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

ld-options is not taken into account when passed by command line or cabal.project.local #4925

Closed
erebe opened this issue Dec 3, 2017 · 12 comments · Fixed by #5451
Closed

Comments

@erebe
Copy link

erebe commented Dec 3, 2017

Hello,

While migrating some project from Stack to Cabal new-style I stumbled upon an issue regarding the ld-options field, which is not taken into account into command line and cabal.project.local but is, if added directly into xxx.cabal file of the project.

My goal is to compile the binary of the project with static linking instead of the standard dynamic one.
To do so, I am following those two steps:

  1. Do a specific configure
cabal new-configure --disable-executable-dynamic --ld-options='-static' --ghc-options='-fPIC -fllvm -split-sections'
  1. Do the build
cabal new-build

After the build finish, sadly the final executable is still dinamicaly linked

/mnt/greenclip # ldd /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip
        /lib/ld-musl-x86_64.so.1 (0x55c3fe225000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0x7f940ea6a000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0x7f940e844000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0x7f940e641000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x7f940e43b000)
        libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x7f940e231000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0x7f940e021000)
        libgmp.so.10 => /usr/lib/libgmp.so.10 (0x7f940ddbd000)
        libffi.so.6 => /usr/lib/libffi.so.6 (0x7f940dbb5000)
        libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x55c3fe225000)
        libXrender.so.1 => /usr/lib/libXrender.so.1 (0x7f940d9ab000)

The result is the same if we pass the configuration to new-build as so

cabal new-build --ld-options='-static'

here the output of cabal -v

/root/.cabal/bin/cabal act-as-setup --build-type=Simple -- configure
--verbose=2
--builddir=/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip
--ghc --prefix=/root/.cabal --bindir=/root/.cabal/bin
--libdir=/root/.cabal/lib/x86_64-linux-ghc-8.0.2/greenclip-2.0.0-inplace-greenclip
--libsubdir= --dynlibdir=/root/.cabal/lib/x86_64-linux-ghc-8.0.2
--libexecdir=/root/.cabal/libexec/x86_64-linux-ghc-8.0.2/greenclip-2.0.0
--libexecsubdir=
--datadir=/root/.cabal/share/x86_64-linux-ghc-8.0.2/greenclip-2.0.0
--datasubdir=
--docdir=/root/.cabal/share/doc/x86_64-linux-ghc-8.0.2/greenclip-2.0.0
--htmldir=/root/.cabal/share/doc/x86_64-linux-ghc-8.0.2/greenclip-2.0.0/html
--haddockdir=/root/.cabal/share/doc/x86_64-linux-ghc-8.0.2/greenclip-2.0.0/html
--sysconfdir=/root/.cabal/etc --enable-library-vanilla
--disable-library-profiling --enable-shared --disable-executable-dynamic
--disable-profiling --profiling-detail=default
--library-profiling-detail=default --enable-optimization --disable-debug-info
--disable-library-for-ghci --disable-split-objs --disable-executable-stripping
--disable-library-stripping --package-db=clear --package-db=global
--package-db=/root/.cabal/store/ghc-8.0.2/package.db
--package-db=/mnt/greenclip/dist-newstyle/packagedb/ghc-8.0.2
--cid=greenclip-2.0.0-inplace-greenclip --extra-prog-path=/root/.cabal/bin
--dependency=base=base-4.9.1.0
--dependency=protolude=protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e
--dependency=exceptions=exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb
--dependency=bytestring=bytestring-0.10.8.1
--dependency=text=text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30
--dependency=vector=vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148
--dependency=hashable=hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239
--dependency=binary=binary-0.8.3.0
--dependency=microlens=microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d
--dependency=microlens-mtl=microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453
--dependency=directory=directory-1.3.0.0 --dependency=unix=unix-2.7.2.1
--dependency=wordexp=wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d
--dependency=X11=X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197
--disable-coverage --exact-configuration --with-ghc=/usr/bin/ghc
--with-ghc-pkg=/usr/bin/ghc-pkg --ghc-option=-fPIC --ghc-option=-fllvm
--ghc-option=-split-sections --ld-option=-static exe:greenclip
...
/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp
/usr/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -odir /mnt/greenclip/
dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -hidir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/gre
enclip-tmp -stubdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -i -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.
0/c/greenclip/build/greenclip/greenclip-tmp -isrc -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/g
hc-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -I/mnt/greenclip/dist-newstyle/build/x86_64
-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -optP-include -optP/mnt/green
clip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen/cabal_macros.h -hide-all-packages -no-user-package-db -package-db /root/.cabal/store/ghc-8.0.2/package.db -packag
e-db /mnt/greenclip/dist-newstyle/packagedb/ghc-8.0.2 -package-db /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/package.conf.inplace -package-id base-4.9.1.0 -package-id pro
tolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e -package-id exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb -package-id bytestring-0.10.8.1 -package-id
 text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30 -package-id vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148 -package-id hashable-1.2.6.1-96c00ce9d2eb
5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239 -package-id binary-0.8.3.0 -package-id microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d -package-id microlens-mtl-0.1.11.0-bda
c7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453 -package-id directory-1.3.0.0 -package-id unix-2.7.2.1 -package-id wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d -pa
ckage-id X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197 -XHaskell2010 Clipboard src/Main.hs -Wall -O3 -fPIC -fllvm -split-sections
Linking...
/usr/bin/ghc --make -fbuilding-cabal-package -O -static -outputdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -odir /mnt/greenclip/dist-news
tyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -hidir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tm
p -stubdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -i -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/green
clip/build/greenclip/greenclip-tmp -isrc -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/
greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/gh
c-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -optP-include -optP/mnt/greenclip/dist
-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen/cabal_macros.h -lX11 -lxcb -lXau -lXdmcp -hide-all-packages -no-user-package-db -package-db /root/.cabal/store/ghc-8.0.2/p
ackage.db -package-db /mnt/greenclip/dist-newstyle/packagedb/ghc-8.0.2 -package-db /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/package.conf.inplace -package-id base-4.9.1.
0 -package-id protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e -package-id exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb -package-id bytestring-0.1
0.8.1 -package-id text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30 -package-id vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148 -package-id hashable-1.2
.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239 -package-id binary-0.8.3.0 -package-id microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d -package-id microlens
-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453 -package-id directory-1.3.0.0 -package-id unix-2.7.2.1 -package-id wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933
a865c073a768d -package-id X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197 -XHaskell2010 Clipboard src/Main.hs -o /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c
/greenclip/build/greenclip/greenclip -Wall -O3 -fPIC -fllvm -split-sections

and the output of ld in verbose mode (note the -dynamic-linker)

Linking /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip ...
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-6.2.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 6.2.1' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 6.2.1 20160822 (Alpine 6.2.1)
COMPILER_PATH=/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/libexec/gcc/x86_64-alpine-linux-musl/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fno-stack-protector' '-D' 'TABLES_NEXT_TO_CODE' '-v' '-o' '/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip' '-no-pie' '-L/root/.cabal/store/ghc-8.0.2/X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-0.7.1.1-1d6731841f6d4a20a28fdbb40d8ed8720152355a7a18f9e5ff740d7f8dc3cd3d/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-old-locale-0.0.1-cdbfd2d06c51c8bc4a9b5a371d3d27606ab0c4c81ec5540193e4c95568c2c91f/lib' '-L/root/.cabal/store/ghc-8.0.2/old-locale-1.0.0.7-70c2803c804464839444221fd353ab6f9e047590ea834322a5f041e9dba1bc49/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-dlist-0.0.1-3b1b94e89dea89d74187347544b050af62c1f3137a5b451b0946fe5350bb88a4/lib' '-L/root/.cabal/store/ghc-8.0.2/dlist-0.8.0.3-493d8062a8ea2e0d95e1183b076874b1fc5b797ce13be040b36e099ed6f1b6c8/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-containers-0.0.1-f77fa4937ea7b1523d543ecd32f55772d2e044bcec586d8bf092fbd1dbe0e579/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-class-0.1.2.0-f1dddfa0fcfc68706933e810083fe7415c43e226c8ac0eb2211a30a87248751d/lib' '-L/root/.cabal/store/ghc-8.0.2/wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d/lib' '-L/root/.cabal/store/ghc-8.0.2/semigroups-0.18.3-c52b824fc1c06b35ce32f544444fec565c778ccf420451dc1282113e034b8281/lib' '-L/usr/lib/ghc-8.0.2/directory-1.3.0.0' '-L/usr/lib/ghc-8.0.2/unix-2.7.2.1' '-L/usr/lib/ghc-8.0.2/time-1.6.0.1' '-L/usr/lib/ghc-8.0.2/filepath-1.4.1.1' '-L/root/.cabal/store/ghc-8.0.2/microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453/lib' '-L/root/.cabal/store/ghc-8.0.2/microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d/lib' '-L/root/.cabal/store/ghc-8.0.2/vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148/lib' '-L/root/.cabal/store/ghc-8.0.2/primitive-0.6.2.0-44275745c4df1b2f5395fe1440d73a10ae9d5f3578ec835e40642a8288763d18/lib' '-L/root/.cabal/store/ghc-8.0.2/exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb/lib' '-L/root/.cabal/store/ghc-8.0.2/transformers-compat-0.5.1.4-7be4c4d6cde89ab173539e66812807feecdbd2bdd2efc145f3dd2e005d8838e3/lib' '-L/usr/lib/ghc-8.0.2/template-haskell-2.11.1.0' '-L/usr/lib/ghc-8.0.2/pretty-1.1.3.3' '-L/usr/lib/ghc-8.0.2/ghc-boot-th-8.0.2' '-L/root/.cabal/store/ghc-8.0.2/protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e/lib' '-L/root/.cabal/store/ghc-8.0.2/safe-0.3.15-1af51dd522929d45c1a66eef6a529e23e2ae9bb24ae6473959e9d99a0e718546/lib' '-L/root/.cabal/store/ghc-8.0.2/mtl-2.2.1-e2c9cbe58118c91f775f4633409c5854e4e34cf118cdb44c6c47d55e029751db/lib' '-L/usr/lib/ghc-8.0.2/transformers-0.5.2.0' '-L/root/.cabal/store/ghc-8.0.2/hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239/lib' '-L/root/.cabal/store/ghc-8.0.2/text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30/lib' '-L/usr/lib/ghc-8.0.2/binary-0.8.3.0' '-L/usr/lib/ghc-8.0.2/bytestring-0.10.8.1' '-L/usr/lib/ghc-8.0.2/containers-0.5.7.1' '-L/usr/lib/ghc-8.0.2/deepseq-1.4.2.0' '-L/root/.cabal/store/ghc-8.0.2/async-2.1.1.1-cee2bad558628b433d25a6de758678702e9cbc0056c5553c3b863155e2f9b5c7/lib' '-L/root/.cabal/store/ghc-8.0.2/stm-2.4.4.1-4c5351fe1cfc4fe9a86154164bf9b602574d00b424e0eeef53f628baadaf6a8f/lib' '-L/usr/lib/ghc-8.0.2/array-0.5.1.1' '-L/usr/lib/ghc-8.0.2/base-4.9.1.0' '-L/usr/lib/ghc-8.0.2/integer-gmp-1.0.0.1' '-L/usr/lib/ghc-8.0.2/ghc-prim-0.5.0.0' '-L/usr/lib/ghc-8.0.2/rts' '-L/usr/lib/../lib' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/collect2 -plugin /usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccnBMedL.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr --hash-style=gnu -m elf_x86_64 --as-needed -dynamic-linker /lib/ld-musl-x86_64.so.1 -z relro -z now -o /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/crt1.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/crtbegin.o -L/root/.cabal/store/ghc-8.0.2/X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197/lib -L/root/.cabal/store/ghc-8.0.2/data-default-0.7.1.1-1d6731841f6d4a20a28fdbb40d8ed8720152355a7a18f9e5ff740d7f8dc3cd3d/lib -L/root/.cabal/store/ghc-8.0.2/data-default-instances-old-locale-0.0.1-cdbfd2d06c51c8bc4a9b5a371d3d27606ab0c4c81ec5540193e4c95568c2c91f/lib -L/root/.cabal/store/ghc-8.0.2/old-locale-1.0.0.7-70c2803c804464839444221fd353ab6f9e047590ea834322a5f041e9dba1bc49/lib -L/root/.cabal/store/ghc-8.0.2/data-default-instances-dlist-0.0.1-3b1b94e89dea89d74187347544b050af62c1f3137a5b451b0946fe5350bb88a4/lib -L/root/.cabal/store/ghc-8.0.2/dlist-0.8.0.3-493d8062a8ea2e0d95e1183b076874b1fc5b797ce13be040b36e099ed6f1b6c8/lib -L/root/.cabal/store/ghc-8.0.2/data-default-instances-containers-0.0.1-f77fa4937ea7b1523d543ecd32f55772d2e044bcec586d8bf092fbd1dbe0e579/lib -L/root/.cabal/store/ghc-8.0.2/data-default-class-0.1.2.0-f1dddfa0fcfc68706933e810083fe7415c43e226c8ac0eb2211a30a87248751d/lib -L/root/.cabal/store/ghc-8.0.2/wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d/lib -L/root/.cabal/store/ghc-8.0.2/semigroups-0.18.3-c52b824fc1c06b35ce32f544444fec565c778ccf420451dc1282113e034b8281/lib -L/usr/lib/ghc-8.0.2/directory-1.3.0.0 -L/usr/lib/ghc-8.0.2/unix-2.7.2.1 -L/usr/lib/ghc-8.0.2/time-1.6.0.1 -L/usr/lib/ghc-8.0.2/filepath-1.4.1.1 -L/root/.cabal/store/ghc-8.0.2/microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453/lib -L/root/.cabal/store/ghc-8.0.2/microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d/lib -L/root/.cabal/store/ghc-8.0.2/vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148/lib -L/root/.cabal/store/ghc-8.0.2/primitive-0.6.2.0-44275745c4df1b2f5395fe1440d73a10ae9d5f3578ec835e40642a8288763d18/lib -L/root/.cabal/store/ghc-8.0.2/exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb/lib -L/root/.cabal/store/ghc-8.0.2/transformers-compat-0.5.1.4-7be4c4d6cde89ab173539e66812807feecdbd2bdd2efc145f3dd2e005d8838e3/lib -L/usr/lib/ghc-8.0.2/template-haskell-2.11.1.0 -L/usr/lib/ghc-8.0.2/pretty-1.1.3.3 -L/usr/lib/ghc-8.0.2/ghc-boot-th-8.0.2 -L/root/.cabal/store/ghc-8.0.2/protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e/lib -L/root/.cabal/store/ghc-8.0.2/safe-0.3.15-1af51dd522929d45c1a66eef6a529e23e2ae9bb24ae6473959e9d99a0e718546/lib -L/root/.cabal/store/ghc-8.0.2/mtl-2.2.1-e2c9cbe58118c91f775f4633409c5854e4e34cf118cdb44c6c47d55e029751db/lib -L/usr/lib/ghc-8.0.2/transformers-0.5.2.0 -L/root/.cabal/store/ghc-8.0.2/hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239/lib -L/root/.cabal/store/ghc-8.0.2/text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30/lib -L/usr/lib/ghc-8.0.2/binary-0.8.3.0 -L/usr/lib/ghc-8.0.2/bytestring-0.10.8.1 -L/usr/lib/ghc-8.0.2/containers-0.5.7.1 -L/usr/lib/ghc-8.0.2/deepseq-1.4.2.0 -L/root/.cabal/store/ghc-8.0.2/async-2.1.1.1-cee2bad558628b433d25a6de758678702e9cbc0056c5553c3b863155e2f9b5c7/lib -L/root/.cabal/store/ghc-8.0.2/stm-2.4.4.1-4c5351fe1cfc4fe9a86154164bf9b602574d00b424e0eeef53f628baadaf6a8f/lib -L/usr/lib/ghc-8.0.2/array-0.5.1.1 -L/usr/lib/ghc-8.0.2/base-4.9.1.0 -L/usr/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -L/usr/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -L/usr/lib/ghc-8.0.2/rts -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1 -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../.. @/tmp/ccClpCpI -lssp_nonshared -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/crtend.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/crtn.o
COLLECT_GCC_OPTIONS='-fno-stack-protector' '-D' 'TABLES_NEXT_TO_CODE' '-v' '-o' '/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip' '-no-pie' '-L/root/.cabal/store/ghc-8.0.2/X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-0.7.1.1-1d6731841f6d4a20a28fdbb40d8ed8720152355a7a18f9e5ff740d7f8dc3cd3d/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-old-locale-0.0.1-cdbfd2d06c51c8bc4a9b5a371d3d27606ab0c4c81ec5540193e4c95568c2c91f/lib' '-L/root/.cabal/store/ghc-8.0.2/old-locale-1.0.0.7-70c2803c804464839444221fd353ab6f9e047590ea834322a5f041e9dba1bc49/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-dlist-0.0.1-3b1b94e89dea89d74187347544b050af62c1f3137a5b451b0946fe5350bb88a4/lib' '-L/root/.cabal/store/ghc-8.0.2/dlist-0.8.0.3-493d8062a8ea2e0d95e1183b076874b1fc5b797ce13be040b36e099ed6f1b6c8/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-containers-0.0.1-f77fa4937ea7b1523d543ecd32f55772d2e044bcec586d8bf092fbd1dbe0e579/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-class-0.1.2.0-f1dddfa0fcfc68706933e810083fe7415c43e226c8ac0eb2211a30a87248751d/lib' '-L/root/.cabal/store/ghc-8.0.2/wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d/lib' '-L/root/.cabal/store/ghc-8.0.2/semigroups-0.18.3-c52b824fc1c06b35ce32f544444fec565c778ccf420451dc1282113e034b8281/lib' '-L/usr/lib/ghc-8.0.2/directory-1.3.0.0' '-L/usr/lib/ghc-8.0.2/unix-2.7.2.1' '-L/usr/lib/ghc-8.0.2/time-1.6.0.1' '-L/usr/lib/ghc-8.0.2/filepath-1.4.1.1' '-L/root/.cabal/store/ghc-8.0.2/microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453/lib' '-L/root/.cabal/store/ghc-8.0.2/microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d/lib' '-L/root/.cabal/store/ghc-8.0.2/vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148/lib' '-L/root/.cabal/store/ghc-8.0.2/primitive-0.6.2.0-44275745c4df1b2f5395fe1440d73a10ae9d5f3578ec835e40642a8288763d18/lib' '-L/root/.cabal/store/ghc-8.0.2/exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb/lib' '-L/root/.cabal/store/ghc-8.0.2/transformers-compat-0.5.1.4-7be4c4d6cde89ab173539e66812807feecdbd2bdd2efc145f3dd2e005d8838e3/lib' '-L/usr/lib/ghc-8.0.2/template-haskell-2.11.1.0' '-L/usr/lib/ghc-8.0.2/pretty-1.1.3.3' '-L/usr/lib/ghc-8.0.2/ghc-boot-th-8.0.2' '-L/root/.cabal/store/ghc-8.0.2/protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e/lib' '-L/root/.cabal/store/ghc-8.0.2/safe-0.3.15-1af51dd522929d45c1a66eef6a529e23e2ae9bb24ae6473959e9d99a0e718546/lib' '-L/root/.cabal/store/ghc-8.0.2/mtl-2.2.1-e2c9cbe58118c91f775f4633409c5854e4e34cf118cdb44c6c47d55e029751db/lib' '-L/usr/lib/ghc-8.0.2/transformers-0.5.2.0' '-L/root/.cabal/store/ghc-8.0.2/hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239/lib' '-L/root/.cabal/store/ghc-8.0.2/text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30/lib' '-L/usr/lib/ghc-8.0.2/binary-0.8.3.0' '-L/usr/lib/ghc-8.0.2/bytestring-0.10.8.1' '-L/usr/lib/ghc-8.0.2/containers-0.5.7.1' '-L/usr/lib/ghc-8.0.2/deepseq-1.4.2.0' '-L/root/.cabal/store/ghc-8.0.2/async-2.1.1.1-cee2bad558628b433d25a6de758678702e9cbc0056c5553c3b863155e2f9b5c7/lib' '-L/root/.cabal/store/ghc-8.0.2/stm-2.4.4.1-4c5351fe1cfc4fe9a86154164bf9b602574d00b424e0eeef53f628baadaf6a8f/lib' '-L/usr/lib/ghc-8.0.2/array-0.5.1.1' '-L/usr/lib/ghc-8.0.2/base-4.9.1.0' '-L/usr/lib/ghc-8.0.2/integer-gmp-1.0.0.1' '-L/usr/lib/ghc-8.0.2/ghc-prim-0.5.0.0' '-L/usr/lib/ghc-8.0.2/rts' '-L/usr/lib/../lib' '-mtune=generic' '-march=x86-64'

now if we override the .cabal file of the project and add the ld-options directly in it, ld is correctly told to link in static mode (note the -static instead -dynamic-linker)

Linking /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip ...
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-6.2.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 6.2.1' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 6.2.1 20160822 (Alpine 6.2.1)
COMPILER_PATH=/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/libexec/gcc/x86_64-alpine-linux-musl/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fno-stack-protector' '-D' 'TABLES_NEXT_TO_CODE' '-v' '-static' '-o' '/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip' '-no-pie' '-L/root/.cabal/store/ghc-8.0.2/X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-0.7.1.1-1d6731841f6d4a20a28fdbb40d8ed8720152355a7a18f9e5ff740d7f8dc3cd3d/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-old-locale-0.0.1-cdbfd2d06c51c8bc4a9b5a371d3d27606ab0c4c81ec5540193e4c95568c2c91f/lib' '-L/root/.cabal/store/ghc-8.0.2/old-locale-1.0.0.7-70c2803c804464839444221fd353ab6f9e047590ea834322a5f041e9dba1bc49/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-dlist-0.0.1-3b1b94e89dea89d74187347544b050af62c1f3137a5b451b0946fe5350bb88a4/lib' '-L/root/.cabal/store/ghc-8.0.2/dlist-0.8.0.3-493d8062a8ea2e0d95e1183b076874b1fc5b797ce13be040b36e099ed6f1b6c8/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-instances-containers-0.0.1-f77fa4937ea7b1523d543ecd32f55772d2e044bcec586d8bf092fbd1dbe0e579/lib' '-L/root/.cabal/store/ghc-8.0.2/data-default-class-0.1.2.0-f1dddfa0fcfc68706933e810083fe7415c43e226c8ac0eb2211a30a87248751d/lib' '-L/root/.cabal/store/ghc-8.0.2/wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d/lib' '-L/root/.cabal/store/ghc-8.0.2/semigroups-0.18.3-c52b824fc1c06b35ce32f544444fec565c778ccf420451dc1282113e034b8281/lib' '-L/usr/lib/ghc-8.0.2/directory-1.3.0.0' '-L/usr/lib/ghc-8.0.2/unix-2.7.2.1' '-L/usr/lib/ghc-8.0.2/time-1.6.0.1' '-L/usr/lib/ghc-8.0.2/filepath-1.4.1.1' '-L/root/.cabal/store/ghc-8.0.2/microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453/lib' '-L/root/.cabal/store/ghc-8.0.2/microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d/lib' '-L/root/.cabal/store/ghc-8.0.2/vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148/lib' '-L/root/.cabal/store/ghc-8.0.2/primitive-0.6.2.0-44275745c4df1b2f5395fe1440d73a10ae9d5f3578ec835e40642a8288763d18/lib' '-L/root/.cabal/store/ghc-8.0.2/exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb/lib' '-L/root/.cabal/store/ghc-8.0.2/transformers-compat-0.5.1.4-7be4c4d6cde89ab173539e66812807feecdbd2bdd2efc145f3dd2e005d8838e3/lib' '-L/usr/lib/ghc-8.0.2/template-haskell-2.11.1.0' '-L/usr/lib/ghc-8.0.2/pretty-1.1.3.3' '-L/usr/lib/ghc-8.0.2/ghc-boot-th-8.0.2' '-L/root/.cabal/store/ghc-8.0.2/protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e/lib' '-L/root/.cabal/store/ghc-8.0.2/safe-0.3.15-1af51dd522929d45c1a66eef6a529e23e2ae9bb24ae6473959e9d99a0e718546/lib' '-L/root/.cabal/store/ghc-8.0.2/mtl-2.2.1-e2c9cbe58118c91f775f4633409c5854e4e34cf118cdb44c6c47d55e029751db/lib' '-L/usr/lib/ghc-8.0.2/transformers-0.5.2.0' '-L/root/.cabal/store/ghc-8.0.2/hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239/lib' '-L/root/.cabal/store/ghc-8.0.2/text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30/lib' '-L/usr/lib/ghc-8.0.2/binary-0.8.3.0' '-L/usr/lib/ghc-8.0.2/bytestring-0.10.8.1' '-L/usr/lib/ghc-8.0.2/containers-0.5.7.1' '-L/usr/lib/ghc-8.0.2/deepseq-1.4.2.0' '-L/root/.cabal/store/ghc-8.0.2/async-2.1.1.1-cee2bad558628b433d25a6de758678702e9cbc0056c5553c3b863155e2f9b5c7/lib' '-L/root/.cabal/store/ghc-8.0.2/stm-2.4.4.1-4c5351fe1cfc4fe9a86154164bf9b602574d00b424e0eeef53f628baadaf6a8f/lib' '-L/usr/lib/ghc-8.0.2/array-0.5.1.1' '-L/usr/lib/ghc-8.0.2/base-4.9.1.0' '-L/usr/lib/ghc-8.0.2/integer-gmp-1.0.0.1' '-L/usr/lib/ghc-8.0.2/ghc-prim-0.5.0.0' '-L/usr/lib/ghc-8.0.2/rts' '-L/usr/lib/../lib' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/collect2 -plugin /usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccBFhKDk.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc --hash-style=gnu -m elf_x86_64 --as-needed -static -z relro -z now -o /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/crt1.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/crtbeginT.o -L/root/.cabal/store/ghc-8.0.2/X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197/lib -L/root/.cabal/store/ghc-8.0.2/data-default-0.7.1.1-1d6731841f6d4a20a28fdbb40d8ed8720152355a7a18f9e5ff740d7f8dc3cd3d/lib -L/root/.cabal/store/ghc-8.0.2/data-default-instances-old-locale-0.0.1-cdbfd2d06c51c8bc4a9b5a371d3d27606ab0c4c81ec5540193e4c95568c2c91f/lib -L/root/.cabal/store/ghc-8.0.2/old-locale-1.0.0.7-70c2803c804464839444221fd353ab6f9e047590ea834322a5f041e9dba1bc49/lib -L/root/.cabal/store/ghc-8.0.2/data-default-instances-dlist-0.0.1-3b1b94e89dea89d74187347544b050af62c1f3137a5b451b0946fe5350bb88a4/lib -L/root/.cabal/store/ghc-8.0.2/dlist-0.8.0.3-493d8062a8ea2e0d95e1183b076874b1fc5b797ce13be040b36e099ed6f1b6c8/lib -L/root/.cabal/store/ghc-8.0.2/data-default-instances-containers-0.0.1-f77fa4937ea7b1523d543ecd32f55772d2e044bcec586d8bf092fbd1dbe0e579/lib -L/root/.cabal/store/ghc-8.0.2/data-default-class-0.1.2.0-f1dddfa0fcfc68706933e810083fe7415c43e226c8ac0eb2211a30a87248751d/lib -L/root/.cabal/store/ghc-8.0.2/wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d/lib -L/root/.cabal/store/ghc-8.0.2/semigroups-0.18.3-c52b824fc1c06b35ce32f544444fec565c778ccf420451dc1282113e034b8281/lib -L/usr/lib/ghc-8.0.2/directory-1.3.0.0 -L/usr/lib/ghc-8.0.2/unix-2.7.2.1 -L/usr/lib/ghc-8.0.2/time-1.6.0.1 -L/usr/lib/ghc-8.0.2/filepath-1.4.1.1 -L/root/.cabal/store/ghc-8.0.2/microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453/lib -L/root/.cabal/store/ghc-8.0.2/microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d/lib -L/root/.cabal/store/ghc-8.0.2/vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148/lib -L/root/.cabal/store/ghc-8.0.2/primitive-0.6.2.0-44275745c4df1b2f5395fe1440d73a10ae9d5f3578ec835e40642a8288763d18/lib -L/root/.cabal/store/ghc-8.0.2/exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb/lib -L/root/.cabal/store/ghc-8.0.2/transformers-compat-0.5.1.4-7be4c4d6cde89ab173539e66812807feecdbd2bdd2efc145f3dd2e005d8838e3/lib -L/usr/lib/ghc-8.0.2/template-haskell-2.11.1.0 -L/usr/lib/ghc-8.0.2/pretty-1.1.3.3 -L/usr/lib/ghc-8.0.2/ghc-boot-th-8.0.2 -L/root/.cabal/store/ghc-8.0.2/protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e/lib -L/root/.cabal/store/ghc-8.0.2/safe-0.3.15-1af51dd522929d45c1a66eef6a529e23e2ae9bb24ae6473959e9d99a0e718546/lib -L/root/.cabal/store/ghc-8.0.2/mtl-2.2.1-e2c9cbe58118c91f775f4633409c5854e4e34cf118cdb44c6c47d55e029751db/lib -L/usr/lib/ghc-8.0.2/transformers-0.5.2.0 -L/root/.cabal/store/ghc-8.0.2/hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239/lib -L/root/.cabal/store/ghc-8.0.2/text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30/lib -L/usr/lib/ghc-8.0.2/binary-0.8.3.0 -L/usr/lib/ghc-8.0.2/bytestring-0.10.8.1 -L/usr/lib/ghc-8.0.2/containers-0.5.7.1 -L/usr/lib/ghc-8.0.2/deepseq-1.4.2.0 -L/root/.cabal/store/ghc-8.0.2/async-2.1.1.1-cee2bad558628b433d25a6de758678702e9cbc0056c5553c3b863155e2f9b5c7/lib -L/root/.cabal/store/ghc-8.0.2/stm-2.4.4.1-4c5351fe1cfc4fe9a86154164bf9b602574d00b424e0eeef53f628baadaf6a8f/lib -L/usr/lib/ghc-8.0.2/array-0.5.1.1 -L/usr/lib/ghc-8.0.2/base-4.9.1.0 -L/usr/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -L/usr/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -L/usr/lib/ghc-8.0.2/rts -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1 -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../x86_64-alpine-linux-musl/lib -L/usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../.. @/tmp/cckONdKB -lssp_nonshared --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/crtend.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.2.1/../../../../lib/crtn.o

the cabal new-build -v output

/usr/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -odir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -hidir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -stubdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -i -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -isrc -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -optP-include -optP/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen/cabal_macros.h -hide-all-packages -no-user-package-db -package-db /root/.cabal/store/ghc-8.0.2/package.db -package-db /mnt/greenclip/dist-newstyle/packagedb/ghc-8.0.2 -package-db /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/package.conf.inplace -package-id base-4.9.1.0 -package-id protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e -package-id exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb -package-id bytestring-0.10.8.1 -package-id text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30 -package-id vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148 -package-id hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239 -package-id binary-0.8.3.0 -package-id microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d -package-id microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453 -package-id directory-1.3.0.0 -package-id unix-2.7.2.1 -package-id wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d -package-id X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197 -XHaskell2010 Clipboard src/Main.hs -Wall -O3 -fPIC -fllvm -split-sections
Linking...
/usr/bin/ghc --make -fbuilding-cabal-package -O -static -outputdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -odir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -hidir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -stubdir /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -i -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -isrc -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -i/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/global-autogen -I/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip-tmp -optP-include -optP/mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/autogen/cabal_macros.h -optl-static -lX11 -lxcb -lXau -lXdmcp -hide-all-packages -no-user-package-db -package-db /root/.cabal/store/ghc-8.0.2/package.db -package-db /mnt/greenclip/dist-newstyle/packagedb/ghc-8.0.2 -package-db /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/package.conf.inplace -package-id base-4.9.1.0 -package-id protolude-0.2-c53bf72e4f41aa227abef214396e7b501c06d3dae194a0f95a0803881df2840e -package-id exceptions-0.8.3-99df7fb1091e82595f8751da3e3af1cd171c7de1921f797c8cff3ba91ffbe7fb -package-id bytestring-0.10.8.1 -package-id text-1.2.2.2-8dc9a27ecc7d86c9dacc1255b386b9059d5ae508d3cebdda054efbca38ed4a30 -package-id vector-0.12.0.1-80b03ad733196f0c3ccac3c3ff0300000efd98a9c471f70d7b74b45be9251148 -package-id hashable-1.2.6.1-96c00ce9d2eb5dd6361b4db269be00e167ed4fe746cb0a1d64ccd0f4a0426239 -package-id binary-0.8.3.0 -package-id microlens-0.4.8.1-f929d694e6c04256470f468b607ed297de07735e53576b7536c21d7be72a2d6d -package-id microlens-mtl-0.1.11.0-bdac7266c988b74d81cf60e03d24df2c8fb6d2c5351451f69c8d06e31e94d453 -package-id directory-1.3.0.0 -package-id unix-2.7.2.1 -package-id wordexp-0.2.0.0-411de64aea6f9aff20aeca21e9e72d8f8a044b5f571214e5933a865c073a768d -package-id X11-1.8-2e8690b52cae71974ff8f6b53277c7da9f070360d3543201d95a1a2f5bbd5197 -XHaskell2010 Clipboard src/Main.hs -o /mnt/greenclip/dist-newstyle/build/x86_64-linux/ghc-8.0.2/greenclip-2.0.0/c/greenclip/build/greenclip/greenclip -Wall -O3 -fPIC -fllvm -split-sections

What is expected ?

When passing ld-option by command line or in cabal.project.local it should be taken into account.

Version of ghc and cabal

/mnt # cabal --version
cabal-install version 2.0.0.1
compiled using version 2.0.1.0 of the Cabal library
/mnt # ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
@erebe
Copy link
Author

erebe commented Dec 5, 2017

Do you have any insight, of how this could happen ?

@23Skidoo
Copy link
Member

23Skidoo commented Dec 5, 2017 via email

@hvr
Copy link
Member

hvr commented Dec 5, 2017

@erebe I've got a feeling this looks a lot like another known issue #2997; what happens if you don't use it top-level but rather use a package stanza like e.g.

package greenclip
  ld-options: -static

?

@erebe
Copy link
Author

erebe commented Dec 6, 2017

@hvr I tried to add a section with

package greenclip
  ld-options: -static

but the binary still end-up being dynamically linked.

I will try to grab the HEAD of cabal, to poke around

@erebe
Copy link
Author

erebe commented Dec 6, 2017

From what I understood so far,
The PackageConfig is good with the correct Options, but the ReadyPackage passed into rebuildTarget is missing the option for ld.
I have to find where this ReadyPackage is build.

P.S: By any hasard do you how to start a cabal new-repl inside the cabal project and start the main function in an other Path (the other project I am trying to build) ?

