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

Cannot build a statically linked binary with cabal new-* commands #5847

Closed
ggrossetie opened this issue Jan 16, 2019 · 5 comments
Closed

Cannot build a statically linked binary with cabal new-* commands #5847

ggrossetie opened this issue Jan 16, 2019 · 5 comments

Comments

@ggrossetie
Copy link

Hello,

As suggested by the error message, I'm opening an issue because I cannot reproduce a successful build with cabal new-* commands.

You can reproduce this issue using a Docker:

Working

# build static executable binary
FROM haskell:8

RUN git clone https://github.com/BurntSushi/erd.git

WORKDIR erd

# use "old" commands on purpose to workaround an issue with static link
RUN cabal update
RUN cabal install --only-dependencies --force-reinstalls
RUN cabal configure --disable-executable-dynamic --disable-shared --ghc-option=-optl=-static \
    && cabal build

Not working

# build static executable binary
FROM haskell:8

RUN git clone https://github.com/BurntSushi/erd.git

WORKDIR erd

RUN cabal new-update
RUN cabal new-install --lib
RUN cabal new-configure --disable-executable-dynamic --disable-shared --ghc-option=-optl=-static --ghc-option=-optl=-fpic \
    && cabal new-build
Full trace
Failed to build base-compat-0.10.5.
Build log (
/root/.cabal/logs/ghc-8.6.3/base-compat-0.10.5-21d660624a01f5a1582e7e1c04d7244556c42ee79cec338da08f996cb2c9fba4.log
):
Configuring library for base-compat-0.10.5..
Preprocessing library for base-compat-0.10.5..
Building library for base-compat-0.10.5..
[  1 of 112] Compiling Control.Concurrent.Compat ( src/Control/Concurrent/Compat.hs, dist/build/Control/Concurrent/Compat.o )
[  2 of 112] Compiling Control.Concurrent.Compat.Repl ( src/Control/Concurrent/Compat/Repl.hs, dist/build/Control/Concurrent/Compat/Repl.o )
[  3 of 112] Compiling Control.Concurrent.MVar.Compat ( src/Control/Concurrent/MVar/Compat.hs, dist/build/Control/Concurrent/MVar/Compat.o )
[  4 of 112] Compiling Control.Concurrent.MVar.Compat.Repl ( src/Control/Concurrent/MVar/Compat/Repl.hs, dist/build/Control/Concurrent/MVar/Compat/Repl.o )
[  5 of 112] Compiling Control.Exception.Compat ( src/Control/Exception/Compat.hs, dist/build/Control/Exception/Compat.o )
[  6 of 112] Compiling Control.Exception.Compat.Repl ( src/Control/Exception/Compat/Repl.hs, dist/build/Control/Exception/Compat/Repl.o )
[  7 of 112] Compiling Control.Monad.Compat ( src/Control/Monad/Compat.hs, dist/build/Control/Monad/Compat.o )
[  8 of 112] Compiling Control.Monad.Compat.Repl ( src/Control/Monad/Compat/Repl.hs, dist/build/Control/Monad/Compat/Repl.o )
[  9 of 112] Compiling Control.Monad.Fail.Compat ( src/Control/Monad/Fail/Compat.hs, dist/build/Control/Monad/Fail/Compat.o )
[ 10 of 112] Compiling Control.Monad.Fail.Compat.Repl ( src/Control/Monad/Fail/Compat/Repl.hs, dist/build/Control/Monad/Fail/Compat/Repl.o )
[ 11 of 112] Compiling Control.Monad.IO.Class.Compat ( src/Control/Monad/IO/Class/Compat.hs, dist/build/Control/Monad/IO/Class/Compat.o )
[ 12 of 112] Compiling Control.Monad.IO.Class.Compat.Repl ( src/Control/Monad/IO/Class/Compat/Repl.hs, dist/build/Control/Monad/IO/Class/Compat/Repl.o )
[ 13 of 112] Compiling Control.Monad.ST.Lazy.Unsafe.Compat ( src/Control/Monad/ST/Lazy/Unsafe/Compat.hs, dist/build/Control/Monad/ST/Lazy/Unsafe/Compat.o )
[ 14 of 112] Compiling Control.Monad.ST.Lazy.Unsafe.Compat.Repl ( src/Control/Monad/ST/Lazy/Unsafe/Compat/Repl.hs, dist/build/Control/Monad/ST/Lazy/Unsafe/Compat/Repl.o )
[ 15 of 112] Compiling Control.Monad.ST.Unsafe.Compat ( src/Control/Monad/ST/Unsafe/Compat.hs, dist/build/Control/Monad/ST/Unsafe/Compat.o )
[ 16 of 112] Compiling Control.Monad.ST.Unsafe.Compat.Repl ( src/Control/Monad/ST/Unsafe/Compat/Repl.hs, dist/build/Control/Monad/ST/Unsafe/Compat/Repl.o )
[ 17 of 112] Compiling Data.Bifoldable.Compat ( src/Data/Bifoldable/Compat.hs, dist/build/Data/Bifoldable/Compat.o )
[ 18 of 112] Compiling Data.Bifoldable.Compat.Repl ( src/Data/Bifoldable/Compat/Repl.hs, dist/build/Data/Bifoldable/Compat/Repl.o )
[ 19 of 112] Compiling Data.Bifunctor.Compat ( src/Data/Bifunctor/Compat.hs, dist/build/Data/Bifunctor/Compat.o )
[ 20 of 112] Compiling Data.Bifunctor.Compat.Repl ( src/Data/Bifunctor/Compat/Repl.hs, dist/build/Data/Bifunctor/Compat/Repl.o )
[ 21 of 112] Compiling Data.Bitraversable.Compat ( src/Data/Bitraversable/Compat.hs, dist/build/Data/Bitraversable/Compat.o )
[ 22 of 112] Compiling Data.Bitraversable.Compat.Repl ( src/Data/Bitraversable/Compat/Repl.hs, dist/build/Data/Bitraversable/Compat/Repl.o )
[ 23 of 112] Compiling Data.Bits.Compat ( src/Data/Bits/Compat.hs, dist/build/Data/Bits/Compat.o )
[ 24 of 112] Compiling Data.Bits.Compat.Repl ( src/Data/Bits/Compat/Repl.hs, dist/build/Data/Bits/Compat/Repl.o )
[ 25 of 112] Compiling Data.Bool.Compat ( src/Data/Bool/Compat.hs, dist/build/Data/Bool/Compat.o )
[ 26 of 112] Compiling Data.Bool.Compat.Repl ( src/Data/Bool/Compat/Repl.hs, dist/build/Data/Bool/Compat/Repl.o )
[ 27 of 112] Compiling Data.Complex.Compat ( src/Data/Complex/Compat.hs, dist/build/Data/Complex/Compat.o )
[ 28 of 112] Compiling Data.Complex.Compat.Repl ( src/Data/Complex/Compat/Repl.hs, dist/build/Data/Complex/Compat/Repl.o )
[ 29 of 112] Compiling Data.Either.Compat ( src/Data/Either/Compat.hs, dist/build/Data/Either/Compat.o )
[ 30 of 112] Compiling Data.Either.Compat.Repl ( src/Data/Either/Compat/Repl.hs, dist/build/Data/Either/Compat/Repl.o )
[ 31 of 112] Compiling Data.Foldable.Compat ( src/Data/Foldable/Compat.hs, dist/build/Data/Foldable/Compat.o )
[ 32 of 112] Compiling Data.Foldable.Compat.Repl ( src/Data/Foldable/Compat/Repl.hs, dist/build/Data/Foldable/Compat/Repl.o )
[ 33 of 112] Compiling Data.Function.Compat ( src/Data/Function/Compat.hs, dist/build/Data/Function/Compat.o )
[ 34 of 112] Compiling Data.Function.Compat.Repl ( src/Data/Function/Compat/Repl.hs, dist/build/Data/Function/Compat/Repl.o )
[ 35 of 112] Compiling Data.Functor.Compat ( src/Data/Functor/Compat.hs, dist/build/Data/Functor/Compat.o )
[ 36 of 112] Compiling Data.Functor.Compat.Repl ( src/Data/Functor/Compat/Repl.hs, dist/build/Data/Functor/Compat/Repl.o )
[ 37 of 112] Compiling Data.Functor.Compose.Compat ( src/Data/Functor/Compose/Compat.hs, dist/build/Data/Functor/Compose/Compat.o )
[ 38 of 112] Compiling Data.Functor.Compose.Compat.Repl ( src/Data/Functor/Compose/Compat/Repl.hs, dist/build/Data/Functor/Compose/Compat/Repl.o )
[ 39 of 112] Compiling Data.Functor.Const.Compat ( src/Data/Functor/Const/Compat.hs, dist/build/Data/Functor/Const/Compat.o )
[ 40 of 112] Compiling Data.Functor.Const.Compat.Repl ( src/Data/Functor/Const/Compat/Repl.hs, dist/build/Data/Functor/Const/Compat/Repl.o )
[ 41 of 112] Compiling Data.Functor.Contravariant.Compat ( src/Data/Functor/Contravariant/Compat.hs, dist/build/Data/Functor/Contravariant/Compat.o )
[ 42 of 112] Compiling Data.Functor.Contravariant.Compat.Repl ( src/Data/Functor/Contravariant/Compat/Repl.hs, dist/build/Data/Functor/Contravariant/Compat/Repl.o )
[ 43 of 112] Compiling Data.Functor.Identity.Compat ( src/Data/Functor/Identity/Compat.hs, dist/build/Data/Functor/Identity/Compat.o )
[ 44 of 112] Compiling Data.Functor.Identity.Compat.Repl ( src/Data/Functor/Identity/Compat/Repl.hs, dist/build/Data/Functor/Identity/Compat/Repl.o )
[ 45 of 112] Compiling Data.Functor.Product.Compat ( src/Data/Functor/Product/Compat.hs, dist/build/Data/Functor/Product/Compat.o )
[ 46 of 112] Compiling Data.Functor.Product.Compat.Repl ( src/Data/Functor/Product/Compat/Repl.hs, dist/build/Data/Functor/Product/Compat/Repl.o )
[ 47 of 112] Compiling Data.Functor.Sum.Compat ( src/Data/Functor/Sum/Compat.hs, dist/build/Data/Functor/Sum/Compat.o )
[ 48 of 112] Compiling Data.Functor.Sum.Compat.Repl ( src/Data/Functor/Sum/Compat/Repl.hs, dist/build/Data/Functor/Sum/Compat/Repl.o )
[ 49 of 112] Compiling Data.IORef.Compat ( src/Data/IORef/Compat.hs, dist/build/Data/IORef/Compat.o )
[ 50 of 112] Compiling Data.IORef.Compat.Repl ( src/Data/IORef/Compat/Repl.hs, dist/build/Data/IORef/Compat/Repl.o )
[ 51 of 112] Compiling Data.List.Compat ( src/Data/List/Compat.hs, dist/build/Data/List/Compat.o )
[ 52 of 112] Compiling Data.List.Compat.Repl ( src/Data/List/Compat/Repl.hs, dist/build/Data/List/Compat/Repl.o )
[ 53 of 112] Compiling Data.List.NonEmpty.Compat ( src/Data/List/NonEmpty/Compat.hs, dist/build/Data/List/NonEmpty/Compat.o )
[ 54 of 112] Compiling Data.List.NonEmpty.Compat.Repl ( src/Data/List/NonEmpty/Compat/Repl.hs, dist/build/Data/List/NonEmpty/Compat/Repl.o )
[ 55 of 112] Compiling Data.Monoid.Compat ( src/Data/Monoid/Compat.hs, dist/build/Data/Monoid/Compat.o )
[ 56 of 112] Compiling Data.Monoid.Compat.Repl ( src/Data/Monoid/Compat/Repl.hs, dist/build/Data/Monoid/Compat/Repl.o )
[ 57 of 112] Compiling Data.Proxy.Compat ( src/Data/Proxy/Compat.hs, dist/build/Data/Proxy/Compat.o )
[ 58 of 112] Compiling Data.Proxy.Compat.Repl ( src/Data/Proxy/Compat/Repl.hs, dist/build/Data/Proxy/Compat/Repl.o )
[ 59 of 112] Compiling Data.Ratio.Compat ( src/Data/Ratio/Compat.hs, dist/build/Data/Ratio/Compat.o )
[ 60 of 112] Compiling Data.Ratio.Compat.Repl ( src/Data/Ratio/Compat/Repl.hs, dist/build/Data/Ratio/Compat/Repl.o )
[ 61 of 112] Compiling Data.STRef.Compat ( src/Data/STRef/Compat.hs, dist/build/Data/STRef/Compat.o )
[ 62 of 112] Compiling Data.STRef.Compat.Repl ( src/Data/STRef/Compat/Repl.hs, dist/build/Data/STRef/Compat/Repl.o )
[ 63 of 112] Compiling Data.Semigroup.Compat ( src/Data/Semigroup/Compat.hs, dist/build/Data/Semigroup/Compat.o )
[ 64 of 112] Compiling Data.Semigroup.Compat.Repl ( src/Data/Semigroup/Compat/Repl.hs, dist/build/Data/Semigroup/Compat/Repl.o )
[ 65 of 112] Compiling Data.String.Compat ( src/Data/String/Compat.hs, dist/build/Data/String/Compat.o )
[ 66 of 112] Compiling Data.String.Compat.Repl ( src/Data/String/Compat/Repl.hs, dist/build/Data/String/Compat/Repl.o )
[ 67 of 112] Compiling Data.Type.Coercion.Compat ( src/Data/Type/Coercion/Compat.hs, dist/build/Data/Type/Coercion/Compat.o )
[ 68 of 112] Compiling Data.Type.Coercion.Compat.Repl ( src/Data/Type/Coercion/Compat/Repl.hs, dist/build/Data/Type/Coercion/Compat/Repl.o )
[ 69 of 112] Compiling Data.Version.Compat ( src/Data/Version/Compat.hs, dist/build/Data/Version/Compat.o )
[ 70 of 112] Compiling Data.Version.Compat.Repl ( src/Data/Version/Compat/Repl.hs, dist/build/Data/Version/Compat/Repl.o )
[ 71 of 112] Compiling Data.Void.Compat ( src/Data/Void/Compat.hs, dist/build/Data/Void/Compat.o )
[ 72 of 112] Compiling Data.Void.Compat.Repl ( src/Data/Void/Compat/Repl.hs, dist/build/Data/Void/Compat/Repl.o )
[ 73 of 112] Compiling Data.Word.Compat ( src/Data/Word/Compat.hs, dist/build/Data/Word/Compat.o )
[ 74 of 112] Compiling Data.Word.Compat.Repl ( src/Data/Word/Compat/Repl.hs, dist/build/Data/Word/Compat/Repl.o )
[ 75 of 112] Compiling Debug.Trace.Compat ( src/Debug/Trace/Compat.hs, dist/build/Debug/Trace/Compat.o )
[ 76 of 112] Compiling Debug.Trace.Compat.Repl ( src/Debug/Trace/Compat/Repl.hs, dist/build/Debug/Trace/Compat/Repl.o )
[ 77 of 112] Compiling Foreign.ForeignPtr.Compat ( src/Foreign/ForeignPtr/Compat.hs, dist/build/Foreign/ForeignPtr/Compat.o )
[ 78 of 112] Compiling Foreign.ForeignPtr.Compat.Repl ( src/Foreign/ForeignPtr/Compat/Repl.hs, dist/build/Foreign/ForeignPtr/Compat/Repl.o )
[ 79 of 112] Compiling Foreign.ForeignPtr.Safe.Compat ( src/Foreign/ForeignPtr/Safe/Compat.hs, dist/build/Foreign/ForeignPtr/Safe/Compat.o )
[ 80 of 112] Compiling Foreign.ForeignPtr.Safe.Compat.Repl ( src/Foreign/ForeignPtr/Safe/Compat/Repl.hs, dist/build/Foreign/ForeignPtr/Safe/Compat/Repl.o )
[ 81 of 112] Compiling Foreign.ForeignPtr.Unsafe.Compat ( src/Foreign/ForeignPtr/Unsafe/Compat.hs, dist/build/Foreign/ForeignPtr/Unsafe/Compat.o )
[ 82 of 112] Compiling Foreign.ForeignPtr.Unsafe.Compat.Repl ( src/Foreign/ForeignPtr/Unsafe/Compat/Repl.hs, dist/build/Foreign/ForeignPtr/Unsafe/Compat/Repl.o )
[ 83 of 112] Compiling Foreign.Marshal.Alloc.Compat ( src/Foreign/Marshal/Alloc/Compat.hs, dist/build/Foreign/Marshal/Alloc/Compat.o )
[ 84 of 112] Compiling Foreign.Marshal.Alloc.Compat.Repl ( src/Foreign/Marshal/Alloc/Compat/Repl.hs, dist/build/Foreign/Marshal/Alloc/Compat/Repl.o )
[ 85 of 112] Compiling Foreign.Marshal.Array.Compat ( src/Foreign/Marshal/Array/Compat.hs, dist/build/Foreign/Marshal/Array/Compat.o )
[ 86 of 112] Compiling Foreign.Marshal.Array.Compat.Repl ( src/Foreign/Marshal/Array/Compat/Repl.hs, dist/build/Foreign/Marshal/Array/Compat/Repl.o )
[ 87 of 112] Compiling Foreign.Marshal.Safe.Compat ( src/Foreign/Marshal/Safe/Compat.hs, dist/build/Foreign/Marshal/Safe/Compat.o )
[ 88 of 112] Compiling Foreign.Marshal.Safe.Compat.Repl ( src/Foreign/Marshal/Safe/Compat/Repl.hs, dist/build/Foreign/Marshal/Safe/Compat/Repl.o )
[ 89 of 112] Compiling Foreign.Marshal.Unsafe.Compat ( src/Foreign/Marshal/Unsafe/Compat.hs, dist/build/Foreign/Marshal/Unsafe/Compat.o )
[ 90 of 112] Compiling Foreign.Marshal.Unsafe.Compat.Repl ( src/Foreign/Marshal/Unsafe/Compat/Repl.hs, dist/build/Foreign/Marshal/Unsafe/Compat/Repl.o )
[ 91 of 112] Compiling Foreign.Marshal.Utils.Compat ( src/Foreign/Marshal/Utils/Compat.hs, dist/build/Foreign/Marshal/Utils/Compat.o )
[ 92 of 112] Compiling Foreign.Marshal.Compat ( src/Foreign/Marshal/Compat.hs, dist/build/Foreign/Marshal/Compat.o )
[ 93 of 112] Compiling Foreign.Marshal.Compat.Repl ( src/Foreign/Marshal/Compat/Repl.hs, dist/build/Foreign/Marshal/Compat/Repl.o )
[ 94 of 112] Compiling Foreign.Compat   ( src/Foreign/Compat.hs, dist/build/Foreign/Compat.o )
[ 95 of 112] Compiling Foreign.Compat.Repl ( src/Foreign/Compat/Repl.hs, dist/build/Foreign/Compat/Repl.o )
[ 96 of 112] Compiling Foreign.Marshal.Utils.Compat.Repl ( src/Foreign/Marshal/Utils/Compat/Repl.hs, dist/build/Foreign/Marshal/Utils/Compat/Repl.o )
[ 97 of 112] Compiling Numeric.Compat   ( src/Numeric/Compat.hs, dist/build/Numeric/Compat.o )
[ 98 of 112] Compiling Numeric.Compat.Repl ( src/Numeric/Compat/Repl.hs, dist/build/Numeric/Compat/Repl.o )
[ 99 of 112] Compiling Numeric.Natural.Compat ( src/Numeric/Natural/Compat.hs, dist/build/Numeric/Natural/Compat.o )
[100 of 112] Compiling Numeric.Natural.Compat.Repl ( src/Numeric/Natural/Compat/Repl.hs, dist/build/Numeric/Natural/Compat/Repl.o )
[101 of 112] Compiling Prelude.Compat   ( src/Prelude/Compat.hs, dist/build/Prelude/Compat.o )
[102 of 112] Compiling Prelude.Compat.Repl ( src/Prelude/Compat/Repl.hs, dist/build/Prelude/Compat/Repl.o )
[103 of 112] Compiling System.Environment.Compat ( src/System/Environment/Compat.hs, dist/build/System/Environment/Compat.o )
[104 of 112] Compiling System.Environment.Compat.Repl ( src/System/Environment/Compat/Repl.hs, dist/build/System/Environment/Compat/Repl.o )
[105 of 112] Compiling System.Exit.Compat ( src/System/Exit/Compat.hs, dist/build/System/Exit/Compat.o )
[106 of 112] Compiling System.Exit.Compat.Repl ( src/System/Exit/Compat/Repl.hs, dist/build/System/Exit/Compat/Repl.o )
[107 of 112] Compiling System.IO.Unsafe.Compat ( src/System/IO/Unsafe/Compat.hs, dist/build/System/IO/Unsafe/Compat.o )
[108 of 112] Compiling System.IO.Unsafe.Compat.Repl ( src/System/IO/Unsafe/Compat/Repl.hs, dist/build/System/IO/Unsafe/Compat/Repl.o )
[109 of 112] Compiling Text.Read.Compat ( src/Text/Read/Compat.hs, dist/build/Text/Read/Compat.o )
[110 of 112] Compiling Text.Read.Compat.Repl ( src/Text/Read/Compat/Repl.hs, dist/build/Text/Read/Compat/Repl.o )
[111 of 112] Compiling Type.Reflection.Compat ( src/Type/Reflection/Compat.hs, dist/build/Type/Reflection/Compat.o )
[112 of 112] Compiling Type.Reflection.Compat.Repl ( src/Type/Reflection/Compat/Repl.hs, dist/build/Type/Reflection/Compat/Repl.o )
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginT.o: requires dynamic R_X86_64_32 reloc against '__TMC_END__' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

Failed to build colour-2.3.4.
Build log (
/root/.cabal/logs/ghc-8.6.3/colour-2.3.4-9875af95a23db6c0040a1d671bc95e43754ed36f818e9c9b185b736d73e68b44.log
):
Configuring library for colour-2.3.4..
Preprocessing library for colour-2.3.4..
Building library for colour-2.3.4..
[ 1 of 14] Compiling Data.Colour.CIE.Chromaticity ( Data/Colour/CIE/Chromaticity.hs, dist/build/Data/Colour/CIE/Chromaticity.o )
[ 2 of 14] Compiling Data.Colour.CIE.Illuminant ( Data/Colour/CIE/Illuminant.hs, dist/build/Data/Colour/CIE/Illuminant.o )
[ 3 of 14] Compiling Data.Colour.Chan ( Data/Colour/Chan.hs, dist/build/Data/Colour/Chan.o )
[ 4 of 14] Compiling Data.Colour.Internal ( Data/Colour/Internal.hs, dist/build/Data/Colour/Internal.o )
[ 5 of 14] Compiling Data.Colour.Matrix ( Data/Colour/Matrix.hs, dist/build/Data/Colour/Matrix.o )
[ 6 of 14] Compiling Data.Colour.RGB ( Data/Colour/RGB.hs, dist/build/Data/Colour/RGB.o )
[ 7 of 14] Compiling Data.Colour.RGBSpace.HSL ( Data/Colour/RGBSpace/HSL.hs, dist/build/Data/Colour/RGBSpace/HSL.o )
[ 8 of 14] Compiling Data.Colour.RGBSpace.HSV ( Data/Colour/RGBSpace/HSV.hs, dist/build/Data/Colour/RGBSpace/HSV.o )
[ 9 of 14] Compiling Data.Colour.SRGB.Linear ( Data/Colour/SRGB/Linear.hs, dist/build/Data/Colour/SRGB/Linear.o )
[10 of 14] Compiling Data.Colour.RGBSpace ( Data/Colour/RGBSpace.hs, dist/build/Data/Colour/RGBSpace.o )
[11 of 14] Compiling Data.Colour.SRGB ( Data/Colour/SRGB.hs, dist/build/Data/Colour/SRGB.o )
[12 of 14] Compiling Data.Colour ( Data/Colour.hs, dist/build/Data/Colour.o )
[13 of 14] Compiling Data.Colour.Names ( Data/Colour/Names.hs, dist/build/Data/Colour/Names.o )
[14 of 14] Compiling Data.Colour.CIE ( Data/Colour/CIE.hs, dist/build/Data/Colour/CIE.o )
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginT.o: requires dynamic R_X86_64_32 reloc against 'TMC_END' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
gcc' failed in phase Linker'. (Exit code: 1)

Failed to build containers-0.5.11.0.
Build log (
/root/.cabal/logs/ghc-8.6.3/containers-0.5.11.0-b8bb6e3b2e1e0428564ba7f198225719fe796dcde5df663eb9fa38dc977e5eef.log
):
Configuring library for containers-0.5.11.0..
Preprocessing library for containers-0.5.11.0..
Building library for containers-0.5.11.0..
[ 1 of 35] Compiling Utils.Containers.Internal.BitUtil ( Utils/Containers/Internal/BitUtil.hs, dist/build/Utils/Containers/Internal/BitUtil.o )
[ 2 of 35] Compiling Utils.Containers.Internal.BitQueue ( Utils/Containers/Internal/BitQueue.hs, dist/build/Utils/Containers/Internal/BitQueue.o )
[ 3 of 35] Compiling Utils.Containers.Internal.PtrEquality ( Utils/Containers/Internal/PtrEquality.hs, dist/build/Utils/Containers/Internal/PtrEquality.o )
[ 4 of 35] Compiling Utils.Containers.Internal.State ( Utils/Containers/Internal/State.hs, dist/build/Utils/Containers/Internal/State.o )
[ 5 of 35] Compiling Utils.Containers.Internal.StrictFold ( Utils/Containers/Internal/StrictFold.hs, dist/build/Utils/Containers/Internal/StrictFold.o )
[ 6 of 35] Compiling Utils.Containers.Internal.StrictMaybe ( Utils/Containers/Internal/StrictMaybe.hs, dist/build/Utils/Containers/Internal/StrictMaybe.o )
[ 7 of 35] Compiling Utils.Containers.Internal.StrictPair ( Utils/Containers/Internal/StrictPair.hs, dist/build/Utils/Containers/Internal/StrictPair.o )
[ 8 of 35] Compiling Data.Set.Internal ( Data/Set/Internal.hs, dist/build/Data/Set/Internal.o )
[ 9 of 35] Compiling Data.Set ( Data/Set.hs, dist/build/Data/Set.o )
[10 of 35] Compiling Data.Sequence.Internal ( Data/Sequence/Internal.hs, dist/build/Data/Sequence/Internal.o )
[11 of 35] Compiling Data.Sequence.Internal.Sorting ( Data/Sequence/Internal/Sorting.hs, dist/build/Data/Sequence/Internal/Sorting.o )
[12 of 35] Compiling Data.Sequence ( Data/Sequence.hs, dist/build/Data/Sequence.o )
[13 of 35] Compiling Data.Tree ( Data/Tree.hs, dist/build/Data/Tree.o )
[14 of 35] Compiling Data.Graph ( Data/Graph.hs, dist/build/Data/Graph.o )
[15 of 35] Compiling Data.Map.Internal ( Data/Map/Internal.hs, dist/build/Data/Map/Internal.o )
[16 of 35] Compiling Data.Map.Merge.Lazy ( Data/Map/Merge/Lazy.hs, dist/build/Data/Map/Merge/Lazy.o )
[17 of 35] Compiling Data.Map.Lazy.Merge ( Data/Map/Lazy/Merge.hs, dist/build/Data/Map/Lazy/Merge.o )
[18 of 35] Compiling Data.Map.Internal.Debug ( Data/Map/Internal/Debug.hs, dist/build/Data/Map/Internal/Debug.o )
[19 of 35] Compiling Data.Map.Internal.DeprecatedShowTree ( Data/Map/Internal/DeprecatedShowTree.hs, dist/build/Data/Map/Internal/DeprecatedShowTree.o )
[20 of 35] Compiling Data.Map.Strict.Internal ( Data/Map/Strict/Internal.hs, dist/build/Data/Map/Strict/Internal.o )
[21 of 35] Compiling Data.Map.Strict ( Data/Map/Strict.hs, dist/build/Data/Map/Strict.o )
[22 of 35] Compiling Data.Map.Merge.Strict ( Data/Map/Merge/Strict.hs, dist/build/Data/Map/Merge/Strict.o )
[23 of 35] Compiling Data.Map.Strict.Merge ( Data/Map/Strict/Merge.hs, dist/build/Data/Map/Strict/Merge.o )
[24 of 35] Compiling Data.Map.Lazy ( Data/Map/Lazy.hs, dist/build/Data/Map/Lazy.o )
[25 of 35] Compiling Data.Map ( Data/Map.hs, dist/build/Data/Map.o )
[26 of 35] Compiling Data.IntSet.Internal ( Data/IntSet/Internal.hs, dist/build/Data/IntSet/Internal.o )
[27 of 35] Compiling Data.IntSet ( Data/IntSet.hs, dist/build/Data/IntSet.o )
[28 of 35] Compiling Data.IntMap.Internal ( Data/IntMap/Internal.hs, dist/build/Data/IntMap/Internal.o )
[29 of 35] Compiling Data.IntMap.Merge.Strict ( Data/IntMap/Merge/Strict.hs, dist/build/Data/IntMap/Merge/Strict.o )
[30 of 35] Compiling Data.IntMap.Merge.Lazy ( Data/IntMap/Merge/Lazy.hs, dist/build/Data/IntMap/Merge/Lazy.o )
[31 of 35] Compiling Data.IntMap.Internal.DeprecatedDebug ( Data/IntMap/Internal/DeprecatedDebug.hs, dist/build/Data/IntMap/Internal/DeprecatedDebug.o )
[32 of 35] Compiling Data.IntMap.Strict ( Data/IntMap/Strict.hs, dist/build/Data/IntMap/Strict.o )
[33 of 35] Compiling Data.IntMap.Lazy ( Data/IntMap/Lazy.hs, dist/build/Data/IntMap/Lazy.o )
[34 of 35] Compiling Data.IntMap ( Data/IntMap.hs, dist/build/Data/IntMap.o )
[35 of 35] Compiling Data.IntMap.Internal.Debug ( Data/IntMap/Internal/Debug.hs, dist/build/Data/IntMap/Internal/Debug.o )
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginT.o: requires dynamic R_X86_64_32 reloc against 'TMC_END' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
gcc' failed in phase Linker'. (Exit code: 1)

Failed to build dlist-0.8.0.5.
Build log (
/root/.cabal/logs/ghc-8.6.3/dlist-0.8.0.5-e7cb8aded1ab336d5b6ec2b6ac3f21944391aa15a32746136d6b4e1295b773d7.log
):
Configuring library for dlist-0.8.0.5..
Preprocessing library for dlist-0.8.0.5..
Building library for dlist-0.8.0.5..
[1 of 1] Compiling Data.DList ( Data/DList.hs, dist/build/Data/DList.o )
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginT.o: requires dynamic R_X86_64_32 reloc against 'TMC_END' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
gcc' failed in phase Linker'. (Exit code: 1)

Failed to build random-1.1.
Build log (
/root/.cabal/logs/ghc-8.6.3/random-1.1-b31a6f9f21ceb46a656aaadd06b6feacdd6ada89e0f9534d355c1f93b059cda4.log
):
Warning: random.cabal:15:2: Tabs used as indentation at 15:2, 16:2, 17:2
Configuring library for random-1.1..
Preprocessing library for random-1.1..
Building library for random-1.1..
[1 of 1] Compiling System.Random ( System/Random.hs, dist/build/System/Random.o )

System/Random.hs:43:1: warning: [-Wtabs]
Tab character found here, and in 74 further locations.
Please use spaces instead.
|
43 | (
| ^^^^^^^^
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginT.o: requires dynamic R_X86_64_32 reloc against 'TMC_END' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
gcc' failed in phase Linker'. (Exit code: 1)

Failed to build transformers-compat-0.6.2.
Build log (
/root/.cabal/logs/ghc-8.6.3/transformers-compat-0.6.2-c757024fa447c63bacc423732c0f19b609550d4010c1166a49299d7800b64862.log
):
Configuring library for transformers-compat-0.6.2..
Preprocessing library for transformers-compat-0.6.2..
Building library for transformers-compat-0.6.2..
[1 of 4] Compiling Control.Monad.Trans.Instances ( src/Control/Monad/Trans/Instances.hs, dist/build/Control/Monad/Trans/Instances.o )
[2 of 4] Compiling Data.Functor.Classes.Generic.Internal ( generics/Data/Functor/Classes/Generic/Internal.hs, dist/build/Data/Functor/Classes/Generic/Internal.o )
[3 of 4] Compiling Data.Functor.Classes.Generic ( generics/Data/Functor/Classes/Generic.hs, dist/build/Data/Functor/Classes/Generic.o )
[4 of 4] Compiling Paths_transformers_compat ( dist/build/autogen/Paths_transformers_compat.hs, dist/build/Paths_transformers_compat.o )
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginT.o: requires dynamic R_X86_64_32 reloc against 'TMC_END' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
gcc' failed in phase Linker'. (Exit code: 1)
cabal: Failed to build base-compat-0.10.5 (which is required by exe:erd from
erd-0.1.3.0). See the build log above for details.
Failed to build colour-2.3.4 (which is required by exe:erd from erd-0.1.3.0).
See the build log above for details.
Failed to build containers-0.5.11.0 (which is required by exe:erd from
erd-0.1.3.0). See the build log above for details.
Failed to build dlist-0.8.0.5 (which is required by exe:erd from erd-0.1.3.0).
See the build log above for details.
Failed to build random-1.1 (which is required by exe:erd from erd-0.1.3.0).
See the build log above for details.
Failed to build transformers-compat-0.6.2 (which is required by exe:erd from
erd-0.1.3.0). See the build log above for details.

The command '/bin/sh -c cabal new-configure --disable-executable-dynamic --disable-shared --ghc-option=-optl=-static && cabal new-build' returned a non-zero code: 1


I'm new to the Haskell ecosystem so maybe I'm missing something.
As suggested by the error message, I've tried to add the -fPIC but without success...

cabal new-configure --disable-executable-dynamic --disable-shared --ghc-option=-optl=-static --ghc-option=-optl=-fpic
cabal new-configure --disable-executable-dynamic --disable-shared --ghc-option=-optl=-static --ghc-option=-fpic

Related issue: BurntSushi/erd#40

@cohei
Copy link

cohei commented Apr 8, 2019

This may help you. They use stack but I try the ld-options way with cabal new-* and it works.

@sboosali
Copy link
Collaborator

sboosali commented Apr 8, 2019 via email

@jneira
Copy link
Member

jneira commented May 5, 2021

did you try cabal v2-build --enable-executable-static?

@Mikolaj
Copy link
Member

Mikolaj commented May 5, 2021

Indeed, it should work according to tests in #7236.

@Mikolaj
Copy link
Member

Mikolaj commented Aug 6, 2021

We've got no info and the recommended way to build static exes is different now and works (sometimes, for cabal new-build), so I'm optimistically closing. Please do reopen if new info arrives.

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

No branches or pull requests

5 participants