Deterministic builds with clang and lld describes several degrees of build determinism. Here is the description of local determinism:
Like incremental basic determinism, but builds are also independent of the name of the build directory. Builds of the same source code on the same machine produce exactly the same output every time, independent of the location of the source checkout directory or the build directory.
This is often a stretch goal for a build system. For example, many autotools builds use absolute paths. CMake's Ninja generator uses absolute paths (https://gitlab.kitware.com/cmake/cmake/-/issues/13894).
Options discouraged by the post
-fmacro-prefix-map are useful for such build systems.
This option overrides the compilation directory in DWARF.
-fdebug-compilation-dir=. is commonly used to set the compilation directory to the special directory
.. When input files are specified as relative paths,
% clang -c -g -fdebug-compilation-dir=. ../src/a.c
See Debug info path remapping for the original GCC patch. See https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html for the documentation.
Generated debug information for assembly source
When an assembler source file has no debug information/
.file directive, GNU assembler synthesizes a
DW_TAG_compile_unit entry. This entry is generated when an assembler source file has at least one
.loc directive without a
.debug_info section. The entry is mainly used to provide address ranges for the file.
% cat a.s
LLVM integrated assembler has a similar behavior. See https://github.com/llvm/llvm-project/issues/37398 for the original feature request.
https://github.com/llvm/llvm-project/issues/56609 reported that
-fdebug-prefix-map did not work for generated DWARF v5 debug information. There were two issues.