Bug 227382 - Can't use devel/stack to build statically
Summary: Can't use devel/stack to build statically
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-09 01:54 UTC by darius
Modified: 2019-02-14 15:19 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description darius 2018-04-09 01:54:56 UTC
I'm trying to build https://github.com/erebe/wstunnel statically like so..
stack install --ghc-options='-optl-static' --system-ghc

However it complains it can't find various libraries, eg..
[vm11 1:35] ~/wstunnel >stack install --ghc-options='-optl-static' --system-ghc
wstunnel-0.1.0.0: build (lib + exe)
Preprocessing library wstunnel-0.1.0.0...
/usr/bin/ld: cannot find -lHSwebsockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP-ghc8.0.2
cc: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)

--  While building package wstunnel-0.1.0.0 using:
     /usr/home/darius/.stack/setup-exe-cache/x86_64-freebsd/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0 build lib:wstunnel exe:wstunnel --ghc-options " -ddump-hi -ddump-to-file"
   Process exited with code: ExitFailure 1

The library is at /home/darius/.stack/snapshots/x86_64-freebsd/lts-9.9/8.0.2/lib/x86_64-freebsd-ghc-8.0.2/websockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP/libHSwebsockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP-ghc8.0.2.a

but that isn't in the search path. I note that /home/darius/.stack/snapshots/x86_64-freebsd/lts-9.9/8.0.2/lib/x86_64-freebsd-ghc-8.0.2/libHSwebsockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP-ghc8.0.2.so is present though so I tried symlinking /home/darius/.stack/snapshots/x86_64-freebsd/lts-9.9/8.0.2/lib/x86_64-freebsd-ghc-8.0.2/websockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP/libHSwebsockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP.a into that directory as libHSwebsockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP-ghc8.0.2.a (and a bunch of others plus ones under /usr/local/lib/ghc-8.0.2).

That got me further but then I ended up seeing a heap of undefined reference errors, eg..
2018-04-09 01:40:02.967973: [info] wstunnel-0.1.0.0: build (lib + exe)
@(Stack/Build/Execute.hs:830:23)
2018-04-09 01:40:02.968352: [debug] Run process: /usr/home/darius/.stack/setup-exe-cache/x86_64-freebsd/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0 build lib:wstunnel exe:wstunnel --ghc-options " -ddump-hi -ddump-to-file"
@(System/Process/Read.hs:306:3)
2018-04-09 01:40:03.086921: [info] Preprocessing library wstunnel-0.1.0.0...
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.253730: [warn] /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400180
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.276500: [warn] .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.dyn_o: In function `r1boV_info':
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.276617: [warn] (.text+0x61): undefined reference to `newCAF'
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.276709: [warn] .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.dyn_o: In function `r1boV_info':
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.276848: [warn] (.text+0x71): undefined reference to `stg_bh_upd_frame_info'
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.276969: [warn] .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.dyn_o: In function `c1fNY_info':
@(Stack/Build/Execute.hs:1096:67)
2018-04-09 01:40:05.277063: [warn] (.text+0x11c): undefined reference to `stg_ap_0_fast'
@(Stack/Build/Execute.hs:1096:67)

etc etc..
Running with -v shows..
/usr/bin/ar -r .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/objs-40035/libHSwstunnel-0.1.0.0-AW3X1jAtS7XCeg7CJRwMWe.a .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Protocols.o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Types.o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Logger.o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Socks5.o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Credentials.o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/HttpProxy.o
ar: warning: creating .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/objs-40035/libHSwstunnel-0.1.0.0-AW3X1jAtS7XCeg7CJRwMWe.a
/usr/local/bin/ghc -shared -dynamic '-dynload deploy' -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/array-0.5.1.1 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/base-4.9.1.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/binary-0.8.3.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/bytestring-0.10.8.1 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/containers-0.5.7.1 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/deepseq-1.4.2.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/directory-1.3.0.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/filepath-1.4.1.1 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/ghc-boot-th-8.0.2 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -optl-Wl,-rpath,/usr/local/lib -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/pretty-1.1.3.3 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/process-1.4.3.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/rts -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/template-haskell-2.11.1.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/time-1.6.0.1 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/transformers-0.5.2.0 -optl-Wl,-rpath,/usr/local/lib/ghc-8.0.2/unix-2.7.2.1 -optl-Wl,-rpath,/usr/home/darius/.stack/snapshots/x86_64-freebsd/lts-9.9/8.0.2/lib/x86_64-freebsd-ghc-8.0.2 -hide-all-packages -no-auto-link-packages -no-user-package-db -package-db /usr/home/darius/.stack/snapshots/x86_64-freebsd/lts-9.9/8.0.2/pkgdb -package-db /usr/home/darius/wstunnel/.stack-work/install/x86_64-freebsd/lts-9.9/8.0.2/pkgdb -package-db .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/package.conf.inplace -package-id async-2.1.1.1-8yywY4inVGRLJSCg60gBXj -package-id base-4.9.1.0 -package-id base64-bytestring-1.0.0.1-4O9TExPPz6eI82Yj7L4SIj -package-id binary-0.8.3.0 -package-id bytestring-0.10.8.1 -package-id classy-prelude-1.2.0.1-DI7QyZr6dYQLSGY5Zda29N -package-id connection-0.2.8-BxEaNY3oDHHAFXlQHNmyac -package-id hslogger-1.2.10-Li6ZV5C1ftGLPA71zPNMlf -package-id mtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6 -package-id network-2.6.3.2-IsLM4TXcLoRI0fmmBYVyQz -package-id network-conduit-tls-1.2.2-Fk5CYGzzcFcSIVqij7Uvk -package-id streaming-commons-0.1.17-6xuIA5RXrs65yyeq3HWIWP -package-id text-1.2.2.2-9UQZjEJZQFSGMffj1Z5g00 -package-id unordered-containers-0.2.8.0-Bp9XgxjuHxcI4tFehVMDGC -package-id websockets-0.10.0.0-VnlKayMDvyHnd2tkINzmP .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.dyn_o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Protocols.dyn_o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Types.dyn_o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Logger.dyn_o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Socks5.dyn_o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Credentials.dyn_o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/HttpProxy.dyn_o -o .stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/libHSwstunnel-0.1.0.0-AW3X1jAtS7XCeg7CJRwMWe-ghc8.0.2.so -optl-static -ddump-hi -ddump-to-file
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400180
.stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.dyn_o: In function `r1boV_info':
(.text+0x61): undefined reference to `newCAF'
.stack-work/dist/x86_64-freebsd/Cabal-1.24.2.0/build/Tunnel.dyn_o: In function `r1boV_info':
(.text+0x71): undefined reference to `stg_bh_upd_frame_info'

But unfortunately I have zero Haskell clue so I'm not sure what's missing.
Comment 1 Gleb Popov freebsd_committer 2019-02-06 18:09:32 UTC
We don't provide GHC 8.0.2 from ports, and there is no working distribution to be used by stack. On the other side, wstunnel doesn't build with recent LTS snapshots.

So, there is nothing that can be done on our side. Why do you need -optl-static, anyways? Stack links statically by default.

Bug upstream to update their application to more recent LTS snapshot.