commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 843 forks source link

stack setup w/ docker enabled fails on macOS Sierra #3105

Open bitemyapp opened 7 years ago

bitemyapp commented 7 years ago
Installing library in
/Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1
"utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" copy libraries/base dist-install "strip" '' '/Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2' '/Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2/lib/ghc-8.0.2' '/Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2/share/doc/ghc-8.0.2/html/libraries' 'v p dyn'
Installing library in
/Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2/lib/ghc-8.0.2/base-4.9.1.0
ghc.mk:981: recipe for target 'install_packages' failed
Makefile:51: recipe for target 'install' failed

strip:/Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2/lib/ghc-8.0.2/base-4.9.1.0/st9yHhmg/Typeable__6.o: Too many open files in system
make[1]: *** [install_packages] Error 1
make: *** [install] Error 2

Error: Error encountered while installing GHC with
         make install
         run in /Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2.temp/ghc-8.0.2/

The following directories may now contain files, but won't be used by stack:
  - /Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2.temp/
  - /Users/callen/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.0.2/

Installing GHC ...%

I bumped the open file limits with sysctl and a plist in launchctl. Any ideas?

bitemyapp commented 7 years ago

I only get this when running stack setup while the stack.yaml has:

docker:
  enable: true

I made sure to restart (new user session), came up with these limits:

$ ulimit -n
64000
$ sysctl kern.maxfiles
kern.maxfiles: 524288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 64000

Docker version:

$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true
borsboom commented 7 years ago

Not sure why you're seeing this, but keep in mind that Docker runs in a VM on macOS, so you may need to set these limits in the VM rather than on the macOS host.

bitemyapp commented 7 years ago

@borsboom I feel you, but this is stack setup on your own (stack-build) Docker container. Shouldn't that be part of the Docker container's image?

borsboom commented 7 years ago

I guess the question is whether the limit is being hit in the Docker container or on the Docker host (which, on macOS, is a VM). It's been some time since I've tried stack --docker setup, but it has definitely worked in the past.

bitemyapp commented 7 years ago

@borsboom The filesystem is stored as one big qcow2 disk image on the host Mac system. Bumping the limits on my host OS didn't fix it.

Changing my docker config in my stack.yaml to the following has unstuck me for now.

docker:
  enable: true
  image: "fpco/stack-build"
  set-user: true
  run-args: ["--ulimit=nofile=60000"]

I think including these run-args in the documentation would be a suitable remediation. What do you think?

bitemyapp commented 7 years ago

stack build under Docker is now failing with the -fPIC thing. Believe I've hit it before when running in native Ubuntu but I don't remember the fix.

    [ 2 of 16] Compiling Settings.StaticFiles ( src/Settings/StaticFiles.hs, .stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-1.24.2.0/build/Settings/StaticFiles.o )
    /usr/bin/ld: error: /usr/lib/gcc/x86_64-linux-gnu/5/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)

I then tried,

$ STACK_YAML=../stack.yaml stack build --ghc-options -fPIC

And got:

[ 1 of 16] Compiling Settings         ( src/Settings.hs, .stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-1.24.2.0/build/Settings.o ) [flags changed]
    <command line>: can't load .so/.DLL for:
/Users/callen/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/lts-8.4/8.0.2/lib/x86_64-linux-ghc-8.0.2/libHSrandom-1.1-9tceXaeYIMZ4JrKq20Egog-ghc8.0.2.so (/Users/callen/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/lts-8.4/8.0.2/lib/x86_64-linux-ghc-8.0.2/libHSrandom-1.1-9tceXaeYIMZ4JrKq20Egog-ghc8.0.2.so: 
undefined symbol: timezm1zi6zi0zi1_DataziTimeziClockziCTimespec_getCTimespec1_info)
bitemyapp commented 7 years ago

Yep, successful build. I think some cruft from some previous linker settings I was experimenting with broke it.

I nuked ~/.stack and .stack-work, reran the build, then it worked.

What are your feelings on mentioning the run-args in the Stack Docker documentation?

borsboom commented 7 years ago

I think mentioning it in the docs is definitely a good idea. I'm considering whether Stack should pass in that argument by default... not sure if there are cases where it would be undesirable.

bitemyapp commented 7 years ago

@borsboom I'd strongly recommend it as the defaults are highly unlikely to work with any typical GHC builds.

You could pick something more conservative, but the main risk I'm aware of is fd saturation causing slow down on the host due to imperfect isolation. This is a risk of using Docker regardless though.

swamp-agr commented 4 years ago

Sorry for interrogating this issue. I would prefer not to create duplicate for pretty the same case and similar error. Unless you ask me to move details into separate issue, of course.

Recently I started to observe similar experience (case and error), even with -fPIC enabled.

Here is (formatted) output of persistent linker error in one module with verbosity level 4:

*** Linker:
gcc -DTABLES_NEXT_TO_CODE '-fuse-ld=gold' -Wl,--no-as-needed -static -pthread -v -lm -o /tmp/ghc160_0/libghc_3.so \
.stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-3.0.1.0/build/Library/Module1.dyn_o \
.stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-3.0.1.0/build/Library/Module2.dyn_o \
.stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-3.0.1.0/build/Library/Module3.dyn_o \
-shared \
-Wl,-Bsymbolic \
-Wl,-h,libghc_3.so \
-L$HOME/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/8a0f1a681a80a9c6848dd87ee6cef4677d1fc20297ff1576c5c73ee112e1c487/8.8.3/lib/x86_64-linux-ghc-8.8.3 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/8a0f1a681a80a9c6848dd87ee6cef4677d1fc20297ff1576c5c73ee112e1c487/8.8.3/lib/x86_64-linux-ghc-8.8.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/parsec-3.1.14.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/parsec-3.1.14.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/haskeline-0.7.5.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/haskeline-0.7.5.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/terminfo-0.4.1.4 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/terminfo-0.4.1.4 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/process-1.6.8.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/process-1.6.8.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/directory-1.3.6.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/directory-1.3.6.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/filepath-1.4.2.1 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/filepath-1.4.2.1 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/mtl-2.2.2 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/mtl-2.2.2 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/stm-2.5.0.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/stm-2.5.0.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/unix-2.7.2.2 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/unix-2.7.2.2 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/text-1.2.4.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/text-1.2.4.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/binary-0.8.7.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/binary-0.8.7.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/bytestring-0.10.10.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/bytestring-0.10.10.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/transformers-0.5.6.2 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/transformers-0.5.6.2 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/template-haskell-2.15.0.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/template-haskell-2.15.0.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/pretty-1.1.3.6 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/pretty-1.1.3.6 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-boot-th-8.8.3 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-boot-th-8.8.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/time-1.9.3 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/time-1.9.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/containers-0.6.2.1 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/containers-0.6.2.1 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/deepseq-1.4.4.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/deepseq-1.4.4.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/array-0.5.4.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/array-0.5.4.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/base-4.13.0.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/base-4.13.0.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/integer-gmp-1.0.2.0 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/integer-gmp-1.0.2.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3 \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/rts \
-Xlinker \
-rpath \
-Xlinker \
$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/rts \
-lH ... **200+ dependencies left** ...
-lHStransformers-0.5.6.2-ghc8.8.3 \
-lHStemplate-haskell-2.15.0.0-ghc8.8.3 \
-lHSpretty-1.1.3.6-ghc8.8.3 \
-lHSghc-boot-th-8.8.3-ghc8.8.3 \
-lHSsplitmix-0.0.4-7560RX9wDw08Q8W750W2rw-ghc8.8.3 \
-lHSrandom-1.1-CUqV1zxrwrE4K5XCdTZSYy-ghc8.8.3 \
-lHStime-1.9.3-ghc8.8.3 \
-lHScontainers-0.6.2.1-ghc8.8.3 \
-lHSdeepseq-1.4.4.0-ghc8.8.3 \
-lHSarray-0.5.4.0-ghc8.8.3 \
-lHSbase-4.13.0.0-ghc8.8.3 \
-lHSinteger-gmp-1.0.2.0-ghc8.8.3 \
-lHSghc-prim-0.5.3-ghc8.8.3 \
-llzma \
-lz \
-ltinfo \
-lpthread \
-lrt \
-lutil \
-ldl \
-lpthread \
-lgmp
Using \
built-in \
specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured \
with: \
../src/configure \
-v \
--with-pkgversion='Ubuntu \
7.5.0-3ubuntu1~18.04' \
--with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs \
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ \
--prefix=/usr \
--with-gcc-major-version-only \
--program-suffix=-7 \
--program-prefix=x86_64-linux-gnu- \
--enable-shared \
--enable-linker-build-id \
--libexecdir=/usr/lib \
--without-included-gettext \
--enable-threads=posix \
--libdir=/usr/lib \
--enable-nls \
--enable-bootstrap \
--enable-clocale=gnu \
--enable-libstdcxx-debug \
--enable-libstdcxx-time=yes \
--with-default-libstdcxx-abi=new \
--enable-gnu-unique-object \
--disable-vtable-verify \
--enable-libmpx \
--enable-plugin \
--enable-default-pie \
--with-system-zlib \
--with-target-system-zlib \
--enable-objc-gc=auto \
--enable-multiarch \
--disable-werror \
--with-arch-32=i686 \
--with-abi=m64 \
--with-multilib-list=m32,m64,mx32 \
--enable-multilib \
--with-tune=generic \
--enable-offload-targets=nvptx-none \
--without-cuda-driver \
--enable-checking=release \
--build=x86_64-linux-gnu \
--host=x86_64-linux-gnu \
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-D' \
'TABLES_NEXT_TO_CODE' \
'-fuse-ld=gold' \
'-static' \
'-pthread' \
'-v' \
'-o' \
'/tmp/ghc160_0/libghc_3.so' \
'-shared' \
'-L$HOME/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/8a0f1a681a80a9c6848dd87ee6cef4677d1fc20297ff1576c5c73ee112e1c487/8.8.3/lib/x86_64-linux-ghc-8.8.3' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/parsec-3.1.14.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/haskeline-0.7.5.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/terminfo-0.4.1.4' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/process-1.6.8.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/directory-1.3.6.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/filepath-1.4.2.1' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/mtl-2.2.2' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/stm-2.5.0.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/unix-2.7.2.2' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/text-1.2.4.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/binary-0.8.7.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/bytestring-0.10.10.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/transformers-0.5.6.2' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/template-haskell-2.15.0.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/pretty-1.1.3.6' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-boot-th-8.8.3' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/time-1.9.3' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/containers-0.6.2.1' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/deepseq-1.4.4.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/array-0.5.4.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/base-4.13.0.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/integer-gmp-1.0.2.0' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3' \
'-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/rts' \
'-mtune=generic' \
'-march=x86-64'
 \
/usr/lib/gcc/x86_64-linux-gnu/7/collect2 \
-plugin \
/usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so \
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper \
-plugin-opt=-fresolution=/tmp/cc704g6R.res \
-plugin-opt=-pass-through=-lgcc \
-plugin-opt=-pass-through=-lgcc_eh \
-plugin-opt=-pass-through=-lpthread \
-plugin-opt=-pass-through=-lc \
--build-id \
-m \
elf_x86_64 \
--hash-style=gnu \
--as-needed \
-shared \
-fuse-ld=gold \
-z \
relro \
-o \
/tmp/ghc160_0/libghc_3.so \
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o \
/usr/lib/gcc/x86_64-linux-gnu/7/crtbeginT.o \
-L$HOME/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/8a0f1a681a80a9c6848dd87ee6cef4677d1fc20297ff1576c5c73ee112e1c487/8.8.3/lib/x86_64-linux-ghc-8.8.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/parsec-3.1.14.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/haskeline-0.7.5.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/terminfo-0.4.1.4 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/process-1.6.8.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/directory-1.3.6.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/filepath-1.4.2.1 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/mtl-2.2.2 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/stm-2.5.0.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/unix-2.7.2.2 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/text-1.2.4.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/binary-0.8.7.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/bytestring-0.10.10.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/transformers-0.5.6.2 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/template-haskell-2.15.0.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/pretty-1.1.3.6 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-boot-th-8.8.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/time-1.9.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/containers-0.6.2.1 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/deepseq-1.4.4.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/array-0.5.4.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/base-4.13.0.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/integer-gmp-1.0.2.0 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3 \
-L$HOME/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3/lib/ghc-8.8.3/rts \
-L/usr/lib/gcc/x86_64-linux-gnu/7 \
-L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu \
-L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib \
-L/lib/x86_64-linux-gnu \
-L/lib/../lib \
-L/usr/lib/x86_64-linux-gnu \
-L/usr/lib/../lib \
-L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. \
@/tmp/ccVyHkvE \
--start-group \
-lgcc \
-lgcc_eh \
-lpthread \
-lc \
--end-group \
/usr/lib/gcc/x86_64-linux-gnu/7/crtend.o \
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/7/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
*** Deleting temp files:
Deleting: /tmp/ghc160_0/ghc_4.rsp /tmp/ghc160_0/libghc_3.so /tmp/ghc160_0/ghc_1.hscpp
Warning: deleting non-existent /tmp/ghc160_0/libghc_3.so
*** Deleting temp dirs:
Deleting: /tmp/ghc160_0
`gcc' failed in phase `Linker'. (Exit code: 1)

One single clue I can see:

Please, advise how to debug issue further to understand what exactly causes it in linker and how and where (on which side) it could be resolved.