NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.09k stars 14.14k forks source link

static build of postgresql (and thus libpq) fails #191920

Open robx opened 2 years ago

robx commented 2 years ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. patch nixpkgs to fix lz4 static build (https://github.com/NixOS/nixpkgs/pull/191915)
  2. build statically some postgresql client tool that links libpq, e.g. pg_top

E.g., nix build github:robx/nixpkgs/lz4-static#pkgsStatic.pg_top does the job.

Build log

$ nix build github:robx/nixpkgs/lz4-static#pkgsStatic.pg_top
error: builder for '/nix/store/jc4h3yc4k5n478bvchfccdyj1a8g3fbx-postgresql-static-x86_64-unknown-linux-musl-14.5.drv' failed with exit code 2;
       last 10 log lines:
       > /nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: /nix/store/zbyfyc4a71mymphik6kz8qxsfasaf1mc-icu4c-71.1-x86_64-unknown-linux-musl/lib/libicuuc.a(ustack.ao):(.data.rel.ro._ZTIN6icu_716UStackE[_ZTIN6icu_716UStackE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
       > /nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: /nix/store/zbyfyc4a71mymphik6kz8qxsfasaf1mc-icu4c-71.1-x86_64-unknown-linux-musl/lib/libicuuc.a(chariter.ao):(.data.rel.ro._ZTIN6icu_7124ForwardCharacterIteratorE[_ZTIN6icu_7124ForwardCharacterIteratorE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
       > /nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: /nix/store/zbyfyc4a71mymphik6kz8qxsfasaf1mc-icu4c-71.1-x86_64-unknown-linux-musl/lib/libicuuc.a(chariter.ao):(.data.rel.ro._ZTIN6icu_7117CharacterIteratorE[_ZTIN6icu_7117CharacterIteratorE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
       > /nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: /nix/store/zbyfyc4a71mymphik6kz8qxsfasaf1mc-icu4c-71.1-x86_64-unknown-linux-musl/lib/libicuuc.a(parsepos.ao):(.data.rel.ro._ZTIN6icu_7113ParsePositionE[_ZTIN6icu_7113ParsePositionE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
       > collect2: error: ld returned 1 exit status
       > make[2]: *** [Makefile:66: postgres] Error 1
       > make[2]: Leaving directory '/build/postgresql-14.5/src/backend'
       > make[1]: *** [Makefile:42: all-backend-recurse] Error 2
       > make[1]: Leaving directory '/build/postgresql-14.5/src'
       > make: *** [GNUmakefile:16: world-src-recurse] Error 2
       For full logs, run 'nix log /nix/store/jc4h3yc4k5n478bvchfccdyj1a8g3fbx-postgresql-static-x86_64-unknown-linux-musl-14.5.drv'.
error: 1 dependencies of derivation '/nix/store/lxlnl2kal1r6a7s6rihs51809djrs79m-pg_top-static-x86_64-unknown-linux-musl-3.7.0.drv' failed to build

Additional context

For the purpose of statically building tools that use libpq, we wouldn't actually need a static build of the postgresql backend. Compare https://github.com/NixOS/nixpkgs/issues/61580, which suggests a separate libpq package.

Notify maintainers

@thoughtpolice @marsam

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.06 MiB download, 0.30 MiB unpacked):
  /nix/store/q6ayjwizl0xcbvknkcksy5g4n1ipa6b1-bash-interactive-5.1-p8-dev
copying path '/nix/store/q6ayjwizl0xcbvknkcksy5g4n1ipa6b1-bash-interactive-5.1-p8-dev' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.91, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
robx commented 2 years ago

Setting icuEnabled to false, the build fails with

/nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld:
  /nix/store/bgsjggllvcb8bs47mnpyz25rq0jvb7qz-libxml2-static-x86_64-unknown-linux-musl-2.9.14/lib/libxml2.a(nanohttp.o):
    in function `xmlNanoHTTPRead':
      > (.text+0x10f8): undefined reference to `inflate'

For whatever it's worth pkgsStatic.xml2 builds successfully, while pkgsStatic.xmlstarlet fails similarly. (Both of these also depend on libxml; trying to figure out whether this is a fundamental problem with pkgsStatic and libxml.)

robx commented 2 years ago

Some progress: