Skip to content

cc-wrapper: fix linking against GCC libs for non-GCC#133512

Closed
Kha wants to merge 1 commit intoNixOS:stagingfrom
Kha:staging
Closed

cc-wrapper: fix linking against GCC libs for non-GCC#133512
Kha wants to merge 1 commit intoNixOS:stagingfrom
Kha:staging

Conversation

@Kha
Copy link
Contributor

@Kha Kha commented Aug 11, 2021

Motivation for this change

clang++ currently links programs statically against libstdc++, which is not expected as upstream clang as well as g++ do not do so. It turns out that while gccForLibs.lib contains a libstdc++.so.6, the specified path does not exist (anymore?), so this change restores the likely intended behavior.
Without this change, clang finds a libstdc++.a by appending ../../.. to the -L flag above the changed line. Not sure where that is coming from, but with this change the flag order makes it find the .so first.

/cc @Ericson2314?

$ echo '#include <exception>\nint main() { throw std::exception(); }' > foo.cpp
$ nix shell nixpkgs#clang -c c++ foo.cpp
$ ldd a.out | grep libstd
$
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.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.

@Kha Kha requested a review from Ericson2314 as a code owner August 11, 2021 14:33
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Aug 11, 2021
@SuperSandro2000
Copy link
Member

@alyssais @Ericson2314 ping

@stale
Copy link

stale bot commented Apr 18, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 18, 2022
@NickCao
Copy link
Member

NickCao commented May 30, 2022

Still relevant.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 30, 2022
@andurillb
Copy link

How could I increase the level of urgency of this PR?

@danielfullmer
Copy link
Contributor

I've submitted another PR for this issue which also works in the cross-compilation case: #192459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants