1
我一直在嘗試編譯使用ghc的Haskell代碼(僅用於與Haskell一起玩),但在gcc鏈接部分期間出現錯誤。Haskell編譯與gcc錯誤
ghc --make compileTest.hs
Linking compileTest ...
/usr/bin/ld: --hash-size=31: unknown option
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
這裏是我的gcc版本:
gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我不明白,GCC接受不同標誌的細微之處,但沒有找到對谷歌的錯誤任何引用。另外,我不認爲我可以直接調用gcc,因爲它是由ghc命令啓動的,用於編譯Haskell文件。
詳細版本看起來像這樣。
:~/haskell_code$ ghc --make compileTest.hs -v
Glasgow Haskell Compiler, Version 7.4.2, stage 2 booted by GHC version 7.4.2
Using binary package database: /usr/lib/ghc/package.conf.d/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-7d3c2c69a5e8257a04b2c679c40e2fa7
wired-in package integer-gmp mapped to integer-gmp-0.4.0.0-af3a28fdc4138858e0c7c5ecc2a64f43
wired-in package base mapped to base-4.5.1.0-6e4c9bdc36eeb9121f27ccbbcb62e3f3
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.7.0.0-2bd128e15c2d50997ec26a1eaf8b23bf
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: *compileTest.hs
Stable obj: [Main]
Stable BCO: []
Ready for upsweep
[NONREC
ModSummary {
ms_hs_date = Sun Apr 21 23:11:03 IST 2013
ms_mod = main:Main,
ms_textual_imps = [import (implicit) Prelude]
ms_srcimps = []
}]
*** Deleting temp files:
Deleting:
compile: input file compileTest.hs
Created temporary directory: /tmp/ghc20569_0
*** Checking old interface for main:Main:
[1 of 1] Skipping Main (compileTest.hs, compileTest.o)
Upsweep completely successful.
*** Deleting temp files:
Deleting: /tmp/ghc20569_0/ghc20569_0.s
Warning: deleting non-existent /tmp/ghc20569_0/ghc20569_0.s
link: linkables are ...
LinkableM (Sun Apr 21 23:11:17 IST 2013) main:Main
[DotO compileTest.o]
Linking compileTest ...
*** C Compiler:
'/usr/bin/gcc' '-fno-stack-protector' '-Wl,--hash-size=31' '-Wl,--reduce-memory-overheads' '-c' '/tmp/ghc20569_0/ghc20569_0.c' '-o' '/tmp/ghc20569_0/ghc20569_0.o' '-DTABLES_NEXT_TO_CODE' '-I/usr/lib/ghc/include'
*** C Compiler:
'/usr/bin/gcc' '-fno-stack-protector' '-Wl,--hash-size=31' '-Wl,--reduce-memory-overheads' '-c' '/tmp/ghc20569_0/ghc20569_0.s' '-o' '/tmp/ghc20569_0/ghc20569_1.o' '-DTABLES_NEXT_TO_CODE' '-I/usr/lib/ghc/include'
*** Linker:
'/usr/bin/gcc' '-fno-stack-protector' '-Wl,--hash-size=31' '-Wl,--reduce-memory-overheads' '-o' 'compileTest' 'compileTest.o' '-L/usr/lib/ghc/base-4.5.1.0' '-L/usr/lib/ghc/integer-gmp-0.4.0.0' '-L/usr/lib/ghc/ghc-prim-0.2.0.0' '-L/usr/lib/ghc' '/tmp/ghc20569_0/ghc20569_0.o' '/tmp/ghc20569_0/ghc20569_1.o' '-lHSbase-4.5.1.0' '-lHSinteger-gmp-0.4.0.0' '-lgmp' '-lHSghc-prim-0.2.0.0' '-lHSrts' '-lffi' '-lm' '-lrt' '-ldl' '-u' 'ghczmprim_GHCziTypes_Izh_static_info' '-u' 'ghczmprim_GHCziTypes_Czh_static_info' '-u' 'ghczmprim_GHCziTypes_Fzh_static_info' '-u' 'ghczmprim_GHCziTypes_Dzh_static_info' '-u' 'base_GHCziPtr_Ptr_static_info' '-u' 'base_GHCziWord_Wzh_static_info' '-u' 'base_GHCziInt_I8zh_static_info' '-u' 'base_GHCziInt_I16zh_static_info' '-u' 'base_GHCziInt_I32zh_static_info' '-u' 'base_GHCziInt_I64zh_static_info' '-u' 'base_GHCziWord_W8zh_static_info' '-u' 'base_GHCziWord_W16zh_static_info' '-u' 'base_GHCziWord_W32zh_static_info' '-u' 'base_GHCziWord_W64zh_static_info' '-u' 'base_GHCziStable_StablePtr_static_info' '-u' 'ghczmprim_GHCziTypes_Izh_con_info' '-u' 'ghczmprim_GHCziTypes_Czh_con_info' '-u' 'ghczmprim_GHCziTypes_Fzh_con_info' '-u' 'ghczmprim_GHCziTypes_Dzh_con_info' '-u' 'base_GHCziPtr_Ptr_con_info' '-u' 'base_GHCziPtr_FunPtr_con_info' '-u' 'base_GHCziStable_StablePtr_con_info' '-u' 'ghczmprim_GHCziTypes_False_closure' '-u' 'ghczmprim_GHCziTypes_True_closure' '-u' 'base_GHCziPack_unpackCString_closure' '-u' 'base_GHCziIOziException_stackOverflow_closure' '-u' 'base_GHCziIOziException_heapOverflow_closure' '-u' 'base_ControlziExceptionziBase_nonTermination_closure' '-u' 'base_GHCziIOziException_blockedIndefinitelyOnMVar_closure' '-u' 'base_GHCziIOziException_blockedIndefinitelyOnSTM_closure' '-u' 'base_ControlziExceptionziBase_nestedAtomically_closure' '-u' 'base_GHCziWeak_runFinalizzerBatch_closure' '-u' 'base_GHCziTopHandler_flushStdHandles_closure' '-u' 'base_GHCziTopHandler_runIO_closure' '-u' 'base_GHCziTopHandler_runNonIO_closure' '-u' 'base_GHCziConcziIO_ensureIOManagerIsRunning_closure' '-u' 'base_GHCziConcziSync_runSparks_closure' '-u' 'base_GHCziConcziSignal_runHandlers_closure'
/usr/bin/ld: --hash-size=31: unknown option
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
*** Deleting temp files:
Deleting: /tmp/ghc20569_0/ghc20569_1.o /tmp/ghc20569_0/ghc20569_0.s /tmp/ghc20569_0/ghc20569_0.o /tmp/ghc20569_0/ghc20569_0.c
*** Deleting temp dirs:
Deleting: /tmp/ghc20569_0
做ghci compileTest.hs的工作? – 2013-04-22 17:26:32
你的'ld'是什麼? Mine('GNU ld(GNU Binutils; openSUSE 12.3)2.23.1')理解'--hash-size = 31'。如果你真的是'黃金',我似乎記得,GHC通過的旗幟有問題。不記得如何對待它。 – 2013-04-22 17:48:07
@DanielFischer我正在使用黃金。在轉移到ld後,它沒有任何投訴。謝謝! – zermelozf 2013-04-22 21:42:12