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

fix: explicitly remap current dir by using . #13114

Merged
merged 4 commits into from
Dec 8, 2023

Commits on Dec 8, 2023

  1. Configuration menu
    Copy the full SHA
    985d49b View commit details
    Browse the repository at this point in the history
  2. test(trim-paths): add test for each split-debuginfo options

    Also demonstarte that on Linux with split-debuginfo on the remap is broken
    weihanglo committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    7cb7b47 View commit details
    Browse the repository at this point in the history
  3. fix(trim-paths): explicit remap to current dir .

    In https://github.com/rust-lang/rust/blob/87e1447aa/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs#L856
    when the remap result of `work_dir` is an empty string,
    LLVM won't generate some symbols for root debuginfo node.
    For example, `N_SO` and `N_OSO` on macOS,
    or `DW_AT_comp_dir` on Linux when debuginfo is splitted.
    Precisely, it is observed that when the `DIFile` of compile unit was
    provied with an empty compilation `Directory` string,
    LLVM would not emit those symbols for the root DI node.
    
    This behavior is not desired,
    resulting in corrupted debuginfo and degrading debugging experience.
    
    This is might not be a bug of `--remap-path-prefix` in rustc,
    since `-fdebug-prefix-map` in clang 16 could have the same result
    (`DW_AT_comp_dir` is gone when `work_dir` is remapped to an empty string).
    However, in gcc 12 `fdebug-prefix-map` will return an absolute work_dir
    when an empty string occurs.
    
    To not bother whether this needs to be fixed in rustc or not,
    let's fix it by always appending an explicit `.`
    when `--remap-path-prefix` remaps to relative workspace root
    a.k.a. where rustc is invoking.
    
    For more on gcc/clang remap options, see
    https://reproducible-builds.org/docs/build-path/
    weihanglo committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    bb86adf View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fcd4221 View commit details
    Browse the repository at this point in the history