Skip to content

Cannot find abc binary when running heir-opt as a standalone binary #885

@kevaundray

Description

@kevaundray

Issue

When running heir-opt as a standalone binary, it cannot find the abc binary.

To reproduce

(This assumes we are in the heir directory)

  1. Build heir-opt using bazel
  • I use bazel build @heir//tools:heir-opt
  • There should be a folder under heir/bazel-bin/tools/heir-opt. The abc binary should also be located at heir/bazel-bin/external/edu_berkeley_abc/abc
  1. Run heir-opt from the bazel-bin directory with a --yosys-optimizer
  • I ran ./bazel-bin/tools/heir-opt --yosys-optimizer --canonicalize --cse heir/tests/yosys_optimizer/add_one.mlir
  • There should be no visible output, whereas we expect for it to show the modified mlir output.
  1. Run heir-opt again, but this time use strace
  • I ran strace ./bazel-bin/tools/heir-opt --yosys-optimizer --canonicalize --cse heir/tests/yosys_optimizer/add_one.mlir
  • The output is quite large so I've pasted it here
  • The line read(3, "sh: 1: external/edu_berkeley_abc"..., 4096) = 48 seems to indicate that it cannot find the abc tool

Solution

What fixed it for me was telling bazel to link to the output location of wherever the abc binary was once it was built.

The modification was made in heir/tools/BUILD.

I changed "HEIR_ABC_BINARY=\\\"$(rootpath @edu_berkeley_abc//:abc)\\\"", to "HEIR_ABC_BINARY=\\\"$(location @edu_berkeley_abc//:abc)\\\"",

Observations

  • Everything works for me when running from bazel, ie bazel build and bazel run work fine.
  • After the change, bazel build and bazel run still work fine for me.
  • The location seems to be an absolute path, so as long as the abc binary is not moved, it works. Otherwise, I had to override the HEIR_ABC_BINARY environment variable to point to the new location of the abc binary

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues concerning build systems and processes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions