BurntSushi / erd

Translates a plain text description of a relational database schema to a graphical entity-relationship diagram.
The Unlicense
1.79k stars 153 forks source link

Build a statically linked binary #40

Closed ggrossetie closed 10 months ago

ggrossetie commented 5 years ago

Hello and thanks for this project!

I'm trying to build a statically linked binary from the source. I'm not very familiar with the Haskell ecosystem so I've been using this blog post https://vaibhavsagar.com/blog/2018/01/03/static-haskell-nix/ to get me started.

I have the following Dockerfile to build the project:

# 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 \
    && cabal new-build

As you can see I'm using new prefixed commands because cabal was complaining. Anyway, the build is failing as you can see below:

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


Do you know if it's possible ? Am I missing something ?

Thanks for your help :+1:

BurntSushi commented 5 years ago

No, I don't know, sorry.

ggrossetie commented 5 years ago

Alright, thanks for your quick reply, I will try to dig a bit further 😄

ggrossetie commented 5 years ago

Just a quick note, it's actually working using "old" cabal commands:

# 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

@BurntSushi If you want I can submit a pull request with this Dockerfile ? Or add a documentation page somewhere if you think that it can be useful ? :wink:

BurntSushi commented 5 years ago

I'd be happy to add a link, but I definitely do not want to adopt a Dockerfile in a project that is already unmaintained.

ggrossetie commented 5 years ago

Oh I didn't know that the project is unmaintained. The idea is not to publish this Docker image to the Docker registry: https://hub.docker.com It's really just about building a statically linked binary then you can copy this binary and do whatever you want. Should I add a mention in the README ?

nh2 commented 5 years ago

Hey, I found this because I got pinged on https://github.com/haskell/cabal/issues/5847.

What you want to do is really easy with https://github.com/nh2/static-haskell-nix: Just check out the repo, do what it says in the README, and run:

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build --no-link survey/default.nix -A haskellPackages.erd

This will generate a 3.8 MB static erd for you.

I have attached it here: erd-0.1.3.0-static-linux-x86_64.zip

Building it took only 2 minutes due to my binary cache. I had to make a miniscule change https://github.com/nh2/static-haskell-nix/commit/3729754351cc439b23a721bb0fd460d99e13f7b8 to get it compile, because the erd hackage package has a declared a fixed dependency base == 4.7 which only allows older GHCs; the doJailbreak I've added relaxes that constraing. If this was fixed on Hackage, you'd be able to build this static exe without any change to my repo.

I also recommend you adding erd to Stackage, because then erd will get built statically as part of my repo automatically.

ggrossetie commented 5 years ago

Hello @nh2 Thanks for your reply.

As mentioned, I'm not familiar with the whole Haskell ecosystem. I finally got this working using cabal "old" commands.

What are the advantages of using nixpkgs ? Also I'm building the binary from a Docker image to make the build reproducible (and avoid Haskell build tools installation on the local machine). In your repository you talk about building against musl instead of gcc. Does it mean that I can use a tiny Alpine image to build erd ?

The dependency should be base >= 4.7. The Haskell policy is to provide backward compatible version of base ?

Regarding Stackage, I don't really know because @BurntSushi already mentioned that the project is unmaintained. So ultimately he will decide.

nh2 commented 5 years ago

@Mogztter

As mentioned, I'm not familiar with the whole Haskell ecosystem.

Yep, understood.

What are the advantages of using nixpkgs ?

Reproducibility to a high degree, and getting a musl based toolchain. It can be a pain to get a full musl-based compiler toolchain available on Linux distributions that default to glibc, because you have to rebuild everything yourself. With nixpkgs you can "codify" this toolchain, and easily share the work across multiple different binaries (e.g. my repo building all executables on Stackage, vs each upstream project having to maintain their own Docker setup to provide static executables).

In your repository you talk about building against musl instead of gcc.

Small correction: musl instead of glibc. gcc is still used as the compiler. This is because glibc doesn't like being linked statically, and musl supports this use case officially.

Does it mean that I can use a tiny Alpine image to build erd ?

Yes, likely. As long as your build toolchain is built on musl, using this approach is equivalent to my nixpkgs approach.

You also need to ensure that all system libraries a given Haskell package needs provide .a files for static linking. I don't know to what extent Alpine does that already; in my repo I can do it relatively conveniently for all kinds of system libraries (example).

The dependency should be base >= 4.7.

I think this is only the case in master, because https://github.com/BurntSushi/erd/commit/51b0807564f5be7cda06bec8bb54bbe3839f6c38 appears to have never made it into a Hackage release. On Hackage (and thus in my repo) it still has the old base == 4.7.*.

Regarding Stackage, I don't really know because @BurntSushi already mentioned that the project is unmaintained. So ultimately he will decide.

You don't need to be the author to add something to Stackage (like you don't need to be an author to add something to Debian).

If @BurntSushi does not need to project any more, but you have an interest in erd because you use it for your work, you could be the Stackage maintainer of it to ensure it keeps compiling well with newer GHCs and libraries. I also do that for some libraries that aren't mine (example).

