Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] Fix relative paths in prefix map #74132

Merged
merged 1 commit into from
Dec 1, 2023
Merged

Conversation

ilovepi
Copy link
Contributor

@ilovepi ilovepi commented Dec 1, 2023

When building debug version of LLVM with LLVM_USE_RELATIVE_PATHS_IN_FILES=On would cause source paths to be incorrect, and be prefixed by the build directory. This lead to source locations like the following: ../build/llvm/.... Such paths do not exist, and existing debuggers can't adjust their search location because of the incorrect prefix. Ultimately, this happened because the relative path creation goes in the wrong direction, from source-dir to build-dir instead of from build-dir to source-dir.

This patch swaps the directionality of the relative paths so that they get a proper prefix from the build directory. Given a build dir at /build and a project directory at /llvm-project, we get source locations like: ../llvm-project/llvm/lib/Transforms/..., which a debugger can resolve once pointed to the correct project directory.

Previously, building a debug version of LLVM when -ffile-prefix-map
would cause llvm project paths to be prefixed by the build directory,
so source locations would be "../build/llvm/...". This happened because
the relative path went in the wrong direction, from source-dir to
build-dir instead of from build-dir to source-dir.

This patch swaps the directionality of the relative paths so that they
get a proper prefix from the build directory. Given a build dir at
/build and a project directory at /llvm-project, we get source locations
like: "../llvm-project/llvm/lib/Transforms/...", which a debugger can
resolve once pointed to the correct directory.
@ilovepi ilovepi added the cmake Build system in general and CMake in particular label Dec 1, 2023
@ilovepi ilovepi merged commit d22944d into llvm:main Dec 1, 2023
4 checks passed
@ilovepi ilovepi deleted the debug-path-fix branch December 4, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants