Skip to content

llvmPackages.clang: Drop CLANG_DEFAULT_CXX_STDLIB#351685

Merged
RossComputerGuy merged 1 commit intoNixOS:masterfrom
pwaller:drop-default-cxxlib
Oct 29, 2024
Merged

llvmPackages.clang: Drop CLANG_DEFAULT_CXX_STDLIB#351685
RossComputerGuy merged 1 commit intoNixOS:masterfrom
pwaller:drop-default-cxxlib

Conversation

@pwaller
Copy link
Copy Markdown
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 p@pwaller.net

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 <p@pwaller.net>
@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
Copy Markdown
Member

Ack

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 27, 2024
@paparodeo
Copy link
Copy Markdown
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.

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Oct 27, 2024
@pwaller
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 persons. and removed 12.approvals: 1 This PR was reviewed and approved by one 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 any of the changed packages. label Oct 28, 2024
@wegank wegank removed the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Oct 29, 2024
@RossComputerGuy RossComputerGuy merged commit 5740734 into NixOS:master Oct 29, 2024
@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 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants