Skip to content

clang: patch like gcc to mangle store path output by __FILE__#424844

Closed
symphorien wants to merge 1 commit intoNixOS:stagingfrom
symphorien:clang_mangle_store_paths
Closed

clang: patch like gcc to mangle store path output by __FILE__#424844
symphorien wants to merge 1 commit intoNixOS:stagingfrom
symphorien:clang_mangle_store_paths

Conversation

@symphorien
Copy link
Member

this prevents unwanted references to -dev outputs. A similar patch exists for gcc.

tested with

printf "# 0 \"/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-pppppp-vvvvvvv\" \nconst char * f(void) { return __FILE__; }" | NIX_STORE=/nix/store result/bin/clang -x c - -S -o  -

the goal is to replace sanitiseHeaderPathsHook because it breaks the filenames of headers in debug symbols and makes gdb useless in template instantiation.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

this prevents unwanted references to -dev outputs.
A similar patch exists for gcc.

tested with
```
printf "# 0 \"/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-pppppp-vvvvvvv\" \nconst char * f(void) { return __FILE__; }" | NIX_STORE=/nix/store result/bin/clang -x c - -S -o  -
```
@symphorien symphorien changed the base branch from master to staging July 13, 2025 15:25
@nixpkgs-ci nixpkgs-ci bot closed this Jul 13, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Jul 13, 2025
@symphorien symphorien mentioned this pull request Jul 13, 2025
13 tasks
Copy link
Member

@emilazy emilazy left a comment

Choose a reason for hiding this comment

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

The general approach seems like it should work, but as I said on the other PR, I’d really like to see this as a simple addition to the cc-wrapper hook, rather than a patch we’ll never be able to upstream.

The only reason a patch was used for GCC was because of the limits on the command‐line arguments, and the activity on the bug tracker there shows that it’s being actively worked on, so we should hopefully be able to drop the GCC patch at some point and use the same logic for both toolchains.

We have a fair number of packages pinning old versions of LLVMs and we have been working on moving Nix‐specific behaviour out of patches (e.g. #356162) to keep unwrapped compilers closer to upstream behaviour and reduce the burden of updates.

@emilazy
Copy link
Member

emilazy commented Jul 13, 2025

(I also think that it should be fine to just use the nuked e paths for macros, rather than doing the invertible mapping that can trip up on some hashes anyway, since I don’t think getting exact paths for __FILE__ is very valuable and it’s okay for debug info to be completely unmangled. So the logic should be very simple to do in the hook, I think.)

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 27, 2025
emilazy added a commit to emilazy/nixpkgs that referenced this pull request Jul 31, 2025
This is now handled by the compiler wrapper.

I have verified that `webkitgtk_6_0` still has no GCC dependency on
`aarch64-linux`, and that `watchman` doesn’t pull in any `dev`
outputs on `aarch64-darwin`.

Closes: NixOS#424844
Closes: NixOS#426934
Closes: NixOS#427475
Closes: NixOS#428546
@symphorien
Copy link
Member Author

obsoleted by #429880

@symphorien symphorien closed this Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants