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 is broken #2327

Closed
robx opened this issue Jun 15, 2022 · 4 comments · Fixed by #2328
Closed

static build is broken #2327

robx opened this issue Jun 15, 2022 · 4 comments · Fixed by #2328

Comments

@robx
Copy link
Contributor

robx commented Jun 15, 2022

It seems the static-haskell-nix hack from #2292 produces non-static binaries:

Unfortunately, I no longer seem to be able to produce a static binary:

nix-build --attr postgrestStatic

ldd result/bin/postgrest
        linux-vdso.so.1 (0x00007ffe5bb03000)
        libz.so.1 => /nix/store/srww288f7sb0f8hb5399431k8ldg2pss-zlib-1.2.11/lib/libz.so.1 (0x00007fda1a070000)
        libpq.so.5 => /nix/store/8y5nh8zx42qbzw0ki5rc9ywgi7z3axqb-postgresql-14.2-lib/lib/libpq.so.5 (0x00007fda19d2c000)
        libgmp.so.10 => /nix/store/wxyn3pv3kvqrl2lnfzpaa82vsd6fizka-gmp-6.2.1/lib/libgmp.so.10 (0x00007fda19c8c000)
        libc.so => /nix/store/88nqrkcal1mmiqbx10ax6wkyncf1h1gk-musl-1.2.2/lib/libc.so (0x00007fda19bd9000)
        libffi.so.8 => /nix/store/wb3ji9r5b2f747phif5lfx7np45fl9px-libffi-3.4.2/lib/libffi.so.8 (0x00007fda19bcc000)

9.0.1 shows:

ldd postgrest
$       not a dynamic executable

We need a test on CI to ensure the above output.


On another NixOS server, trying to run produces an error(No such file or directory) and when running ldd on it:

ldd /nix/store/hpx1rapsd6ylshh8d115ab7ifpjd3bia-postgrest/bin/postgrest

/nix/store/hpx1rapsd6ylshh8d115ab7ifpjd3bia-postgrest/bin/postgrest: 
error while loading shared libraries: 
/nix/store/2pi6zgkwnr3zdslvlv16nixpzvbyjx1n-glibc-2.31/lib/libc.so: invalid ELF header

Originally posted by @steve-chavez in #2292 (comment)

@robx
Copy link
Contributor Author

robx commented Jun 15, 2022

Likeliest thing to look into is this patch: https://github.com/PostgREST/postgrest/blob/main/nix/patches/static-haskell-nix-isexecutable.patch. If we're lucky, that test is just wrong, and if we fix it we get a static build.

If not, it's a bit less clear how to proceed. https://github.com/nh2/static-haskell-nix is quite outdated and feels a bit abandoned, and it seems @monacoremo who introduced this here is not around anymore either?

@steve-chavez
Copy link
Member

steve-chavez commented Jun 15, 2022

If not, it's a bit less clear how to proceed. https://github.com/nh2/static-haskell-nix is quite outdated and feels a bit abandoned

Yeah, that is surprising, no issues opened in 2022 too. Seeing NixOS/nixpkgs#43795 (comment), perhaps static-haskell-nix is not needed anymore for static binaries?

@steve-chavez
Copy link
Member

steve-chavez commented Jun 15, 2022

From NixOS/nixpkgs#61575 (comment)

don't know about other use cases, but for TemplateHaskell we seems to be doing fine with just -fexternal-dynamic-refs. On the unstable channel pkgsStatic.haskellPackages can build pretty complex applications fully statically, so this may not be necessary anymore.

We'd have to look into pkgsStatic.haskellPackages

@robx
Copy link
Contributor Author

robx commented Jun 15, 2022

Ooh pkgsStatic.haskellPackages looks interesting! For now, I do think I managed to fix things in #2328.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants