[clang] [clang] Add -fno-debug-record-sysroot (PR #192541)

Keith Smiley via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 11:01:03 PDT 2026


keith wrote:

> @keith could you elaborate on the "reproducible builds" part?

the case I'm interested in at the moment is that if you build `clang foo.m -c -g -o foo.o -ffile-compilation-dir=.` the debug info has an absolute path to your Xcode installation, which may not be the same as the path on the machine you end up debugging on in the case of distributed builds. Today you can fix this with `-fdebug-prefix-map=/path/to/xcode.app=/PLACEHOLDER` but that's potentially annoying to fit into your build system.

> On Darwin-derived operating systems LLDB really only consumes the name of the SDK directory

I might be misunderstanding the issue here, but in this patch I left the `DW_AT_APPLE_sdk`, so I think that info is still there?

This is with `-fno-debug-record-sysroot`:

```
0x0000000c: DW_TAG_compile_unit
              DW_AT_producer	("clang version 23.0.0git (https://github.com/llvm/llvm-project 860e78e212c2bb9091fb6a96160c40e9d5f80491)")
              DW_AT_language	(DW_LANG_ObjC)
              DW_AT_name	("foo.m")
              DW_AT_APPLE_sdk	("MacOSX.sdk")
```

> introduce a new DW_AT_APPLE_sdk attribute for this purpose

see above.

> but LLDB needs at least the latter to attempt to import the Clang module from source. The key to making that reproducible should IMHO be a prefix remapping.

if this is the case than likely the `-fdebug-prefix-map` flag I mentioned above is the solution. Although what happens in the case that path is not valid? Since at least today in our builds we leave it as the `/PLACEHOLDER` and debugging still works fine, but even if we didn't and just left this full path in there, it could be invalid if the Xcode path is different.

> For our implementation of caching work, DW_LLVM_AT_include_path is not needed (or sysroot) unless there is a relative include path.

are you doing anything special to handle this path or just letting lldb's fallback logic deal with it?

https://github.com/llvm/llvm-project/pull/192541


More information about the cfe-commits mailing list