Skip to content

Conversation

@trofi
Copy link
Contributor

@trofi trofi commented Aug 21, 2023

Before the change the following command did not work:

$ nix develop -i --impure --expr 'with import <nixpkgs> { system = "i686-linux"; }; (buildFHSUserEnv { name = "t"; targetPkgs = ps: with ps; [ libmpc stdenv.cc ]; }).env'
$ ld -lmpc -o a
ld: cannot find -lmpc: No such file or directory

It is expected to work as NIX_LDFLAGS does contain valid values:

$ echo $NIX_LDFLAGS
-L/usr/lib -L/usr/lib32

Note that for gcc it does work:

$ printf "int main(){}" |  gcc -x c - -lmpc -o a

It happens because HOST role is enabled for cc:

$ echo $NIX_CC_WRAPPER_TARGET_HOST_i686_unknown_linux_gnu
1

But not for BINTOOLS:

$ echo $NIX_BINTOOLS_WRAPPER_TARGET_HOST_i686_unknown_linux_gnu
<empty>

The change adds BINTOOLS role and fixes linking:

$ nix develop -i --impure --expr 'with import ~/nm { system = "i686-linux"; }; (buildFHSUserEnv { name = "t"; targetPkgs = ps: with ps; [ libmpc stdenv.cc ]; }).env'
$ printf "int main(){}" |  gcc -x c - -lmpc -o a
$ ld -lmpc -o a
ld: warning: cannot find entry symbol _start; not setting start address

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.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.

Before the change the following command did not work:

    $ nix develop -i --impure --expr 'with import <nixpkgs> { system = "i686-linux"; }; (buildFHSUserEnv { name = "t"; targetPkgs = ps: with ps; [ libmpc stdenv.cc ]; }).env'
    $ ld -lmpc -o a
    ld: cannot find -lmpc: No such file or directory

It is expected to work as `NIX_LDFLAGS` does contain valid values:

    $ echo $NIX_LDFLAGS
    -L/usr/lib -L/usr/lib32

Note that for `gcc` it does work:

    $ printf "int main(){}" |  gcc -x c - -lmpc -o a

It happens because `HOST` role is enabled for `cc`:

    $ echo $NIX_CC_WRAPPER_TARGET_HOST_i686_unknown_linux_gnu
    1

But not for `BINTOOLS`:

    $ echo $NIX_BINTOOLS_WRAPPER_TARGET_HOST_i686_unknown_linux_gnu
    <empty>

The change adds BINTOOLS role and fixes linking:

    $ nix develop -i --impure --expr 'with import ~/nm { system = "i686-linux"; }; (buildFHSUserEnv { name = "t"; targetPkgs = ps: with ps; [ libmpc stdenv.cc ]; }).env'
    $ printf "int main(){}" |  gcc -x c - -lmpc -o a
    $ ld -lmpc -o a
    ld: warning: cannot find entry symbol _start; not setting start address
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/development-on-gcc-on-nixos/18376/8

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Aug 21, 2023
@trofi
Copy link
Contributor Author

trofi commented Aug 21, 2023

Result of nixpkgs-review pr 250500 run on x86_64-linux 1

1 package blacklisted:
  • appimage-run-tests
5 packages failed to build:
  • ciscoPacketTracer7
  • houdini
  • pdfstudioviewer
  • pureref
  • radicle-upstream
