Open
Description
General summary/comments
Recent ArchLinux ships system GHC without static libraries at all. Even without static versions of ghc builtin libraries.
Can I use this ghc with Stack?
The problem is that even Setup.hs
needs -dynamic
.
Steps to reproduce
- Run
stack new simple
- Add
-dynamic
to thesimple-exe
target - Run
stack build
Expected
- Setup executable is dynamically linked to
libHSCabal-1.24.2.0-ghc8.0.2.so
and so on. simple-exe
executable is dynamically linked tolibHSsimple-0.1.0.0-5DX8evVT2MQPefjCl7ERW-ghc8.0.2.so
Actual
stack build
fails at setup-exe-cache linker stage, unable to find dynamic libraries:
[foo@arch stack-test]$ ~/.local/bin/stack build --verbose
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) i386 hpack-0.17.1
2017-09-02 23:02:00.449671: [debug] Checking for project config at: /home/foo/dev/stack-test/stack.yaml
@(Stack/Config.hs:974:9)
2017-09-02 23:02:00.450138: [debug] Loading project config file stack.yaml
@(Stack/Config.hs:999:13)
2017-09-02 23:02:00.456979: [debug] Trying to decode /home/foo/.stack/build-plan-cache/i386-linux/lts-9.2.cache
@(Data/Store/VersionTagged.hs:72:5)
2017-09-02 23:02:00.480637: [debug] Success decoding /home/foo/.stack/build-plan-cache/i386-linux/lts-9.2.cache
@(Data/Store/VersionTagged.hs:76:13)
2017-09-02 23:02:00.481557: [debug] Getting system compiler version
@(Stack/Setup.hs:379:17)
2017-09-02 23:02:00.482149: [debug] Run process: /usr/bin/ghc --info
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.560287: [debug] Process finished in 77ms: /usr/bin/ghc --info
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.570574: [debug] Getting global package database location
@(Stack/GhcPkg.hs:55:5)
2017-09-02 23:02:00.571133: [debug] Asking GHC for its version
@(Stack/Setup/Installed.hs:103:13)
2017-09-02 23:02:00.571526: [debug] Getting Cabal package version
@(Stack/GhcPkg.hs:189:5)
2017-09-02 23:02:00.571778: [debug] Run process: /usr/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.572470: [debug] Run process: /usr/bin/ghc --numeric-version
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.573957: [debug] Run process: /usr/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.650533: [debug] Process finished in 76ms: /usr/bin/ghc --numeric-version
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.670339: [debug] Process finished in 98ms: /usr/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.703184: [debug] Process finished in 128ms: /usr/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.703547: [debug] Resolving package entries
@(Stack/Setup.hs:260:5)
2017-09-02 23:02:00.704146: [debug] Starting to execute command inside EnvConfig
@(Stack/Runners.hs:175:18)
2017-09-02 23:02:00.704362: [debug] Parsing the cabal files of the local packages
@(Stack/Build/Source.hs:328:5)
2017-09-02 23:02:00.706213: [debug] Parsing the targets
@(Stack/Build/Source.hs:265:5)
2017-09-02 23:02:00.706585: [debug] Exception ignored when attempting to load /home/foo/dev/stack-test/.stack-work/dist/i386-linux/Cabal-1.24.2.0/stack-build-cache: /home/foo/dev/stack-test/.stack-work/dist/i386-linux/Cabal-1.24.2.0/stack-build-cache: openBinaryFile: does not exist (No such file or directory)
@(Data/Store/VersionTagged.hs:90:9)
2017-09-02 23:02:00.706917: [debug] Start: getPackageFiles /home/foo/dev/stack-test/setup-depends.cabal
@(Stack/Package.hs:259:21)
2017-09-02 23:02:00.709374: [debug] Finished in 2ms: getPackageFiles /home/foo/dev/stack-test/setup-depends.cabal
@(Stack/Package.hs:259:21)
2017-09-02 23:02:00.710438: [debug] Finding out which packages are already installed
@(Stack/Build/Installed.hs:69:5)
2017-09-02 23:02:00.710864: [debug] Run process: /usr/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.820944: [debug] Process finished in 109ms: /usr/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.846849: [debug] Ignoring package haskeline due to wanting version 0.7.4.0 instead of 0.7.3.0
@(Stack/Build/Installed.hs:199:5)
2017-09-02 23:02:00.847374: [debug] Ignoring package xhtml due to wanting version 3000.2.2 instead of 3000.2.1
@(Stack/Build/Installed.hs:199:5)
2017-09-02 23:02:00.847687: [debug] Ignoring package terminfo due to wanting version 0.4.1.0 instead of 0.4.0.2
@(Stack/Build/Installed.hs:199:5)
2017-09-02 23:02:00.848002: [debug] Run process: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/foo/.stack/snapshots/i386-linux/lts-9.2/8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.937985: [debug] Process finished in 89ms: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/foo/.stack/snapshots/i386-linux/lts-9.2/8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:00.938420: [debug] Run process: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/foo/dev/stack-test/.stack-work/install/i386-linux/lts-9.2/8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:01.030095: [debug] Process finished in 91ms: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/foo/dev/stack-test/.stack-work/install/i386-linux/lts-9.2/8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-09-02 23:02:01.030953: [debug] Trying to decode /home/foo/.stack/indices/Hackage/01-index.cache
@(Data/Store/VersionTagged.hs:72:5)
2017-09-02 23:02:01.351467: [debug] Success decoding /home/foo/.stack/indices/Hackage/01-index.cache
@(Data/Store/VersionTagged.hs:76:13)
2017-09-02 23:02:01.379778: [debug] Constructing the build plan
@(Stack/Build/ConstructPlan.hs:188:5)
2017-09-02 23:02:01.387945: [debug] Checking if we are going to build multiple executables with the same name
@(Stack/Build.hs:210:5)
2017-09-02 23:02:01.388381: [debug] Executing the build plan
@(Stack/Build/Execute.hs:478:5)
2017-09-02 23:02:01.390216: [debug] Creating process: /usr/bin/ghc -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-1.24.2.0 /home/foo/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/foo/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/foo/.stack/setup-exe-cache/i386-linux/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2
@(System/Process/Run.hs:102:5)
Linking /home/foo/.stack/setup-exe-cache/i386-linux/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 ...
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/usr/bin/ld: cannot find -lHSbase-4.9.1.0
/usr/bin/ld: cannot find -lHSinteger-gmp-1.0.0.1
/usr/bin/ld: cannot find -lHSghc-prim-0.5.0.0
/usr/bin/ld: cannot find -lHSrts_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
2017-09-02 23:02:01.940916: [error] Exit code ExitFailure 1 while running ["ghc","-rtsopts","-threaded","-clear-package-db","-global-package-db","-hide-all-packages","-package","base","-main-is","StackSetupShim.mainOverride","-package","Cabal-1.24.2.0","/home/foo/.stack/setup-exe-src/setup-mPHDZzAJ.hs","/home/foo/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs","-o","/home/foo/.stack/setup-exe-cache/i386-linux/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2"] in /tmp/stack7830/
@(System/Process/Run.hs:70:13)
Note that I can copy the long command line from Creating process:
log line and create a dynamically linked Setup by appending -dynamic
option.
And in case of the simple
project I can then use Setup build
to build a dynamically linked simple-exe
.
But in case of more complex projects it obviously doesn't work as Setup build
doesn't install dependencies.
Stack version
$ ~/.local/bin/stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) i386 hpack-0.17.1
Method of installation
- Official binary, downloaded from stackage.org or fpcomplete's package repository (upgraded by an older version to
.local/bin
)