{{ message }}
Improve build path mapping to produce clean relative paths in stack traces#102000
Merged
Algunenano merged 2 commits intoApr 8, 2026
Merged
Conversation
…races
Previously, `ENABLE_BUILD_PATH_MAPPING` used `-ffile-prefix-map=${SOURCE_DIR}=.`,
which mapped source paths to `./src/Foo.cpp` but left `DW_AT_comp_dir` pointing
at the build directory. The symbolizer joined them, producing paths like
`./ci/tmp/fast_build/./src/Foo.cpp` in out-of-tree CI builds.
Replace the single flag with two Clang-specific flags:
- `-fdebug-compilation-dir=.` — pins `DW_AT_comp_dir` to `.` unconditionally,
regardless of where the build directory is located.
- `-ffile-prefix-map=${SOURCE_DIR}/=` — strips the source root prefix including
the separator, leaving bare relative paths like `src/Foo.cpp`.
Also fix `Dwarf::LineNumberVM::getFullFileName` to skip a directory entry of `"."`
when building file paths. The DWARF 5 line number program stores the compilation
directory as an explicit entry (index 0), which after the prefix mapping becomes
`"."`. Prepending it produced `./src/Foo.cpp` for `.cpp` translation units while
inlined header frames (whose directory entries were absolute paths that mapped to
`src/Common`) showed as `src/Common/Foo.h` — inconsistent. Treating `"."` as
an empty directory makes all paths consistently bare relative.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
alexey-milovidov
approved these changes
Apr 7, 2026
Member
|
The test |
Contributor
LLVM Coverage ReportChanged lines: 100.00% (4/4) · Uncovered code |
Merged
via the queue into
ClickHouse:master
with commit Apr 8, 2026
cf5fb46
160 of 163 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Stack traces now show clean bare relative paths (e.g.
src/Common/Exception.cpp) instead of paths polluted with the build directory (e.g../ci/tmp/fast_build/./src/Common/Exception.cpp).Description
ENABLE_BUILD_PATH_MAPPINGpreviously used-ffile-prefix-map=${SOURCE_DIR}=., which mapped source paths to./src/Foo.cppbut leftDW_AT_comp_dirpointing at the build directory. The symbolizer joined them, producing paths like./ci/tmp/fast_build/./src/Common/Exception.cppin out-of-tree CI builds.This PR replaces the single flag with two Clang-specific flags:
-fdebug-compilation-dir=.— pinsDW_AT_comp_dirto.unconditionally, regardless of where the build directory is located.-ffile-prefix-map=${SOURCE_DIR}/=— strips the source root prefix including the separator, leaving bare relative paths likesrc/Foo.cpp.It also fixes
Dwarf::LineNumberVM::getFullFileNameto skip a directory entry of"."when building file paths. The DWARF 5 line number program stores the compilation directory as an explicit entry (index 0), which after the prefix mapping becomes".". Prepending it produced./src/Foo.cppfor.cpptranslation units while inlined header frames showed assrc/Common/Foo.h— inconsistent. Treating"."as an empty directory makes all paths consistently bare relative.Before:
After:
Documentation entry for user-facing changes