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

gcc always present in nix-shell and overrides clang #5117

Open
babbaj opened this issue Aug 10, 2021 · 7 comments
Open

gcc always present in nix-shell and overrides clang #5117

babbaj opened this issue Aug 10, 2021 · 7 comments

Comments

@babbaj
Copy link

babbaj commented Aug 10, 2021

Is your feature request related to a problem? Please describe.
When creating a nix-shell with -p, even with --pure, gcc will be included in the $PATH and it will take precedence over any explicitly listed package. This makes it very annoying to try to build a program with clang instead of gcc and requires creating a shell.nix or setting cmake variables to work around.

Describe the solution you'd like
nix-shell is currently created with pkgs.runCommandCC, use pkgs.runCommand instead to just remove gcc

Describe alternatives you've considered
Getting the package arguments to be in the $PATH before the default packages would also work without being a potentially breaking change

@trofi
Copy link
Contributor

trofi commented Oct 23, 2021

I also noticed that pointing cc to clang is not very easy via nix-shell -p clang due to always-present gcc:

$ nix-shell -p gcc -p clang --command 'cc --version'
gcc (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ nix-shell -p clang -p gcc --command 'cc --version'
gcc (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@stale
Copy link

stale bot commented Apr 27, 2022

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

@stale stale bot added the stale label Apr 27, 2022
@stale stale bot removed the stale label Dec 5, 2022
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/using-gcc-14-with-nix/52001/2

@szmarczak
Copy link

ref: #9836

@szmarczak
Copy link

@szmarczak
Copy link

ref: NixOS/nixpkgs#283248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants