Given that you’re talking about building with Bazel and lhlo, this might be more appropriate for the mlir@tensorflow.org list (https://groups.google.com/a/tensorflow.org/g/mlir). But since I’m here, I’ll try to answer your question
The optimization level you’re setting in the Bazel build command is specifically for the target configuration. Bazel generally assumes you’re doing some sort of cross-compilation, in the sense that the tools that you’re using as part of the build step shouldn’t necessarily be built in the same configuration as your target. So when you set -c dbg
or similar, you’re telling it to build the target binaries in debug mode. So you have a few options here:
Pass --nodistinct_host_configuration
to force Bazel to build the host tools in the target configuration. You’re likely going to end up rebuilding a lot of stuff and thrash various caches, but this is likely the simplest.
Build mlir-tblgen directly as your target bazel build -c dbg @llvm-project//mlir:mlir-tblgen
and then manually invoke it in the same way as Bazel is. You can see what commands Bazel runs with the -s
(User manual - Bazel). Be warned that it will produce quite a bit of output as that will list the command for every command Bazel runs that isn’t cached. If you’re just trying to debug a failed command use --verbose_failures
.
Manually pass the relevant compilation options to --host_copt
(User manual - Bazel). bazel build --host_copt=-O0 --host_copt-UNDEBUG --host_copt=-g ...
I think would be the invocation, though untested
Some more background/complaints: Please add a way to control compilation mode in host-build tools · Issue #4485 · bazelbuild/bazel · GitHub