Hi all, trust all is well!
I’m trying to build C++ modules using CLang and Bazel. I’ve created a special rule to compile modules, and inside the rule I’ve created two actions for the seperate steps of compiling the module to a precompiled file, and the second action builds the LLVM bitcode from the pre-compiled file.
This is where I’m having trouble. The precompiled file builds correctly, but the second step, building the bitcode from the precompiled header fails with the following error:
fatal error: malformed or corrupted AST file: ‘could not find file ‘/home/wpieterse/.cache/bazel/_bazel_wpieterse/097a98d4b8ea7d3c9ae2315ed87ce0f0/sandbox/linux-sandbox/1/execroot/bazel_llvm
_stuff/cpp/add.cppm’ referenced by AST file ‘bazel-out/k8-fastbuild/bin/cpp/add.pcm’’
I presume this has something to do with Bazel creating a sandbox for each action. This is why the file cannot be found.
Also, these are the parameters sent to CLang 9.0 when compiling:
Compiling the precompiled header:
./clang -std=c++2a -fmodules-ts --precompile -o add.pcm add.cppm
Compiling the bitcode:
./clang -std=c++2a -fmodules-ts -S -emit-llvm -c add.pcm -o add.bc
I’ve tried searching for a way to use relative paths, but to no avail. The file is there, inside the Bazel execution root, but not in the sandbox.
Is there a switch on CLang that can be used to use relative paths? Am I using the correct command line switches.