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

Installing any gcc version also installs version 10 and defaults to the latter #127249

Open
ljleb opened this issue Jun 17, 2021 · 16 comments
Open

Comments

@ljleb
Copy link

ljleb commented Jun 17, 2021

Describe the bug
I tried to launch a shell using the gcc11 package, but gcc -v yields "10.3.0" instead of "11.1.0"

To Reproduce
Steps to reproduce the behavior:

  1. launch a shell with gcc nix-shell -p gcc11
  2. check gcc version gcc -v and recognise something's off

Expected behavior
I would expect the version of gcc to be 11.1.0

Actual behavior
The version of gcc being selected is 10.3.0.

Screenshots
1623953494

Additional context
Both gcc 11.1.0 and 10.3.0 get installed, and both are in $PATH, but 10.3.0 is the first listed in there:

[nix-shell:~]$ printf '%s\n' ${PATH//:/$'\n'}
/nix/store/fgbzvd4c6nly9m4dpczrxybdpkm8mnk3-bash-interactive-4.4-p23/bin
/nix/store/nn70k5w99m6y59ldxlnb1x6j4q8bbjbq-patchelf-0.12/bin
/nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin
/nix/store/h3f8rn6wwanph9m3rc1gl0lldbr57w3l-gcc-10.3.0/bin # this should not get installed in the first place
/nix/store/d32ym7m2p7lfb6gsghq1dhi61f694k0f-glibc-2.32-46-bin/bin
/nix/store/0vkw1m51q34dr64z5i87dy99an4hfmyg-coreutils-8.32/bin
/nix/store/pd21dgf1vdpxbfx7ilbwb8hs9l3wd6xd-binutils-wrapper-2.35.1/bin
/nix/store/77i6h1kjpdww9zzpvkmgyym2mz65yff1-binutils-2.35.1/bin
/nix/store/21kw9s3jf419f0fqk53rlnjzlf3h2m2p-gcc-wrapper-11.1.0/bin
/nix/store/wgrmw9d9qmnqdcbxsl98bkhacz8hnw0i-gcc-11.1.0/bin # only this should
...

Manually removing gcc-10.3.0/bin from $PATH is my current workaround, which isn't really user-friendly.

Notify maintainers
@alyssais

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
these paths will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/rmhwi0jcya8f87gzk2jjdwv4hifmmbb4-nix-info
copying path '/nix/store/rmhwi0jcya8f87gzk2jjdwv4hifmmbb4-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 4.15.0-142-generic, Ubuntu, 16.04.7 LTS (Xenial Xerus)`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.12`
 - channels(abstrack): `"nixpkgs-21.11pre295670.189a1368878"`
 - nixpkgs: `/home/abstrack/.nix-defexpr/channels/nixpkgs`

Maintainer information:

attribute: gcc11
module:
@ljleb ljleb changed the title Installing gcc11 actually also installs gcc10 and defaults to the latter Installing gcc11 also installs gcc10 and defaults to the latter Jun 17, 2021
@mmlb
Copy link
Contributor

mmlb commented Jul 2, 2021

@lebel-louisjacob its actually worse than that, its happening for any gcc version. Can you amend your issue title?

[manny@nixc3small:~]$ for v in 48 49 6 7 8 9 10 11; do echo want gcc$v; nix-shell -p gcc$v --run "gcc -v |& grep 'gcc version'; which gcc"; done
want gcc48
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc49
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc6
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc7
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc8
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc9
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc10
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc
want gcc11
gcc version 10.3.0 (GCC) 
/nix/store/x0xd1vp2w7n38g0hzflzy8p6hyl0dwic-gcc-wrapper-10.3.0/bin/gcc

@mmlb
Copy link
Contributor

mmlb commented Jul 2, 2021

I've just started a bisect run, I'm starting on 0b83126 as my good.

@ljleb ljleb changed the title Installing gcc11 also installs gcc10 and defaults to the latter Installing any gcc version also installs version 10 and defaults to the latter Jul 2, 2021
@mmlb
Copy link
Contributor

mmlb commented Jul 3, 2021

The git bisect came back with af80265 as the bad commit:

git bisect log
git bisect start
# good: [0b8312660aaa34cc87bdf5e3776bcaf4c5ba3c59] gcc10: fix building darwin->linux cross compiler
git bisect good 0b8312660aaa34cc87bdf5e3776bcaf4c5ba3c59
# bad: [c40d0126f85b4b38bbcee0812366de9e0948c4ec] Merge pull request #129022 from Mic92/flask-compress
git bisect bad c40d0126f85b4b38bbcee0812366de9e0948c4ec
# bad: [0667f269fc138184d930d606b2a1dc4e9e6187f7] Merge staging-next into staging
git bisect bad 0667f269fc138184d930d606b2a1dc4e9e6187f7
# good: [9e062723b2d60d2be85268fb7eebb28abce0b5af] Merge master into staging-next
git bisect good 9e062723b2d60d2be85268fb7eebb28abce0b5af
# bad: [add2d890824281417852b38cf2804fc01b3bd81e] Merge master into staging-next
git bisect bad add2d890824281417852b38cf2804fc01b3bd81e
# good: [afead527c444e9459fc0a32c9b9992862ef9e77e] Merge pull request #105615 from collares/sage-update
git bisect good afead527c444e9459fc0a32c9b9992862ef9e77e
# good: [507f0fc185b1ff414d16e8e0267a0cc430dfca83] Merge pull request #107350 from fabaff/msgpack
git bisect good 507f0fc185b1ff414d16e8e0267a0cc430dfca83
# bad: [bde5fee350d6fa83c550cd5a8df03b6fd3e44a93] Merge pull request #108463 from 1000101/pgmodeler
git bisect bad bde5fee350d6fa83c550cd5a8df03b6fd3e44a93
# bad: [a6e50716bd5db56903b2b1044be308e12d466e53] Merge pull request #107890 from cpcloud/prom-more-relabel-actions
git bisect bad a6e50716bd5db56903b2b1044be308e12d466e53
# bad: [f19b7b03a03b7f1d5beb44471eb9298de4b9e186] Merge branch 'master' into staging-next
git bisect bad f19b7b03a03b7f1d5beb44471eb9298de4b9e186
# good: [e8a8d380ec4fd84eb60a615ea11b4c88eb98fbb8] Merge pull request #107490 from gebner/gstreamer-wrapper
git bisect good e8a8d380ec4fd84eb60a615ea11b4c88eb98fbb8
# bad: [760bb86156afaba267759483f407e1064dea950b] perlPackages.ExtUtilsPkgConfig: disable checks
git bisect bad 760bb86156afaba267759483f407e1064dea950b
# good: [8cedad3fe60cc1350ffd639a283a480a8563757e] gtk-doc: 1.33.0 -> 1.33.1
git bisect good 8cedad3fe60cc1350ffd639a283a480a8563757e
# good: [9ddbef87ecb9be3c6ad49cabf727cf8b3c10693b] Merge staging-next into staging
git bisect good 9ddbef87ecb9be3c6ad49cabf727cf8b3c10693b
# bad: [b1b3ca79073ba82b551906fd11cc0ca086f81894] gcc: make -fcommon default on gcc10
git bisect bad b1b3ca79073ba82b551906fd11cc0ca086f81894
# good: [3a3b682793042046233421a60deb71e4d0750bb6] Merge pull request #103674 from chkno/lcms-src-fix
git bisect good 3a3b682793042046233421a60deb71e4d0750bb6
# good: [2d9193f9f032c52594d90eb64b8c4ffa8c615354] Merge staging-next into staging
git bisect good 2d9193f9f032c52594d90eb64b8c4ffa8c615354
# bad: [af802654b91e150fdaa8e32c29a0eefbdf953597] use gcc10 instead of gcc9
git bisect bad af802654b91e150fdaa8e32c29a0eefbdf953597
# first bad commit: [af802654b91e150fdaa8e32c29a0eefbdf953597] use gcc10 instead of gcc9

@mmlb
Copy link
Contributor

mmlb commented Jul 3, 2021

which looking at the commit doesn't seem to make sense. So tried gcc8 instead of gcc9 and am seeing the same behavior!

[02:11:21]-[~/cloned/NixOS/nixpkgs]─[manny@nixc3small]> 
git checkout 0b8312660aaa34cc87bdf5e3776bcaf4c5ba3c59
HEAD is now at 0b8312660aa gcc10: fix building darwin->linux cross compiler
                                                                                                                                                                                      
[02:11:37]-[~/cloned/NixOS/nixpkgs]─[manny@nixc3small]> 
nix-shell -I nixpkgs=. -p gcc8 --run 'gcc -v|& grep version'
gcc version 9.3.0 (GCC) 

@mmlb
Copy link
Contributor

mmlb commented Jul 3, 2021

Going further back to when gcc7 came into the tree shows the expected behavior. Bisecting from there.

@mmlb
Copy link
Contributor

mmlb commented Jul 3, 2021

Bisecting once again got me to:

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
9cda2f5559bcbc8ca279521561f6096b35c7f07a
0f5c80463176f7b146e8ef1943a3bbd61d4cbaf0
114a9b625386e3ca4e142dce6ce8bcfcabea8fe3
4ad9a97e9678c70ca974c43fe3ef27f0e65af15a
bc23afe5c7fd9095b1e49fccc51a42a18dd220c4
5b74540c5be2ca4c47b61ef9d0776412266addeb
a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457
046f091e0d9853a81ce4d484a75cfa1b5fc9347d
3a50395ef226259694689da92b2fd636476abc67
a036473a0a0c6100fce316e1444fc33ec6674b85
e0f1739c75c5bd2618d90789627b173066656f78
7f3ca3e21a22fd3101b40cadb86899542dec2e35
f083248290fb1268fba1beb8e1c353c4cb39528d
469fd8983276d851c19827cd9e78a89dd53a5914
We cannot bisect more!
bisect run cannot continue any more

it seems building gcc is broken during these commits so git bisect can't figure out the exact commit. Looking at the commit diffs:
bc23afe
7f3ca3e
seem most likely to me (though I'm not very well versed in whats going on in the gcc derivations and could be totally wrong).

I'll try to get gcc building again during those commits to see if I can track down the actual commit.

@mmlb
Copy link
Contributor

mmlb commented Jul 3, 2021

I'm going to try and get @Ericson2314 's attention here

gagbo added a commit to LedgerHQ/lib-ledger-core that referenced this issue Aug 19, 2021
gagbo added a commit to LedgerHQ/lib-ledger-core that referenced this issue Aug 20, 2021
* Need to use gcc10 instead of gcc11 because of an
  outstanding bug that prevents from using any other
  version. That means the .so file is not correctly linked.
We use gcc10 instead of using an older nixpkgs pin because
we would lack other dependencies otherwise

Ref: NixOS/nixpkgs#127249

* Refactor nix derivations  and add readme info
@r-burns
Copy link
Contributor

r-burns commented Aug 21, 2021

I think this is a common user error due to the way nix-shell works. nix-shell -p pkg doesn't give you only pkg - it drops you into a development shell containing stdenv and additionally the requested pkg. And our stdenv uses gcc 10, so that's why you're always seeing gcc 10.

I don't know a way to do what you want on the command-line, but you can use a shell.nix:

$ cat shell.nix 
with import <nixpkgs> {};
gcc11Stdenv.mkDerivation {
  name = "test";
  src = ./.;
}
$ nix-shell
$ gcc --version
gcc (GCC) 11.1.0

@gagbo
Copy link

gagbo commented Sep 2, 2021

Derp. Thanks!

@mmlb
Copy link
Contributor

mmlb commented Sep 2, 2021

Hey @r-burns thanks for this info, makes sense 🤦 . I wonder if theres an easy enough way to treat the buildInputs as more important by setting them earlier in the path than stdenv.mkDerivation 🤔 ?

@r-burns
Copy link
Contributor

r-burns commented Sep 3, 2021

Not helpful if you need to use nix-shell -p, but if you're okay with creating a .nix file, you could use stdenvNoCC.mkDerivation.

@mmlb
Copy link
Contributor

mmlb commented Sep 3, 2021

nice, and as of June 24 we can do mkShellNoCC in shell.nix.

@stale
Copy link

stale bot commented Apr 28, 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 28, 2022
@coderfromhere
Copy link

what is mkShellNoCC? where can I read about it?

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

gagbo commented May 18, 2022

It took me one copy-paste in the search bar to find the info.

At least the post reminded me to unsubscribe from here I guess

@coderfromhere
Copy link

coderfromhere commented May 18, 2022

@gagbo it just leads to another similar question: what is stdenvNoCC and how is it different from stdenv? Let's not pretend the copy-paste to a github search bar answers the question.

There's exactly one match in the official nixpkgs manual (https://nixos.org/manual/nixpkgs/stable/) that doesn't shed a light on that question either.

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

No branches or pull requests

5 participants