NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.68k stars 13.83k forks source link

pkgsStatic.borgbackup fails #64471

Open nomeata opened 5 years ago

nomeata commented 5 years ago

I tried to build a static version of borgbackup, but it failed:

$ nix build pkgsStatic.borgbackup -f .
…
builder for '/nix/store/8xji6vq74qz05bansmk362vfqi005dgg-keyutils-1.6-x86_64-unknown-linux-musl.drv' failed with exit code 1; last 10 log lines:
  grep: /usr/lib/rpm: No such file or directory
  x86_64-unknown-linux-musl-gcc -I. -g -Wall -Werror -o keyctl.o -c keyctl.c
  x86_64-unknown-linux-musl-gcc -I. -DPKGBUILD="\"1970-01-01\"" -DPKGVERSION="\"keyutils-1.6\"" -DAPIVERSION="\"libkeyutils-1.8\"" -g -Wall -Werror -fPIC -o keyutils.os -c keyutils.c
  x86_64-unknown-linux-musl-gcc -g -Wall -Werror -fPIC  -shared -Wl,-soname,libkeyutils.so.1 -Wl,--version-script,version.lds -o libkeyutils.so.1.8 keyutils.os
  /nix/store/b2zlnsp56ccrq2y0ybgwlm3m2ils7xhj-x86_64-unknown-linux-musl-binutils-2.31.1/bin/x86_64-unknown-linux-musl-ld: /nix/store/zyrpxbdzmqpi2yvxypxkwsp5d2z3g05j-x86_64-unknown-linux-musl-stage-final-gcc-debug-7.4.0/lib/gcc/x86_64-unknown-linux-musl/7.4.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
  /nix/store/b2zlnsp56ccrq2y0ybgwlm3m2ils7xhj-x86_64-unknown-linux-musl-binutils-2.31.1/bin/x86_64-unknown-linux-musl-ld: /nix/store/zyrpxbdzmqpi2yvxypxkwsp5d2z3g05j-x86_64-unknown-linux-musl-stage-final-gcc-debug-7.4.0/lib/gcc/x86_64-unknown-linux-musl/7.4.0/crtend.o: relocation R_X86_64_32 against `.ctors' can not be used when making a shared object; recompile with -fPIC
  /nix/store/b2zlnsp56ccrq2y0ybgwlm3m2ils7xhj-x86_64-unknown-linux-musl-binutils-2.31.1/bin/x86_64-unknown-linux-musl-ld: final link failed: nonrepresentable section on output
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:138: libkeyutils.so.1.8] Error 1
  builder for '/nix/store/8xji6vq74qz05bansmk362vfqi005dgg-keyutils-1.6-x86_64-unknown-linux-musl.drv' failed with exit code 2
cannot build derivation '/nix/store/1amll33h5m5c1w5lvd08iz3rjilzkfq1-libkrb5-1.17-x86_64-unknown-linux-musl.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/p0lqychn6d30nh4kfd0i77xi984m6nqx-openssh-7.9p1-x86_64-unknown-linux-musl.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/28fcvpfy6db21vcw3sckn2pw7rb8b75w-borgbackup-1.1.10-x86_64-unknown-linux-musl.drv': 1 dependencies couldn't be built

This is with nixpkgs revision 6cc7e33ac8ac7b255bd621e8fbfb29c1fd49966e

It is not super important to me, so if reports about a random package not building statically are not helpful at this point, feel free to just close this.

rasendubi commented 5 years ago

Looks like keyutils is not able to build the static library.

krb5 has a conditional to disable keyutils on bionic and llvm https://github.com/NixOS/nixpkgs/blob/5ad0677aec2455e664992d93d063d5cb34a32e2f/pkgs/development/libraries/kerberos/krb5.nix#L44

We could either add a musl condition there, or apply cross-compilation tweaks to keyutils. (Gentoo seem to has this.)

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
Ma27 commented 4 years ago

I just needed keyutils to get something else built statically. I managed to get it building with the following patch:

diff --git a/pkgs/os-specific/linux/keyutils/default.nix b/pkgs/os-specific/linux/keyutils/default.nix
index 553b0b87f41..1139fe5b5f4 100644
--- a/pkgs/os-specific/linux/keyutils/default.nix
+++ b/pkgs/os-specific/linux/keyutils/default.nix
@@ -23,10 +23,14 @@ stdenv.mkDerivation rec {
     ./conf-symlink.patch
   ];

+  postPatch = ''
+    sed -ie 's/\-shared/\-static/g' Makefile
+  '';
+
   BUILDDATE = "1970-01-01";
   outputs = [ "out" "lib" "dev" ];

-  installFlags = [
+  makeFlags = [
     "ETCDIR=$(out)/etc"
     "BINDIR=$(out)/bin"
     "SBINDIR=$(out)/sbin"
@@ -35,6 +39,8 @@ stdenv.mkDerivation rec {
     "INCLUDEDIR=$(dev)/include"
     "LIBDIR=$(lib)/lib"
     "USRLIBDIR=$(lib)/lib"
+    "NO_ARLIB=0"
+    "NO_SOLIB=1"
   ];

   meta = with stdenv.lib; {

I didn't do further research on this, however e.g. openssh seems to break on pkgsStatic as well.

expipiplus1 commented 3 years ago

@Ma27 You should open a PR with that patch (changes conditional on stdenv.targetPlatform.isStatic)!

stale[bot] commented 3 years ago

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