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

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

Open
robx opened this issue Sep 19, 2022 · 2 comments · May be fixed by #345289
Open

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

robx opened this issue Sep 19, 2022 · 2 comments · May be fixed by #345289

Comments

@robx
Copy link
Contributor

robx commented Sep 19, 2022

Steps To Reproduce

Steps to reproduce the behavior:

  1. patch nixpkgs to fix lz4 static build (lz4: fix static build #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 #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
Copy link
Contributor Author

robx commented Sep 19, 2022

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
Copy link
Contributor Author

robx commented Sep 19, 2022

Some progress:

make[3]: Entering directory '/home/rob/postgresql-14.5/src/backend/utils/mb/conversion_procs/euc_cn_and_mic'
x86_64-unknown-linux-musl-cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2 -fPIC -I../../../../../../src/include  -D_GNU_SOURCE -I/nix/store/cks2a0805w2scxjavn8299fawadng2i6-libxml2-static-x86_64-unknown-linux-musl-2.9.14-dev/include/libxml2 -I/nix/store/yy6c26ms94fff2nckjrfjm416f7k5hvb-lz4-static-x86_64-unknown-linux-musl-1.9.4-dev/include   -c -o euc_cn_and_mic.o euc_cn_and_mic.c
x86_64-unknown-linux-musl-cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2 -fPIC -shared -o euc_cn_and_mic.so euc_cn_and_mic.o  -L../../../../../../src/port -L../../../../../../src/common   -L/nix/store/bgsjggllvcb8bs47mnpyz25rq0jvb7qz-libxml2-static-x86_64-unknown-linux-musl-2.9.14/lib -L/nix/store/6hj73llfmli3d3c67lmhwc7490hx24wj-zlib-static-x86_64-unknown-linux-musl-1.2.12/lib -L/nix/store/qqq58sk2qgicygjk7z91m99kns87xm3g-lz4-static-x86_64-unknown-linux-musl-1.9.4/lib    
/nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: /nix/store/ravnd17fg4maxzc5ns8vbijn7ah3p4b1-x86_64-unknown-linux-musl-stage-final-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-musl/11.3.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
/nix/store/q8zpwwa77zaa5h0p15iiid26g5ak6s7l-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this issue Sep 29, 2024
The underlying problem was fixed as a side-effect of [1], for reasons
unknown to me. In the current state, it's enough to disable a few
breaking dependencies to make the build pass.

Note, that this builds the full package, including backend. However, the
backend is not working, yet: Loading shared modules, which PostgreSQL
heavily depends is still broken. Further, all binaries in the default
output, even client binaries such as psql, are currently dynamically
linked against libpq.so. While the current autoconf based build system
doesn't support changing this, this might be possible in the future with
meson.

However, not all is bad: Fixing the build allows using the static
libpq.a library, which is probably the one thing that most users want
from pkgsStatic.postgresql anyway.

Resolves NixOS#191920

[1]: 7797728
@wolfgangwalther wolfgangwalther linked a pull request Sep 29, 2024 that will close this issue
13 tasks
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this issue Sep 29, 2024
The underlying problem was fixed as a side-effect of [1], for reasons
unknown to me. In the current state, it's enough to disable a few
breaking dependencies to make the build pass.

Note, that this builds the full package, including backend. However, the
backend is not working, yet: Loading shared modules, which PostgreSQL
heavily depends is still broken. Further, all binaries in the default
output, even client binaries such as psql, are currently dynamically
linked against libpq.so. While the current autoconf based build system
doesn't support changing this, this might be possible in the future with
meson.

However, not all is bad: Fixing the build allows using the static
libpq.a library, which is probably the one thing that most users want
from pkgsStatic.postgresql anyway.

Resolves NixOS#191920

[1]: 7797728
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this issue Sep 29, 2024
The underlying problem was fixed as a side-effect of [1], for reasons
unknown to me. In the current state, it's enough to disable a few
breaking dependencies to make the build pass.

Note, that this builds the full package, including backend. However, the
backend is not working, yet: Loading shared modules, which PostgreSQL
heavily depends is still broken. Further, all binaries in the default
output, even client binaries such as psql, are currently dynamically
linked against libpq.so. While the current autoconf based build system
doesn't support changing this, this might be possible in the future with
meson.

However, not all is bad: Fixing the build allows using the static
libpq.a library, which is probably the one thing that most users want
from pkgsStatic.postgresql anyway.

Resolves NixOS#191920

[1]: 7797728
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this issue Sep 29, 2024
The underlying problem was fixed as a side-effect of [1], for reasons
unknown to me. In the current state, it's enough to disable a few
breaking dependencies to make the build pass.

Note, that this builds the full package, including backend. However, the
backend is not working, yet: Loading shared modules, which PostgreSQL
heavily depends is still broken. Further, all binaries in the default
output, even client binaries such as psql, are currently dynamically
linked against libpq.so. While the current autoconf based build system
doesn't support changing this, this might be possible in the future with
meson.

However, not all is bad: Fixing the build allows using the static
libpq.a library, which is probably the one thing that most users want
from pkgsStatic.postgresql anyway.

Resolves NixOS#191920

[1]: 7797728
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this issue Sep 29, 2024
The underlying problem was fixed as a side-effect of [1], for reasons
unknown to me. In the current state, it's enough to disable a few
breaking dependencies to make the build pass.

Note, that this builds the full package, including backend. However, the
backend is not working, yet: Loading shared modules, which PostgreSQL
heavily depends is still broken. Further, all binaries in the default
output, even client binaries such as psql, are currently dynamically
linked against libpq.so. While the current autoconf based build system
doesn't support changing this, this might be possible in the future with
meson.

However, not all is bad: Fixing the build allows using the static
libpq.a library, which is probably the one thing that most users want
from pkgsStatic.postgresql anyway.

Resolves NixOS#191920

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

Successfully merging a pull request may close this issue.

2 participants