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

llvmPackages.clang: Drop CLANG_DEFAULT_CXX_STDLIB #351685

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

pwaller
Copy link
Contributor

@pwaller pwaller commented Oct 27, 2024

This is better handled in the cc-wrapper, and makes it possible to avoid
rebuilding clang in some scenarios.

It also appears to be unnecessary since the cc-wrapper already passes
-stdlib=libc++ where needed.

See:

echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags

Signed-off-by: Peter Waller [email protected]

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (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.

Add a 👍 reaction to pull requests you find important.

This is better handled in the cc-wrapper, and makes it possible to avoid
rebuilding clang in some scenarios.

It also appears to be unnecessary since the cc-wrapper already passes
-stdlib=libc++ where needed.

See: https://github.com/NixOS/nixpkgs/blob/8885a1e21ad43f8031c738a08029cd1d4dcbc2f7/pkgs/build-support/cc-wrapper/default.nix#L603
Signed-off-by: Peter Waller <[email protected]>
@github-actions github-actions bot added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label Oct 27, 2024
@pwaller pwaller marked this pull request as ready for review October 27, 2024 15:30
@alyssais
Copy link
Member

Ack

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Oct 27, 2024
@paparodeo
Copy link
Contributor

This is better handled in the cc-wrapper, and makes it possible to avoid rebuilding clang in some scenarios.

it is not obvious to me how it helps rebuilding clang. what scenarios does this cause additional rebuilds? I'd think that dropping the cc-wrapper duplicate would be preferable over dropping properly setting the default at compile time.

@pwaller
Copy link
Contributor Author

pwaller commented Oct 27, 2024

it is not obvious to me how it helps rebuilding clang. what scenarios does this cause additional rebuilds? I'd think that dropping the cc-wrapper duplicate would be preferable over dropping properly setting the default at compile time.

The code removed here gets rid of the only place I can see where the clang derivation varies by targetPlatform.

Clang is a cross compiler by default. So in the best case you only need to build it once and then you can use it for various things by passing different parameters to it. What I want is to use the clang provided by the existing public build, so I don't need to rebuild it, but then use crossSystem to target something else.

This can be arranged with import <nixpkgs> { crossSystem = ...; config.replaceCrossStdenv = { buildPackages, baseStdenv }: somethingInvolving buildPackages.llvmPackages.clang-unwrapped; } to substitute in the compiler from buildPackages, but because the build varies according to the targetPlatform, this requires a rebuild of clang for each one, even though they are functionally identical. This isn't necessary - the wrapper is incredibly cheap to rebuild compared with rebuilding the compiler, it is better if the flag lives there.

@paparodeo
Copy link
Contributor

paparodeo commented Oct 27, 2024

it is not obvious to me how it helps rebuilding clang. what scenarios does this cause additional rebuilds? I'd think that dropping the cc-wrapper duplicate would be preferable over dropping properly setting the default at compile time.

The code removed here gets rid of the only place I can see where the clang derivation varies by targetPlatform.

aren't the build inputs different tho?
[edit] tried a build without the compile flag and observed clang not getting rebuilt.

@RossComputerGuy
Copy link
Member

To note, the flag was misinterpreted in its use. Source

@wegank wegank added 12.approvals: 2 This PR was reviewed and approved by two reputable people and removed 12.approvals: 1 This PR was reviewed and approved by one reputable person labels Oct 28, 2024
@rrbutani rrbutani added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package label Oct 28, 2024
@wegank wegank removed the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package label Oct 29, 2024
@RossComputerGuy RossComputerGuy merged commit 5740734 into NixOS:master Oct 29, 2024
34 of 35 checks passed
@pwaller pwaller deleted the drop-default-cxxlib branch October 29, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 1-10 10.rebuild-linux: 11-100 12.approvals: 2 This PR was reviewed and approved by two reputable people
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants