Skip to content

Add -fdebug-prefix-map and follow clang's behavior for debuginfo file/dir names#5039

Merged
kinke merged 6 commits intomasterfrom
fdebug-prefix-map
Feb 3, 2026
Merged

Add -fdebug-prefix-map and follow clang's behavior for debuginfo file/dir names#5039
kinke merged 6 commits intomasterfrom
fdebug-prefix-map

Conversation

@JohanEngelen
Copy link
Copy Markdown
Member

https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fdebug-prefix-map

This is required to have reproducible builds without remapping the source code directory to a fixed location (for example in Bazel, where the source code for every build action will end up in a sandbox directory with some hash in the path name).

Try to keep the implementation as close as possible to what clang does.

Originally implemented by Ilya, modified and expanded by Johan.

@JohanEngelen
Copy link
Copy Markdown
Member Author

I guess the test timeouts mean that indeed this now takes a lot of compile time to generate file info. Will implement a caching mechanism

@JohanEngelen
Copy link
Copy Markdown
Member Author

circleci failure is unrelated (fails in other PRs too)

@JohanEngelen
Copy link
Copy Markdown
Member Author

@kinke Can you review and give your OK for this change? Appreciated!

Ilya Yanok and others added 4 commits January 24, 2026 13:36
…/dir names.

This is required to have reproducible builds without remapping the source code directory to a fixed location (for example in Bazel, where the source code for every build action will end up in a sandbox directory with some hash in the path name).

Try to keep the implementation as close as possible to what clang does.
#undef startswith
#endif
llvm::SmallString<256> P = path;
for (auto &[from, to] : llvm::reverse(opts::debugPrefixMap))
Copy link
Copy Markdown
Member

@kinke kinke Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(clang's reverse makes sense because their debugPrefixMap is a vector of string-pairs, not a std::map)

Edit: I guess that's done so that later -fdebug-prefix-map cmdline args can override earlier ones.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a commit to mimic clang there too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@kinke kinke enabled auto-merge (squash) February 3, 2026 14:54
@kinke kinke merged commit fbc5d2f into master Feb 3, 2026
41 of 42 checks passed
@kinke kinke deleted the fdebug-prefix-map branch February 3, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants