Clang MD MF emitting absolute paths

Hi there,

I’m trying to integrate a local build of GitHub - ARM-software/LLVM-embedded-toolchain-for-Arm: A project dedicated to build LLVM toolchain for 32-bit Arm embedded targets. with Bazel to build an embedded project.

I’m running into a problem where clang dependency file generation with MD/MF emits absolute paths for some system header files. Example:

bazel-out/darwin_arm64-opt/bin/hx/kern/_objs/alloc_test/alloc_test.o:
hx/kern/alloc_test.cc hx/kern/alloc.h
external/llvm-embedded-toolchain-for-arm-osx/llvm/lib/clang-runtimes/arm-none-eabi/armv6m_soft_nofp/include/sys/types.h

external/llvm-embedded-toolchain-for-arm-osx/llvm/lib/clang/16/include/float.h
/Users/markus/Hacks/LLVM-embedded-toolchain-for-Arm/BUILD/llvm/lib/clang/16/include/float.h

This is a problem because Bazel configures the toolchain with external paths to achieve hermetic builds inside a sandbox and thus doesn’t know about the absolute path file.

Does anyone know why the file is emitted with an absolute path? Is there any way I can stop that from happening?