I am trying to write a compiler, well, a Python wrapper for Clang that does some platform specific stuff in Bazel. I have created a MRE where I can reproduce my problem here: https://github.com/allsey87/custom_cc_toolchain
The workspace is supposed to be built using the following command:
bazel build --platforms=//:custom_platform //:test
Based on the following output from Bazel, I think my py_binary
has been created and is found, however, there is a failing assertion from the Bazel’s Python wrapper code as follows:
$ bazel clean --expunge
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
$ bazel build --verbose_failures --sandbox_debug --platforms=//:custom_platform //:test
Starting local Bazel server and connecting to it...
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
INFO: Analyzed target //:test (87 packages loaded, 754 targets configured).
ERROR: /workspaces/bazel_test/BUILD:23:10: Compiling empty.c failed: (Exit 1): process-wrapper failed: error executing CppCompile command
(cd /home/developer/.cache/bazel/_bazel_developer/e4895a8da4e216f782d166038e1bbca2/sandbox/processwrapper-sandbox/1/execroot/_main &&
exec env -
PATH=/vscode/vscode-server/bin/linux-x64/5437499feb04f7a586f677b155b039bc2b3669eb/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/proc/self/cwd
TMPDIR=/tmp
/home/developer/.cache/bazel/_bazel_developer/install/937e6e0d806e40997135c14c1d61532a/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/home/developer/.cache/bazel/_bazel_developer/e4895a8da4e216f782d166038e1bbca2/sandbox/processwrapper-sandbox/1/stats.out' bazel-out/k8-opt-exec-ST-d57f47055a04/bin/clang_wrapper -MD -MF bazel-out/k8-fastbuild/bin/_objs/test/empty.d '-frandom-seed=bazel-out/k8-fastbuild/bin/_objs/test/empty.o' -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools -c empty.c -o bazel-out/k8-fastbuild/bin/_objs/test/empty.o)
Traceback (most recent call last):
File "/home/developer/.cache/bazel/_bazel_developer/e4895a8da4e216f782d166038e1bbca2/sandbox/processwrapper-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/clang_wrapper", line 559, in <module>
Main()
File "/home/developer/.cache/bazel/_bazel_developer/e4895a8da4e216f782d166038e1bbca2/sandbox/processwrapper-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/clang_wrapper", line 457, in Main
module_space = FindModuleSpace(main_rel_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/developer/.cache/bazel/_bazel_developer/e4895a8da4e216f782d166038e1bbca2/sandbox/processwrapper-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/clang_wrapper", line 172, in FindModuleSpace
raise AssertionError('Cannot find .runfiles directory for %s' % sys.argv[0])
AssertionError: Cannot find .runfiles directory for bazel-out/k8-opt-exec-ST-d57f47055a04/bin/clang_wrapper
Target //:test failed to build
INFO: Elapsed time: 5.067s, Critical Path: 0.05s
INFO: 7 processes: 7 internal.
ERROR: Build did NOT complete successfully
How can I provide this .runfiles directory to the toolchain?