I tried running ghc to compile a haskell program, and I get the following error:
$ ghc --make main
Linking main ...
ld: building for macOS, but linking in object file built for iOS Simulator, file 'main.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`clang' failed in phase `Linker'. (Exit code: 1)
Here are some details about my machine:
macOS Catalina 10.15.7
Xcode 12.2
The Xcode developer tools were installed with xcode-select --install
I installed ghc with brew install ghc
Some other output that might be relevant:
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
If I run ghc --make main -v, this is what the output looks like right before it fails (apologies for the long line, not sure how to format this better):
clang -o main -fno-common -U__PIC__ -D__PIC__ -Wl,-no_compact_unwind main.o -L/usr/local/Cellar/ghc/8.10.1_2/lib/ghc-8.10.1/base-4.14.0.0 -L/usr/local/Cellar/ghc/8.10.1_2/lib/ghc-8.10.1/integer-gmp-1.0.3.0 -L/usr/local/Cellar/ghc/8.10.1_2/libexec/integer-gmp/lib -L/usr/local/Cellar/ghc/8.10.1_2/lib/ghc-8.10.1/ghc-prim-0.6.1 -L/usr/local/Cellar/ghc/8.10.1_2/lib/ghc-8.10.1/rts /var/folders/5j/wwtlv8lx0m5fmhc3hy5w5_000000gp/T/ghc49162_0/ghc_2.o -Wl,-u,_base_GHCziTopHandler_runIO_closure -Wl,-u,_base_GHCziTopHandler_runNonIO_closure -Wl,-u,_ghczmprim_GHCziTuple_Z0T_closure -Wl,-u,_ghczmprim_GHCziTypes_True_closure -Wl,-u,_ghczmprim_GHCziTypes_False_closure -Wl,-u,_base_GHCziPack_unpackCString_closure -Wl,-u,_base_GHCziWeak_runFinalizzerBatch_closure -Wl,-u,_base_GHCziIOziException_stackOverflow_closure -Wl,-u,_base_GHCziIOziException_heapOverflow_closure -Wl,-u,_base_GHCziIOziException_allocationLimitExceeded_closure -Wl,-u,_base_GHCziIOziException_blockedIndefinitelyOnMVar_closure -Wl,-u,_base_GHCziIOziException_blockedIndefinitelyOnSTM_closure -Wl,-u,_base_GHCziIOziException_cannotCompactFunction_closure -Wl,-u,_base_GHCziIOziException_cannotCompactPinned_closure -Wl,-u,_base_GHCziIOziException_cannotCompactMutable_closure -Wl,-u,_base_ControlziExceptionziBase_absentSumFieldError_closure -Wl,-u,_base_ControlziExceptionziBase_nonTermination_closure -Wl,-u,_base_ControlziExceptionziBase_nestedAtomically_closure -Wl,-u,_base_GHCziEventziThread_blockedOnBadFD_closure -Wl,-u,_base_GHCziConcziSync_runSparks_closure -Wl,-u,_base_GHCziConcziIO_ensureIOManagerIsRunning_closure -Wl,-u,_base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure -Wl,-u,_base_GHCziConcziSignal_runHandlersPtr_closure -Wl,-u,_base_GHCziTopHandler_flushStdHandles_closure -Wl,-u,_base_GHCziTopHandler_runMainIO_closure -Wl,-u,_ghczmprim_GHCziTypes_Czh_con_info -Wl,-u,_ghczmprim_GHCziTypes_Izh_con_info -Wl,-u,_ghczmprim_GHCziTypes_Fzh_con_info -Wl,-u,_ghczmprim_GHCziTypes_Dzh_con_info -Wl,-u,_ghczmprim_GHCziTypes_Wzh_con_info -Wl,-u,_base_GHCziPtr_Ptr_con_info -Wl,-u,_base_GHCziPtr_FunPtr_con_info -Wl,-u,_base_GHCziInt_I8zh_con_info -Wl,-u,_base_GHCziInt_I16zh_con_info -Wl,-u,_base_GHCziInt_I32zh_con_info -Wl,-u,_base_GHCziInt_I64zh_con_info -Wl,-u,_base_GHCziWord_W8zh_con_info -Wl,-u,_base_GHCziWord_W16zh_con_info -Wl,-u,_base_GHCziWord_W32zh_con_info -Wl,-u,_base_GHCziWord_W64zh_con_info -Wl,-u,_base_GHCziStable_StablePtr_con_info -Wl,-u,_hs_atomic_add8 -Wl,-u,_hs_atomic_add16 -Wl,-u,_hs_atomic_add32 -Wl,-u,_hs_atomic_add64 -Wl,-u,_hs_atomic_sub8 -Wl,-u,_hs_atomic_sub16 -Wl,-u,_hs_atomic_sub32 -Wl,-u,_hs_atomic_sub64 -Wl,-u,_hs_atomic_and8 -Wl,-u,_hs_atomic_and16 -Wl,-u,_hs_atomic_and32 -Wl,-u,_hs_atomic_and64 -Wl,-u,_hs_atomic_nand8 -Wl,-u,_hs_atomic_nand16 -Wl,-u,_hs_atomic_nand32 -Wl,-u,_hs_atomic_nand64 -Wl,-u,_hs_atomic_or8 -Wl,-u,_hs_atomic_or16 -Wl,-u,_hs_atomic_or32 -Wl,-u,_hs_atomic_or64 -Wl,-u,_hs_atomic_xor8 -Wl,-u,_hs_atomic_xor16 -Wl,-u,_hs_atomic_xor32 -Wl,-u,_hs_atomic_xor64 -Wl,-u,_hs_cmpxchg8 -Wl,-u,_hs_cmpxchg16 -Wl,-u,_hs_cmpxchg32 -Wl,-u,_hs_cmpxchg64 -Wl,-u,_hs_atomicread8 -Wl,-u,_hs_atomicread16 -Wl,-u,_hs_atomicread32 -Wl,-u,_hs_atomicread64 -Wl,-u,_hs_atomicwrite8 -Wl,-u,_hs_atomicwrite16 -Wl,-u,_hs_atomicwrite32 -Wl,-u,_hs_atomicwrite64 -Wl,-search_paths_first -Wl,-dead_strip -lHSbase-4.14.0.0 -lHSinteger-gmp-1.0.3.0 -lHSghc-prim-0.6.1 -lHSrts -lCffi -liconv -lgmp -lm -ldl -Wl,-dead_strip_dylibs
ld: building for macOS, but linking in object file built for iOS Simulator, file 'main.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I would like to start developing for web using yesod framework.
But I can not install yesod.
I'm following the steps suggested:
stack new my-project yesod-sqlite
cd my-project
stack install yesod-bin --install-ghc
But the "stack install yesod-bin --install-ghc" command gives me the following output:
clock-0.7.2: configure
clock-0.7.2: build
basement-0.0.4: configure
file-embed-0.0.10.1: download
hourglass-0.2.10: download
basement-0.0.4: build
file-embed-0.0.10.1: configure
file-embed-0.0.10.1: build
hourglass-0.2.10: configure
hourglass-0.2.10: build
file-embed-0.0.10.1: copy/register
hourglass-0.2.10: copy/register
Progress: 4/93
-- While building custom Setup.hs for package basement-0.0.4 using:
/home/mbaroni/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/mbaroni/Computacao/prog/yesod-project/.stack-work/logs/basement-0.0.4.log
Configuring basement-0.0.4...
Preprocessing library for basement-0.0.4..
/usr/bin/ld.gold: error: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Basement/Terminal/Size_hsc_make.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC
/usr/bin/ld.gold: error: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Basement/Terminal/Size_hsc_utils.o: requires dynamic R_X86_64_PC32 reloc against 'vprintf' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
linking .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Basement/Terminal/Size_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Basement/Terminal/Size_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Basement/Terminal/Size_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Basement/Terminal/Size_hsc_make -fuse-ld=gold -fno-PIE -fno-stack-protector -fuse-ld=gold -L/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/base-4.10.1.0 -Wl,-R,/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/base-4.10.1.0 -L/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0 -Wl,-R,/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0 -lgmp -L/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1 -Wl,-R,/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1 -L/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/rts -Wl,-R,/home/mbaroni/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/rts -lm -lrt -ldl -lpthread
Any idea about what could be the cause of the problem would be greatly appreciated.
My environment:
stack --version
Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0
ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2
uname -a
Linux mbaroni 4.12.13-1-ARCH #1 SMP PREEMPT Fri Sep 15 06:36:43 UTC 2017 x86_64 GNU/Linux
Thanks for helping!
I finally figured out what was the problem and I was able to solve it in my environment.
Reason
It seems that GCC enabled PIE (Position Independent Executable) by default and stack (which uses GCC in the back) does not expect this, causing the reported problem at linking stage (source).
Solution
As suggested here the solution was to configure stack to pass gcc the right flags to correct this.
This is done editing the file "~/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.1/lib/ghc-8.0.1/settings" in my case.
I had to modify the configuration of 3 lines as follows:
...
("C compiler flags", "-fno-PIE -fno-stack-protector -fPIC"),
("C compiler link flags", "-no-pie -fuse-ld=gold"),
("C compiler supports -no-pie", "YES"),
...
Best.
I'm trying to install tidal cycles via stack using stack install tidal.
Installation went smooth for the first couple dependencies but now I'm getting this.
04:24 ~ stack install tidal
mersenne-random-pure64-0.2.2.0: configure
mersenne-random-pure64-0.2.2.0: build
network-2.6.3.2: configure
zlib-0.6.1.2: configure
zlib-0.6.1.2: build
Progress: 3/7
-- While building custom Setup.hs for package zlib-0.6.1.2 using:
/home/mn/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/mn/.stack/global-project/.stack-work/logs/zlib-0.6.1.2.log
Configuring zlib-0.6.1.2...
Preprocessing library for zlib-0.6.1.2..
/usr/bin/ld.gold: error: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Codec/Compression/Zlib/Stream_hsc_make.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC
/usr/bin/ld.gold: error: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Codec/Compression/Zlib/Stream_hsc_utils.o: requires dynamic R_X86_64_PC32 reloc against 'vprintf' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
linking .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Codec/Compression/Zlib/Stream_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Codec/Compression/Zlib/Stream_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Codec/Compression/Zlib/Stream_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/Codec/Compression/Zlib/Stream_hsc_make -fuse-ld=gold -fno-PIE -fno-stack-protector -fuse-ld=gold -lz -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/bytestring-0.10.8.2 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/bytestring-0.10.8.2 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/deepseq-1.4.3.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/deepseq-1.4.3.0 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/array-0.5.2.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/array-0.5.2.0 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/base-4.10.1.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/base-4.10.1.0 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0 -lgmp -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/rts -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/rts -lm -lrt -ldl -lpthread
-- While building custom Setup.hs for package network-2.6.3.2 using:
/tmp/stack17553/network-2.6.3.2/.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/setup/setup --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0 configure --with-ghc=/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/bin/ghc --with-ghc-pkg=/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/bin/ghc-pkg --user --package-db=clear --package-db=global --package-db=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/pkgdb --libdir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/lib --bindir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/bin --datadir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/share --libexecdir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/libexec --sysconfdir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/etc --docdir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/doc/network-2.6.3.2 --htmldir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/doc/network-2.6.3.2 --haddockdir=/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/doc/network-2.6.3.2 --dependency=base=base-4.10.1.0 --dependency=bytestring=bytestring-0.10.8.2 --dependency=unix=unix-2.7.2.2
Process exited with code: ExitFailure 1
Logs have been written to: /home/mn/.stack/global-project/.stack-work/logs/network-2.6.3.2.log
[1 of 2] Compiling Main ( /tmp/stack17553/network-2.6.3.2/Setup.hs, /tmp/stack17553/network-2.6.3.2/.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /home/mn/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /tmp/stack17553/network-2.6.3.2/.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/setup/StackSetupShim.o )
Linking /tmp/stack17553/network-2.6.3.2/.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/setup/setup ...
Configuring network-2.6.3.2...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/tmp/stack17553/network-2.6.3.2':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
-- While building custom Setup.hs for package mersenne-random-pure64-0.2.2.0 using:
/home/mn/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/mn/.stack/global-project/.stack-work/logs/mersenne-random-pure64-0.2.2.0.log
Configuring mersenne-random-pure64-0.2.2.0...
Preprocessing library for mersenne-random-pure64-0.2.2.0..
/usr/bin/ld.gold: error: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/System/Random/Mersenne/Pure64/Base_hsc_make.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC
/usr/bin/ld.gold: error: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/System/Random/Mersenne/Pure64/Base_hsc_utils.o: requires dynamic R_X86_64_PC32 reloc against 'vfprintf' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
linking .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/System/Random/Mersenne/Pure64/Base_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/System/Random/Mersenne/Pure64/Base_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/System/Random/Mersenne/Pure64/Base_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0/build/System/Random/Mersenne/Pure64/Base_hsc_make -fuse-ld=gold -fno-PIE -fno-stack-protector -fuse-ld=gold -L/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/lib/x86_64-linux-ghc-8.2.2/random-1.1-LLUGZ7T9DqQ5vN0Jbcd0We -Wl,-R,/home/mn/.stack/snapshots/x86_64-linux-tinfo6-nopie/lts-10.0/8.2.2/lib/x86_64-linux-ghc-8.2.2/random-1.1-LLUGZ7T9DqQ5vN0Jbcd0We -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/time-1.8.0.2 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/time-1.8.0.2 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/deepseq-1.4.3.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/deepseq-1.4.3.0 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/array-0.5.2.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/array-0.5.2.0 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/base-4.10.1.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/base-4.10.1.0 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0 -lgmp -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1 -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1 -L/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/rts -Wl,-R,/home/mn/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/rts -lm -lrt -ldl -lpthread
✘ 04:24 ~
Googled a little and found a few things, tried a few things but none worked, I'm lost.
Any help is appreciated, thanks.
I'm guessing you're using Arch Linux.
I'm in the middle of trying to come up with a comprehensive fix for this and related problems in stack setup, but I believe the simplest course of action is to add this to your ~/.stack/config.yaml:
ghc-build: tinfo6
You may need to run stack setup --reinstall to force a re-install.
While I run snmpd daemon on powerpc board(a.p.) I am getting this error:
R_PPC_REL24: Compile shared libraries with -fPIC!
/usr/local/sbin/snmpd: symbol 'strlen': can't handle reloc type 0xa in lib
/lib/libnetsnmpmibs.so.15'
sh: you need to specify whom to kill
I googled and found that the -fPIC flag should be there while compiling and its place should be right after gcc, so I changed my Makefie accordingly. Here is a snippet of my makefile:
$(Q)cd $(PROJECT_BUILD_DIR)/$(NET_SNMP_PKG) && ./configure --target=$(TARGET_TRIPLET) \
--host=$(HOST_TRIPLET) \
--build=$(BUILD_TRIPLET) \
--with-cc="$(CR_COMPLR)gcc -fPIC" \`
--with-cflags="-Os -I$(RFS)/lib -I$(NMS_DIR)/include" \`
--with-linkcc="$(CR_COMPLR)gcc -fPIC" \`
As you can see I embedded -fPIC right after gcc, but I am still getting an error. I have cross compiled for powerpc platform and I am using latest buildroot-2011.11 and gcc 4.3.6 and uClibc version 0.9.32. What may be the cause of error?
P.S. When I do nm libnetsnmpmibs.so.15 | grep strlen then I get output as U strlen. Does this mean it is undefined?
I got the problem. actually the main thing is to compile with -fPIC only.
In my case I was compiling snmp libraries with -fPIC correctly but some of the functions were dependent on libraries of other packages (nms). As I am working on firmware development there are more than 20 packages involved. So I compiled nms libraries with -fPIC and error is resolved.
I'm trying to install GHC with -fPIC support in Fedora.
I've grabbed a source tarball since it seems no binary one has this.
In Build.mk i've changed the quick build type to
ifeq "$(BuildFlavour)" "quick"
SRC_HC_OPTS = -H64m -O0 -fasm -fPIC
GhcStage1HcOpts = -O -fasm -fPIC
GhcStage2HcOpts = -O0 -fasm -fPIC
GhcLibHcOpts = -O -fasm -fPIC
SplitObjs = NO
HADDOCK_DOCS = NO
BUILD_DOCBOOK_HTML = NO
BUILD_DOCBOOK_PS = NO
BUILD_DOCBOOK_PDF = NO
endif
unfortunately, when compiling i still get the ld error
ghc -fglasgow-exts --make -shared -oHs2lib.a /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno-warn-deprecated-flags -O2 -package ghc -package Hs2lib -i/home/phyx/Documents/Haskell/Hs2lib -optl-Wl,-s -funfolding-use-threshold=16 -optc-O3 -optc-ffast-math
Linking a.out ...
/usr/bin/ld: /tmp/Hs2lib924498/Hs2lib.o: relocation R_X86_64_32 against `ghczmprim_GHCziUnit_Z0T_closure' can not be used when making a shared object; recompile with -fPIC
/tmp/Hs2lib924498/Hs2lib.o: could not read symbols: Bad value
So it seems that GHC-prim still isn't compiled with -FPIC
I've also told cabal to build any packages with -fPIC and shared.
Anyone have any ideas?
EDIT:
Thanks to dcouts I've been able to make some progress. But now i'm at the point where I thnk libffi isn't compiled with -fPIC. I've edited the makefile(.in) for it but so far, no luck.
The new command is:
ghc -fPIC -shared dllmain.o Hs2lib.o /usr/local/lib/ghc-7.0.3/libHSrts.a -o Hs2lib.so
where dllmain.c and Hs2lib.hs have both been compiled using -fPIC.
The error I get is:
/usr/bin/ld: /usr/local/lib/ghc-7.0.3/libHSffi.a(closures.o): relocation R_X86_64_32
against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/ghc-7.0.3/libHSffi.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
After you see this error, do the following:
cd /tmp/Hs2lib924498/
ghc -fglasgow-exts --make -shared -oHs2lib.a /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno-warn-deprecated-flags -fPIC -O2 -package ghc -package Hs2lib -i/home/phyx/Documents/Haskell/Hs2lib -optl-Wl,-s -funfolding-use-threshold=16 -optc-O3 -optc-ffast-math
Note I added -fPIC to the failed ghc command.
Once the command succeeds, continue the compilation from within the tmp directory without cleaning already compiled files. It should skip them and continue where it ended.
There's an FAQ entry on this topic on the Haskell Stack page.
It basically says the problem is environment related and sometimes non-deterministic.
The issue may be related to the use of hardening flags in some cases, specifically those related to producing position independent executables (PIE).
There's also a work around suggestion for Arch Linux:
On Arch Linux, installing the ncurses5-compat-libs package from AUR resolves this issue.