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

pkgsStatic.gcc fails to build for Raspberry Pi #88956

Open
langston-barrett opened this issue May 26, 2020 · 2 comments
Open

pkgsStatic.gcc fails to build for Raspberry Pi #88956

langston-barrett opened this issue May 26, 2020 · 2 comments
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: static

Comments

@langston-barrett
Copy link
Contributor

langston-barrett commented May 26, 2020

Describe the bug
Looks like patchelf shouldn't be run on the output of GCC when building in static. Here's the last bit of the log:

Removing empty /nix/store/mh74c5z7kb3b84qahfa1as2850hxl9n1-gcc-debug-9.3.0-armv6l-unknown-linux-musleabihf/share/gcc-9.3.0/ and (possibly) its parents
patchelf is /nix/store/kzbgdws5kwpsw874nr5n18ayhb7n1340-patchelf-0.9/bin/patchelf
cannot find section .dynamic
builder for '/nix/store/9mzlwscgwmvwxv71qxb8na6734zy0wmb-gcc-debug-9.3.0-armv6l-unknown-linux-musleabihf.drv' failed with exit code 1
cannot build derivation '/nix/store/c2lc9wprjg11jfa0qfc0vgkmi1d8v9ad-gcc-debug-wrapper-9.3.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/c2lc9wprjg11jfa0qfc0vgkmi1d8v9ad-gcc-debug-wrapper-9.3.0.drv' failed

This might be totally misguided, but I attempted to fix this like so to no avail:

diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix
index 5785782a671..54d3909255d 100644
--- a/pkgs/development/compilers/gcc/9/default.nix
+++ b/pkgs/development/compilers/gcc/9/default.nix
@@ -144,6 +144,11 @@ stdenv.mkDerivation ({
   inherit noSysDirs staticCompiler crossStageStatic
     libcCross crossMingw;

+  # If GDB has been built as a static executable, running patchelf produces an
+  # error "cannot find section .dynamic", at least when cross-compiling for ARM
+  # on x86_64.
+  dontPatchELF = staticCompiler;
+
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [ texinfo which gettext ]
     ++ (optional (perl != null) perl);
diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix
index 6f331b20d3f..c8fcada095c 100644
--- a/pkgs/top-level/static.nix
+++ b/pkgs/top-level/static.nix
@@ -179,6 +179,9 @@ in {
     static = true;
     twisted = null;
   };
+  gcc-unwrapped = super.gcc-unwrapped.override {
+    staticCompiler = true;
+  };
   gmp = super.gmp.override {
     withStatic = true;
   };

To Reproduce
Steps to reproduce the behavior:

nix-build . --arg crossSystem '(import <nixpkgs> {}).lib.systems.examples.raspberryPi' -A pkgsStatic.gcc

Expected behavior
The build should succeed.

Additional context

Notify maintainers

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.41, NixOS, 20.03.1950.48723f48ab9 (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.4`
 - channels(root): `"nixos-20.03.1950.48723f48ab9, nixos-hardware"`
 - channels(siddharthist): `"home-manager-20.03, unstable-20.09pre223023.fce7562cf46"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@langston-barrett langston-barrett added the 0.kind: bug Something is broken label May 26, 2020
@matthewbauer
Copy link
Member

This is probably from

if type "patchelf"; then
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do
PREV_RPATH=`patchelf --print-rpath "$i"`
NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'`
patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
done
fi
. Any patchelf --print-rpath call will fail like that on static executables. We need to have a fallback.

@stale
Copy link

stale bot commented Nov 23, 2020

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 Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: static
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants