Skip to content

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 requested a review from petrhosek December 1, 2023 19:32
@ilovepi ilovepi merged commit d22944d into llvm:main Dec 1, 2023
@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

2 participants