llvmPackages.clang: embed resource directory in Clang libraries#420382
Merged
alyssais merged 1 commit intoNixOS:masterfrom Jul 2, 2025
Merged
llvmPackages.clang: embed resource directory in Clang libraries#420382alyssais merged 1 commit intoNixOS:masterfrom
alyssais merged 1 commit intoNixOS:masterfrom
Conversation
Member
|
Great! So do we draft this until the patch is accepted upstream? |
Contributor
Author
Makes sense, done |
Contributor
Author
|
Upstream patch landed, ready for review. I noticed one more issue with absolute resource directory paths and sent a fix: llvm/llvm-project#146449 I wouldn't expect landing this PR to regress anything in the meantime though because resource directory lookup via the API doesn't work anyway. |
When Clang is statically linked against other programs they are unable to find the headers in Clang's resource directory. Typically the resource directory is found by searching a path relative to argv[0] but this would only really work for Clang itself due to each binary having a separate prefix (and not in Nix because of the full resource directory being split between multiple derivations and assembled in the wrapper). Because users of Clang as a library typically only need include in order for parsing to succeed, let's set that as the resource directory. The LLVM patch to make this work was sent upstream in llvm/llvm-project#145996, I intend to land it upstream and drop it from this PR.
dramforever
added a commit
to dramforever/nixpkgs
that referenced
this pull request
Oct 4, 2025
Since NixOS#420382, we set an absolute default CLANG_RESOURCE_DIR for LLVM versions >= 21, which breaks the bootstrap tools because the absolute path was removed by nuke-ref while building and isn't there while bootstrapping. Pass -resource-dir explicitly while testing Clang to make it work.
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.
When Clang is statically linked against other programs they are unable to find the headers in Clang's resource directory. Typically the resource directory is found by searching a path relative to argv[0] but this would only really work for Clang itself due to each binary having a separate prefix (and not in Nix because of the full resource directory being split between multiple derivations and assembled in the wrapper).
Because users of Clang as a library typically only need include in order for parsing to succeed, let's set that as the resource directory. The LLVM patch to make this work was sent upstream in llvm/llvm-project#145996, I intend to land it upstream and drop it from this PR.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.