I hadn't heard of erd before this ticket, but it looks pretty useful and the output looks nice, so it might be worthwhile.

Hope this answers all questions!

BurntSushi commented 5 years ago

If someone wanted to take over this code and manage the Stack package, that'd be great!

nh2 commented 5 years ago

If someone wanted to take over this code and manage the Stack package, that'd be great!

@BurntSushi mind making a short, pinned "looking for new maintainer" issue?

That would make it obvious for people looking at issues. I'd then link it for you on Haskell reddit and mailing lists unless you want to do that. The package seems beginner friendly so chances are high somebody would like to take it over.

BurntSushi commented 5 years ago

@nh2 Sure, good idea. See #42.

ggrossetie commented 4 years ago

@mmzx I have seen that the project can now be built using stack. What is the recommended way to create a statically linked binary? Thanks!

mmzx commented 4 years ago

@Mogztter, can you maybe have a look at the link below? I would be able to give a better answer towards the weekend, at the moment I'm in the road... https://github.com/commercialhaskell/stack/issues/3420

nh2 commented 4 years ago

What is the recommended way to create a statically linked binary?

static-haskell-nix can do it for stack projects: https://github.com/nh2/static-haskell-nix/#building-stack-projects

ggrossetie commented 4 years ago

@nh2 I'm using a Docker image to build the project and I'm not familiar with nix so https://github.com/nh2/static-haskell-nix/blob/master/static-stack2nix-builder-example/default.nix is really cryptic for me :thinking:

Do you provide a Docker image to build a statically linked binary with static-haskell-nix ? Ideally I want to do something like:

FROM xyz

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

WORKDIR erd

RUN git checkout v0.2.0.0

RUN nixpkgs nix-build
ggrossetie commented 4 years ago

I also recommend you adding erd to Stackage, because then erd will get built statically as part of my repo automatically.

@nh2 Is that the case now? Can I get a pre-built statically linked binary of erd somewhere?

ggrossetie commented 4 years ago

For reference the following is working:

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y graphviz curl git

RUN curl -sSL https://get.haskellstack.org/ | sh

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

WORKDIR erd

RUN git checkout v0.2.0.0

RUN /usr/local/bin/stack install --ghc-options="-fPIC" \
  --ghc-options="-static" \
  --ghc-options="-optl=-static" \
  --ghc-options="-optc=-static"
nh2 commented 4 years ago

@Mogztter

Is that the case now?

It looks not, erd is not on https://www.stackage.org/lts-14.7. Did anybody make an effort to add it?

Do you provide a Docker image to build a statically linked binary with static-haskell-nix ?

No, Docker does not really provide any benefit over using nix directly on a host system, so it is unlikely that anybody will do that.

For reference the following is working:

Be aware that your Docker image is using Ubuntu, which means you are statically linking against glibc, which does not properly support static linking (neither technically, nor do its maintainers consider static linking a use case worth supporting). If you use any networking functionality, you must expect segfaults (e.g. https://github.com/nh2/static-haskell-nix/issues/17), and may experience other odd behaviour.

To get a proper static binary without surprises, you must use a libc that supports static linking, such as musl, and the entire dependency chain (including all dependent system C libraries) must be built against it. This is what static-haskell-nix does, and the reason why stack alone cannot give you a static binary (because it has no control over your system C libraries). An alternative is to do what you do (building with stack) in Alpine Linux (or a docker container thereof), which comes with musl as its system libc.

Building erd with static-haskell-nix

I'm not familiar with nix so https://github.com/nh2/static-haskell-nix/blob/master/static-stack2nix-builder-example/default.nix is really cryptic for me

Understood. Nix has a significant learning curve (though certainly easier than Haskell), but it is usually worth it because it gives full control over all dependencies (like using a different libc), and high reproducibility.

In this case, you have it easy though:

You don't need to understand the static-stack2nix-builder in detail. I've written it such that for most projects, you can just drop it into your directory and run it. This also works for erd.

First install nix.

Download default.nix, and set the relevant variables for erd:

  cabalPackageName = "erd";
  compiler = "ghc844"; # matching stack.yaml

Then run the command $(nix-build --no-link -A fullBuildScript) as explained in the top of the the file.

It will build and print /nix/store/5i3b3n7amd0yb9fx0zdrww95ancyy9iz-erd-0.2.0.0, which contains the desired static binary in the bin directory.

(Follow the steps at Binary caches for faster building (optional) if you want to use my binary cache so you don't have wait for building GHC from scratch.)

For convenience I've attached the binary built this way, so you can try out if it works before making any effort of building it yourself: erd-0.2.0.0.tar.gz

ggrossetie commented 4 years ago

It looks not, erd is not on https://www.stackage.org/lts-14.7. Did anybody make an effort to add it?

Sorry I misread, it's published on hackage not stackage 😅 http://hackage.haskell.org/package/erd

No, Docker does not really provide any benefit over using nix directly on a host system, so it is unlikely that anybody will do that.

Ok but I can install Nix on an Alpine image?

To get a proper static binary without surprises, you must use a libc that supports static linking, such as musl, and the entire dependency chain (including all dependent system C libraries) must be built against it. This is what static-haskell-nix does, and the reason why stack alone cannot give you a static binary (because it has no control over your system C libraries). An alternative is to do what you do (building with stack) in Alpine Linux (or a docker container thereof), which comes with musl as its system libc.

I tried to use an Alpine based image, but stack threw an error. I don't have the stack trace anymore but basically stack was unable to install GHC.

Download default.nix, and set the relevant variables for erd:

Should we add this file to the erd repository ?

Understood. Nix has a significant learning curve (though certainly easier than Haskell), but it is usually worth it because it gives full control over all dependencies (like using a different libc), and high reproducibility.

Thanks for the explanation. I was a bit confused with NixOS... I thought it was mandatory to use NixOS.

It will build and print /nix/store/5i3b3n7amd0yb9fx0zdrww95ancyy9iz-erd-0.2.0.0, which contains the desired static binary in the bin directory.

Is it possible to get a stable output (ie /nix/store/stable-identifier-erd-0.2.0.0)? Because I need to reference the path to copy the binary.

For convenience I've attached the binary built this way, so you can try out if it works before making any effort of building it yourself: erd-0.2.0.0.tar.gz

Thanks I will give it a try 👍

nh2 commented 4 years ago

Ok but I can install Nix on an Alpine image?

@Mogztter That's possible but the question may not make sense. You need either nix (on any OS, without Docker) or Alpine (for example in Docker) in order to get a musl-based build.

Should we add this file to the erd repository ?

Yes.

I was a bit confused with NixOS... I thought it was mandatory to use NixOS.

Ah I see. Indeed NixOS is not necessary. Only the nix build tool, and the nixpkgs repository of software, which you can run on any Linux distro.

I tried to use an Alpine based image, but stack threw an error. I don't have the stack trace anymore but basically stack was unable to install GHC.

Yes, there have been some problems with stack on Alpine with its GHC versions recently (https://github.com/commercialhaskell/stack/issues/2387). This was one of the reasons I made static-haskell-nix: To make reproducible static builds possible on any distro, without having to depend on whether a specific Linux distro's GHC setup is currently in good shape or not. (That's not to say Alpine isn't good -- I think it's great, but nixpkgs is much easier to override with a bit of declarative code than Alpine is.)

Is it possible to get a stable output

Yes: The nix build prints the path to stdout, and it's the only thing it prints to stdout. So you can do e.g.

cp $($(nix-build --no-link -A fullBuildScript))/bin/erd somewhere-else/erd

Thanks I will give it a try +1

Let me know if you encounter any issues :+1:

mmzx commented 4 years ago

@Mogztter the master just got updated with the descriptions and help from @nh2 in the form of a script. @nh2 Thanks, static-haskell-nix is quite nice!

mmzx commented 4 years ago

I am currently working on to put erd into stackage, but having some obstacles on the way.

akdor1154 commented 2 years ago

FWIW the following gives me a static binary (except for glibc) from current master:

FROM docker.io/haskell:8

WORKDIR /src

RUN cabal v2-update
RUN cabal v2-configure --enable-executable-static --enable-optimization=2
RUN cabal v2-build
RUN cabal v2-install --install-method=copy --overwrite-policy=always --installdir .

Run with

buildah bud \
    --volume "$(pwd)":"/src" \
    --volume "$(pwd)/.cabal":"/root/.cabal" \
    -t erd \
    .

EDIT: or better, because the container image is actually not needed here:

mkdir -p .cabal

podman run \
    --volume "$(pwd)":"/src" \
    --volume "$(pwd)/.cabal":"/root/.cabal" \
    --workdir /src \
    --interactive \
    --rm \
    docker.io/haskell:8 \
    sh <<EOF
cabal v2-update
cabal v2-configure --enable-executable-static --enable-optimization=2
cabal v2-build
cabal v2-install --install-method=copy --overwrite-policy=always --installdir .
EOF
ggrossetie commented 1 year ago

@mmzx I see that https://github.com/BurntSushi/erd/releases/tag/v0.2.1.0-RC1 has binaries attached. Would it be possible to do that for the current and next releases?

mmzx commented 1 year ago

@Mogztter Yes, should be possible. Will do the binaries over the weekend, stay tuned please.

mmzx commented 1 year ago

@Mogztter I've just created a PR to release a new version, it would be due anyway regardless static binary availability.

However, I have failed making the compiling work using static-haskell-nix. How would you - if ever that happened - otherwise create a statically linked executable?

Would you be fine using a docker container as an alternative?

ggrossetie commented 1 year ago

For now, we are using a Docker container to produce an executable:

https://github.com/yuzutech/kroki/blob/b7b102d074ace07ba6260378691088b88e04a032/server/ops/docker/jdk11-alpine/Dockerfile#L102-L122

Since we are using a tag, it would be better if the result was attached to a release. Currently, we are building it every time 😞

dduportal commented 1 year ago

We have the same requirement for the official asciidoctor Docker image which provides erd.

The recent upgrade to alpine 3.17 break the cabal install so we need to find another static binary. Would be useful to get static binaries on releases.

@mmzx I can help if you need some