Skip to content

build failure when linking application statically #87

@zoranbosnjak

Description

@zoranbosnjak

I am trying to include formatting to the project and create statically linked binary. It works fine for many other libs (not all), but the build fails when formatting is included to the cabal file.

Here is a simple hello world application to reproduce the problem:

git clone -b with-formatting https://github.com/zoranbosnjak/staticbuild.git
cd staticbuild/
nix-build --arg static true -j auto

The error is:

...
/nix/store/1pm5xhabz1k0kqnsnfq2cz1r9hcnw8s1-ghc-9.8.4/lib/ghc-9.8.4/lib/../lib/x86_64-linux-ghc-9.8.4/rts-1.0.2/libHSrts-1.0.2_thr.a(LoadNativeObjPosix.thr_o):LoadNativeObjPosix.c:function loadNativeObj_POSIX:(.text+0x211): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
ghc-9.8.4: `cc' failed in phase `Linker'. (Exit code: 1)
error: Cannot build '/nix/store/34fzjpd3d0a3l7dman4nam4wa5gzvsky-proj-0.1.0.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/kzlis94idg5anmgml443jksgd8xl8j1v-proj-0.1.0
         /nix/store/n4ssgf7bj9mmf4dikd9h84bdb50zmy9y-proj-0.1.0-doc

Is there any simple way to workaround the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions