How to produce a statically linked binary with GHC?

Nicola Squartini tensor5 at gmail.com
Fri Aug 15 01:40:33 EDT 2008


Same result.

When I type

$> runhaskell Setup build --verbose=3

I see this
...
gcc -v -o dist/build/lambdaInit/lambdaInit
dist/build/lambdaInit/lambdaInit-tmp/Main.o -static
-L/usr/lib/ghc-6.8.2/lib/hinotify-0.2
-L/usr/lib/ghc-6.8.2/lib/containers-0.1.0.1
-L/home/nicola/ghc//lib/VolumeID-0.1/ghc-6.8.2
-L/home/nicola/ghc/lib/Mount-0.1/ghc-6.8.2
-L/usr/lib/ghc-6.8.2/lib/regex-compat-0.71.0.1
-L/usr/lib/ghc-6.8.2/lib/regex-posix-0.72.0.2
-L/usr/lib/ghc-6.8.2/lib/regex-base-0.72.0.1
-L/usr/lib/ghc-6.8.2/lib/bytestring-0.9.0.1
-L/usr/lib/ghc-6.8.2/lib/array-0.1.0.0
-L/usr/lib/ghc-6.8.2/lib/process-1.0.0.0
-L/usr/lib/ghc-6.8.2/lib/unix-2.3.0.0
-L/usr/lib/ghc-6.8.2/lib/directory-1.0.0.0
-L/usr/lib/ghc-6.8.2/lib/filepath-1.1.0.0
-L/usr/lib/ghc-6.8.2/lib/old-time-1.0.0.0
-L/usr/lib/ghc-6.8.2/lib/old-locale-1.0.0.0
-L/usr/lib/ghc-6.8.2/lib/base-3.0.1.0 -L/usr/lib/ghc-6.8.2 -lHShinotify-0.2
-lHScontainers-0.1.0.1 -lHSVolumeID-0.1 -lvolume_id -lHSMount-0.1
-lHSregex-compat-0.71.0.1 -lHSregex-posix-0.72.0.2 -lHSregex-base-0.72.0.1
-lHSbytestring-0.9.0.1 -lHSarray-0.1.0.0 -lHSprocess-1.0.0.0
-lHSunix-2.3.0.0 -lutil -ldl -lHSdirectory-1.0.0.0 -lHSfilepath-1.1.0.0
-lHSold-time-1.0.0.0 -lHSold-locale-1.0.0.0 -lHSbase-3.0.1.0 -lHSrts -lm
-lgmp -ldl -lrt -u base_GHCziBase_Izh_static_info -u
base_GHCziBase_Czh_static_info -u base_GHCziFloat_Fzh_static_info -u
base_GHCziFloat_Dzh_static_info -u base_GHCziPtr_Ptr_static_info -u
base_GHCziWord_Wzh_static_info -u base_GHCziInt_I8zh_static_info -u
base_GHCziInt_I16zh_static_info -u base_GHCziInt_I32zh_static_info -u
base_GHCziInt_I64zh_static_info -u base_GHCziWord_W8zh_static_info -u
base_GHCziWord_W16zh_static_info -u base_GHCziWord_W32zh_static_info -u
base_GHCziWord_W64zh_static_info -u base_GHCziStable_StablePtr_static_info
-u base_GHCziBase_Izh_con_info -u base_GHCziBase_Czh_con_info -u
base_GHCziFloat_Fzh_con_info -u base_GHCziFloat_Dzh_con_info -u
base_GHCziPtr_Ptr_con_info -u base_GHCziPtr_FunPtr_con_info -u
base_GHCziStable_StablePtr_con_info -u base_GHCziBase_False_closure -u
base_GHCziBase_True_closure -u base_GHCziPack_unpackCString_closure -u
base_GHCziIOBase_stackOverflow_closure -u
base_GHCziIOBase_heapOverflow_closure -u
base_GHCziIOBase_NonTermination_closure -u
base_GHCziIOBase_BlockedOnDeadMVar_closure -u
base_GHCziIOBase_BlockedIndefinitely_closure -u
base_GHCziIOBase_Deadlock_closure -u
base_GHCziIOBase_NestedAtomically_closure -u
base_GHCziWeak_runFinalizzerBatch_closure -u
base_GHCziConc_ensureIOManagerIsRunning_closure
...

So I run that gcc command manually adding -lpthread at the end of it end it
works,  I get the static binary. Isn't it strange? It could be a gcc
problem.

On Thu, Aug 14, 2008 at 10:06 PM, Brandon S. Allbery KF8NH <
allbery at ece.cmu.edu> wrote:

>
> On 2008 Aug 15, at 1:02, Nicola Squartini wrote:
>
>  I did the following in my project and this is what I get:
>
> $> runhaskell Setup configure --user --ghc-option="-optl -static"
>
>
> No space between "-optl" and "-static".  The "-pthread" is probably being
> misrecognized as a result of the generated command.
>
> --
> brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
> system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
> electrical and computer engineering, carnegie mellon university    KF8NH
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20080814/9e015dd1/attachment.htm


More information about the Glasgow-haskell-users mailing list