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)
When I did build my first actix-web test I found below error:
error: failed to run custom build command for brotli-sys v0.3.2
How to solve?
My system properties:
OS Name Microsoft Windows 10 Pro
Version 10.0.18363 Build 18363
System Type x64-based PC
Installed Physical Memory (RAM) 6.00 GB
Terminal:
PS C:\Users\Administrator\dev\rust_Lab\hello-world-actix> cargo run
Compiling cfg-if v0.1.10
Compiling lazy_static v1.4.0
Compiling futures-core v0.3.5
Compiling slab v0.4.2
Compiling futures-sink v0.3.5
Compiling winapi v0.2.8
Compiling bytes v0.5.6
Compiling once_cell v1.4.1
Compiling iovec v0.1.4
Compiling pin-project-lite v0.1.7
Compiling futures-io v0.3.5
Compiling pin-utils v0.1.0
Compiling smallvec v1.4.2
Compiling scopeguard v1.1.0
Compiling matches v0.1.8
Compiling tinyvec v0.3.4
Compiling copyless v0.1.5
Compiling adler v0.2.3
Compiling itoa v0.4.6
Compiling percent-encoding v2.1.0
Compiling either v1.6.1
Compiling ppv-lite86 v0.2.9
Compiling gimli v0.22.0
Compiling fnv v1.0.7
Compiling match_cfg v0.1.0
Compiling rustc-demangle v0.1.16
Compiling object v0.20.0
Compiling quick-error v1.2.3
Compiling widestring v0.4.2
Compiling linked-hash-map v0.5.3
Compiling regex-syntax v0.6.18
Compiling hashbrown v0.9.0
Compiling cpuid-bool v0.1.2
Compiling dtoa v0.4.6
Compiling opaque-debug v0.3.0
Compiling base64 v0.12.3
Compiling mio-uds v0.6.8
Compiling mime v0.3.16
Compiling language-tags v0.2.2
Compiling instant v0.1.7
Compiling tracing-core v0.1.16
Compiling thread_local v1.0.1
Compiling futures-channel v0.3.5
Compiling futures-task v0.3.5
Compiling bytestring v0.1.5
Compiling lock_api v0.4.1
Compiling unicode-bidi v0.3.4
Compiling unicode-normalization v0.1.13
Compiling http v0.2.1
Compiling lru-cache v0.1.2
Compiling addr2line v0.13.0
Compiling winapi v0.3.9
Compiling memchr v2.3.3
Compiling log v0.4.11
Compiling libc v0.2.77
Compiling proc-macro-nested v0.1.6
Compiling bitflags v1.2.1
Compiling getrandom v0.1.15
Compiling typenum v1.12.0
Compiling idna v0.2.0
Compiling brotli-sys v0.3.2
error: failed to run custom build command for `brotli-sys v0.3.2`
Caused by:
process didn't exit successfully: `C:\Users\Administrator\dev\rust_Lab\hello-world-actix\target\debug\build\brotli-sys-c17dbe422e853792\build-script-build` (exit code: 1)
--- stdout
cargo:include=C:\Users\Administrator\.cargo\registry\src\github.com-1ecc6299db9ec823\brotli-sys-0.3.2\brotli/include
TARGET = Some("x86_64-pc-windows-msvc")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-pc-windows-msvc")
CC_x86_64-pc-windows-msvc = None
CC_x86_64_pc_windows_msvc = None
HOST_CC = None
CC = None
CFLAGS_x86_64-pc-windows-msvc = None
CFLAGS_x86_64_pc_windows_msvc = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
DEBUG = Some("true")
running: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "brotli/include" "-FoC:\\Users\\Administrator\\dev\\rust_Lab\\hello-world-actix\\target\\debug\\build\\brotli-sys-924a6a49d6a39ff4\\out\\brotli/common/dictionary.o" "-c" "brotli/common/dictionary.c"
dictionary.c
brotli/common/dictionary.c: fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\p0io.c', line 2739)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
exit code: 2
--- stderr
fatal: not a git repository (or any of the parent directories): .git
error occurred: Command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "brotli/include" "-FoC:\\Users\\Administrator\\dev\\rust_Lab\\hello-world-actix\\target\\debug\\build\\brotli-sys-924a6a49d6a39ff4\\out\\brotli/common/dictionary.o" "-c" "brotli/common/dictionary.c" with args "cl.exe" did not execute successfully (status code exit code: 2).
warning: build failed, waiting for other jobs to finish...
error: build failed
After some research, I did found a solution for this error.
Issue resolved by disable "Beta: Use Unicode UTF-8 for worldwide language support" in Region Settings.
This hinted as per fatal error C1001: An internal error has occurred in the compiler. 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\p0io.c' , as per https://superuser.com/questions/1033088/is-it-possible-to-set-locale-of-a-windows-application-to-utf-8/1451686#1451686.
I am new to haskell. I have the simplest of simple programs.
#!/usr/bin/env stack
-- stack --resolver lts-13.7 script
module Main where
import Lib
main :: IO ()
main = putStrLn "Hello World"
It does work for stack
$stack ./Main.hs
Hello World
(base) 19:48:11/app $
But it suffers a rather gruesome demise on anything more extravagent:
$stack build --test --haddock --no-haddock-hyperlink-source;
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
[1 of 2] Compiling Main ( /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 ...
ld64.lld: warning: ignoring unknown argument: --gc-sections
ld64.lld: warning: ignoring unknown argument: -u
(maybe 50 of these ..)
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command. Setting sdk version to match provided min version
Cannot open /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=21c, r1_type=5, r1_extern=1, r1_length=2, r1_pcrel=0, r1_symbolnum=37), (r2_address=21c, r2_type=0, r2_extern=1, r2_length=2, r2_pcrel=0, r2_symbolnum=30)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
-- While building simple Setup.hs using:
/Users/steve/.stack/programs/x86_64-osx/ghc-8.8.3/bin/ghc-8.8.3 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.0.1.0 /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3
Process exited with code: ExitFailure 1
I tried searching for these but did not run into obvious matches/solutions. Tips?
Update haskell and stack were installed as such:
brew install haskell-stack
Another update I am trying to navigate to install from the haskell platform.
The asker is not off in left field but instead following the directions provided by the Haskell platform https://www.haskell.org/platform/
There is no download link there so we resort to googling for download ghcup which leads us to https://www.haskell.org/ghcup/
Then running the command
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
The result is:
$curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
This did install ghcup correctly
$ghcup
ghcup 0.0.8
GHC up toolchain installer
USAGE:
ghcup [FLAGS] <SUBCOMMAND>
Next in line: cabal. Google search led me to: https://hackage.haskell.org/package/cabal-install
I downloaded the cabal-install tarball https://hackage.haskell.org/package/cabal-install-3.2.0.0/cabal-install-3.2.0.0.tar.gz
This one was not so cooperative. The short version of the errors is:
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command. Setting sdk version to match provided min version
Cannot open ./Distribution/Compat/Async.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=2338, r1_type=5, r1_extern=1, r1_length=3, r1_pcrel=0, r1_symbolnum=243), (r2_address=2338, r2_type=0, r2_extern=1, r2_length=3, r2_pcrel=0, r2_symbolnum=237)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
Error during cabal-install bootstrap:
Compiling the Setup script failed.
Full version of errors is:
$./bootstrap.sh
mktemp: illegal option -- p
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
mktemp [-d] [-q] [-u] -t prefix
Using gcc for C compiler. If this is not what you want, set CC.
Using /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld instead.
Checking installed packages for ghc-8.8.3...
deepseq is already installed and the version is ok.
binary is already installed and the version is ok.
time is already installed and the version is ok.
transformers is already installed and the version is ok.
mtl is already installed and the version is ok.
text is already installed and the version is ok.
parsec is already installed and the version is ok.
network-uri-2.6.1.0 will be downloaded and installed.
network-2.7.0.0 will be downloaded and installed.
HTTP-4000.3.12 will be downloaded and installed.
zlib-0.6.2 will be downloaded and installed.
random-1.1 will be downloaded and installed.
stm is already installed and the version is ok.
hashable-1.2.7.0 will be downloaded and installed.
async-2.2.1 will be downloaded and installed.
base16-bytestring-0.1.1.6 will be downloaded and installed.
base64-bytestring-1.0.0.1 will be downloaded and installed.
cryptohash-sha256-0.11.101.0 will be downloaded and installed.
resolv-0.1.1.1 will be downloaded and installed.
mintty-0.1.2 will be downloaded and installed.
echo-0.1.3 will be downloaded and installed.
edit-distance-0.2.2.1 will be downloaded and installed.
ed25519-0.0.5.0 will be downloaded and installed.
tar-0.5.1.0 will be downloaded and installed.
digest-0.0.1.2 will be downloaded and installed.
lukko-0.1.1 will be downloaded and installed.
hackage-security-0.6.0.0 will be downloaded and installed.
Cabal-3.2.0.0 will be downloaded and installed.
Downloading Cabal-3.2.0.0...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 753k 0 753k 0 0 2879k 0 --:--:-- --:--:-- --:--:-- 2888k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 27320 0 27320 0 0 188k 0 --:--:-- --:--:-- --:--:-- 189k
[ 1 of 236] Compiling Distribution.Compat.Async ( Distribution/Compat/Async.hs, Distribution/Compat/Async.o )
[ 2 of 236] Compiling Distribution.Compat.Binary ( Distribution/Compat/Binary.hs, Distribution/Compat/Binary.o )
[ 3 of 236] Compiling Distribution.Compat.Directory ( Distribution/Compat/Directory.hs, Distribution/Compat/Directory.o )
[ 4 of 236] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, Distribution/Compat/Exception.o )
[ 5 of 236] Compiling Distribution.Compat.FilePath ( Distribution/Compat/FilePath.hs, Distribution/Compat/FilePath.o )
[ 7 of 236] Compiling Distribution.Compat.Internal.TempFile ( Distribution/Compat/Internal/TempFile.hs, Distribution/Compat/Internal/TempFile.o )
( 200 other compiling lines ..)
[230 of 236] Compiling Distribution.Simple.Configure ( Distribution/Simple/Configure.hs, Distribution/Simple/Configure.o )
[231 of 236] Compiling Distribution.Simple.SrcDist ( Distribution/Simple/SrcDist.hs, Distribution/Simple/SrcDist.o )
[232 of 236] Compiling Distribution.Simple.Build ( Distribution/Simple/Build.hs, Distribution/Simple/Build.o )
[233 of 236] Compiling Distribution.Simple.Haddock ( Distribution/Simple/Haddock.hs, Distribution/Simple/Haddock.o )
[234 of 236] Compiling Distribution.Simple.Doctest ( Distribution/Simple/Doctest.hs, Distribution/Simple/Doctest.o )
[235 of 236] Compiling Distribution.Simple ( Distribution/Simple.hs, Distribution/Simple.o )
[236 of 236] Compiling Main ( Setup.hs, Setup.o )
Linking Setup ...
ld64.lld: warning: ignoring unknown argument: --gc-sections
ld64.lld: warning: ignoring unknown argument: -u
(80 other similar lines..)
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command. Setting sdk version to match provided min version
Cannot open ./Distribution/Compat/Async.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=2338, r1_type=5, r1_extern=1, r1_length=3, r1_pcrel=0, r1_symbolnum=243), (r2_address=2338, r2_type=0, r2_extern=1, r2_length=3, r2_pcrel=0, r2_symbolnum=237)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
Error during cabal-install bootstrap:
Compiling the Setup script failed.
And Another update
Per a comment from #bradm I have tried the Haskell Stack http://docs.haskellstack.org/en/stable/README/#how-to-install . The same errors occur as at beginning of my question. I did double check that the stack were newly installed and it shows right now timestamp. It fails on stack setup within a new dummy project and has the same signature of long ugly errors including linker error on Main.o bad relocation . Here is the core of it (same as at top):
Cannot open /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=21c, r1_type=5, r1_extern=1, r1_length=2, r1_pcrel=0, r1_symbolnum=37), (r2_address=21c, r2_type=0, r2_extern=1, r2_length=2, r2_pcrel=0, r2_symbolnum=30)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
-- While building simple Setup.hs using:
/Users/steve/.stack/programs/x86_64-osx/ghc-8.8.3/bin/ghc-8.8.3
-rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.0.1.0 /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3
Process exited with code: ExitFailure 1
I just found this known bug: https://github.com/commercialhaskell/stack/issues/4373
That is exactly what I'm seeing.
The workaround required is to update a settings file that is buried deep under a newly generated ~/.stack directory https://github.com/commercialhaskell/stack/issues/4373#issuecomment-432726112
Those instructions are incomplete so I added a comment to that bug to clarify. That settings location: ~/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/settings
And this works (note that stack test is a combination of stack build and stack test):
(base) 10:27:09/haskelltest $stack test
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
Linking /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 ...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
Building all executables for `haskelltest' once. After a successful build of all of them, only specified executables will be rebuilt.
haskelltest> configure (lib + exe + test)
Configuring haskelltest-0.1.0.0...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
haskelltest> build (lib + exe + test)
Preprocessing library for haskelltest-0.1.0.0..
Building library for haskelltest-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_haskelltest
Preprocessing test suite 'haskelltest-test' for haskelltest-0.1.0.0..
Building test suite 'haskelltest-test' for haskelltest-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_haskelltest
Linking .stack-work/dist/x86_64-osx/Cabal-3.0.1.0/build/haskelltest-test/haskelltest-test ...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
Preprocessing executable 'haskelltest-exe' for haskelltest-0.1.0.0..
Building executable 'haskelltest-exe' for haskelltest-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_haskelltest
Linking .stack-work/dist/x86_64-osx/Cabal-3.0.1.0/build/haskelltest-exe/haskelltest-exe ...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
haskelltest> copy/register
Installing library in /git/rubytest/haskelltest/.stack-work/install/x86_64-osx/18cf924ea0be80a27100889c349bd98b50cf064de8de23f912f9f822b43a80db/8.8.3/lib/x86_64-osx-ghc-8.8.3/haskelltest-0.1.0.0-48zsyNIR9r7Efmr0ATZ6Im
Installing executable haskelltest-exe in /git/rubytest/haskelltest/.stack-work/install/x86_64-osx/18cf924ea0be80a27100889c349bd98b50cf064de8de23f912f9f822b43a80db/8.8.3/bin
Registering library for haskelltest-0.1.0.0..
haskelltest> test (suite: haskelltest-test)
Progress 1/2: haskelltestTest suite not yet implemented
haskelltest> Test suite haskelltest-test passed
Completed 2 action(s).
I tried to compile one of my Rust projects to the x86_64-unknown-linux-gnu target:
$ cargo build --target=x86_64-unknown-linux-gnu
Compiling deployer v0.1.0 (file:///Users/raphael/web/deployer)
error: linking with `cc` failed: exit code: 1
|
= note: "cc"
= note: clang: warning: argument unused during compilation: '-pie'
ld: unknown option: --as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't know what to do with such a message. What should I do to make it work?
Here is my Cargo.toml file:
[package]
name = "deployer"
version = "0.1.0"
authors = ["..."]
[dependencies]
clap = "2.14.0"
time = "0.1.35"
slack-hook = "0.2"
Cargo version:
cargo 0.13.0-nightly (109cb7c 2016-08-19)
Rust version:
rustc 1.12.0 (3191fbae9 2016-09-23)
I tried to update everything with rustup, but I still get the same problem.
Inspired from cross-compile-rust-from-mac-to-linux, I typically install these dependencies to cross compile rust from Mac OS to Linux (e.g. for Docker containers):
rustup target add x86_64-unknown-linux-gnu
# Install a pre-built cross compiler
brew tap SergioBenitez/osxct
brew install x86_64-unknown-linux-gnu
And finally I can cross compile to Linux on Mac OS with:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc \
cargo build --target=x86_64-unknown-linux-gnu