157 packages built:
  • Sylk
  • altair
  • android-studio
  • androidStudioPackages.beta
  • androidStudioPackages.canary
  • androidStudioPackages.dev
  • anki-bin
  • anytype
  • appimage-run
  • arduino
  • arduino-ci
  • arduino-cli
  • arduino-core
  • atlauncher
  • beekeeper-studio
  • betterdiscord-installer
  • beyond-identity
  • bitscope.chart
  • bitscope.console
  • bitscope.display
  • bitscope.dso
  • bitscope.logic
  • bitscope.meter
  • bitscope.proto
  • bitscope.server
  • bloomrpc
  • bootstrap-studio
  • bottles
  • burpsuite
  • buttercup-desktop
  • caprine-bin
  • chrysalis
  • cider
  • cockroachdb-bin
  • codux
  • conda
  • cozy-drive
  • crypto-org-wallet
  • davinci-resolve
  • devdocs-desktop
  • dropbox
  • dropbox-cli
  • dropbox-cli.nautilusExtension
  • electron-fiddle
  • electron-mail
  • electronplayer
  • esphome
  • esphome.dist
  • expressvpn
  • fahclient
  • firefly-desktop
  • flexoptix-app
  • fluent-reader
  • framesh
  • fspy
  • golden-cheetah-bin
  • hamsket
  • heroic
  • hover
  • insync
  • irccloud
  • jbrowse
  • jetbrains-toolbox
  • joplin-desktop
  • keet
  • kingstvis
  • kodiPackages.steam-launcher
  • lbry
  • ldtk
  • ledger-live-desktop
  • left4gore-bin
  • lens
  • lightworks
  • localsend
  • losslesscut-bin
  • lunar-client
  • lunatask
  • lutris
  • lutris-free
  • marktext
  • mate.caja-dropbox
  • mathpix-snipping-tool
  • mendeley
  • minigalaxy
  • minigalaxy.dist
  • mobilecoin-wallet
  • mockoon
  • molotov
  • motrix
  • museeks
  • mycrypto
  • neo4j-desktop
  • nextflow
  • notable
  • notesnook
  • notion-app-enhanced
  • nuclear
  • octant-desktop
  • openlens
  • osu-lazer-bin
  • p3x-onenote
  • passky-desktop
  • pdfstudio2021
  • pdfstudio2022
  • platformio
  • playonlinux
  • plex
  • plexamp
  • polypane
  • protontricks
  • protontricks.dist
  • protonup-qt
  • quartus-prime-lite
  • rambox
  • raven-reader
  • remnote
  • requestly
  • saleae-logic-2
  • session-desktop
  • shticker-book-unwritten
  • sidequest
  • sonixd
  • space-station-14-launcher
  • sparrow
  • ssb-patchwork
  • station
  • steam
  • steam-rom-manager
  • steam-run
  • steam-small
  • steam-tui
  • steamPackages.steam-fhsenv-without-steam
  • steamPackages.steamcmd
  • teensyduino
  • timeular
  • trezor-suite
  • tusk
  • uhk-agent
  • uhk-udev-rules
  • unigine-superposition
  • unityhub
  • unvanquished
  • upscayl
  • via
  • vial
  • vmware-horizon-client
  • vmware-workstation
  • vscode-fhs
  • vscodium-fhs
  • wootility
  • xivlauncher
  • youtube-music
  • ytmdesktop
  • zecwallet-lite
  • zettlr
  • zettlr-beta
  • zulip

@trofi
Copy link
Contributor Author

trofi commented Aug 21, 2023

All failures are pre-existing. radicle-upstream specifically is broken for a few months:

       > searching for dependencies of /nix/store/8p9yb88z7wd4v095bn5qa7bfkxh5z992-git-remote-rad-0.3.0/bin/git-remote-rad
       >     libgcc_s.so.1 -> not found!
       > auto-patchelf: 1 dependencies could not be satisfied

Copy link
Member

@Atemu Atemu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not knowledgable about these core features of the stdenv/cc-wrappings but I doubt setting these env vars could break anything for our internal usages of FHSEnvs which concern the runtime wrapping of proprietary binaries.

@trofi
Copy link
Contributor Author

trofi commented Aug 22, 2023

Proposed radicle-upstream workaround to fix the build as #250710

@Atemu
Copy link
Member

Atemu commented Aug 23, 2023

I think the only way to test this is to have it merged. This change is tiny anyways.

If nobody objects the next few days, I'll merge this.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/prs-ready-for-review/3032/2612

@Atemu Atemu merged commit 4867914 into NixOS:master Aug 31, 2023
@trofi trofi deleted the fix-buildFHSEnv-BINTOOLS-wrapper branch August 31, 2023 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 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.

4 participants