@erebe
Copy link
Author

erebe commented Dec 6, 2017

The problem seems to be in rebuildProjectConfig

rebuildProjectConfig :: Verbosity

the action phaseReadProjectConfig correctly parse the .local file into a ProjectConfig and all the options are correctly there, but sadly the later phase phaseReadLocalPackages read the .cabal file into a SpecificSourcePackage and it is this one that is used by the resolver.

If I understand correctly, I think there is a missing step where we should update the SpecificSourcePackage with the resulting ProjectConfig. Can you confirm this hypothesis ?

Unrelated to my issue, I think there is also an other bug in the function as in the last line return (projectConfig <> cliConfig, localPackages) we try to update the ProjectConfig with the CliConfig, but as CliConfig is filled with default values and is last in mappend, the values specified in the .local file get overridden by the default value from cliConfig. Is it an already known issue ?

@23Skidoo
Copy link
Member

23Skidoo commented Dec 8, 2017

@erebe Excellent sleuthing, would it be possible for you to create a pull request?

@erebe
Copy link
Author

erebe commented Dec 8, 2017

I was not sure about the direction to take as the problem seemed deeper than my original issue. So I browsed a bit and stumbled upon #4737, regarding my last interrogation. It seems the problem is already known and worked on.
if @hvr can provide some feedback on this issue.
It may be good to take a step back as it seems to have a lot of issues related to this part #4939

@hvr
Copy link
Member

hvr commented Dec 8, 2017

@erebe well, you could try applying #4886 to see if it helps empirically (it works mostly, I've used it locally for some time and only ran into problems with e.g. new-haddock)

@erebe
Copy link
Author

erebe commented Dec 9, 2017

I will try the PR next week, as for now I only have my laptop and building cabal on it is kind of long...

@nh2
Copy link
Member

nh2 commented Jul 19, 2018

Possibly related, some other places where cabal ignores linker related options:

#4439

nh2 added a commit to nh2/cabal that referenced this issue Jul 20, 2018
@nh2
Copy link
Member

nh2 commented Jul 20, 2018

Tentative patch for this: #5451

I would appreciate testers.

nh2 added a commit to nh2/cabal that referenced this issue Jul 21, 2018
nh2 added a commit to nh2/cabal that referenced this issue Oct 16, 2018
nh2 added a commit to nh2/cabal that referenced this issue Aug 4, 2019
nh2 added a commit to nh2/cabal that referenced this issue Aug 4, 2019
newhoggy pushed a commit to arbor/cabal that referenced this issue Aug 9, 2019
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.

4 participants