2009-11-30 18 views
0

我經歷Real world Haskell,並且到了例子:「不能做簽名的4字節搬遷」上編譯

-- file: ch04/InteractWith.hs 
-- Save this in a source file, e.g. Interact.hs 

import System.Environment (getArgs) 

interactWith function inputFile outputFile = do 
    input <- readFile inputFile 
    writeFile outputFile (function input) 

main = mainWith myFunction 
    where mainWith function = do 
      args <- getArgs 
      case args of 
      [input,output] -> interactWith function input output 
      _ -> putStrLn "error: exactly two arguments needed" 

     -- replace "id" with the name of our function below 
     myFunction = id 

但是,當我嘗試編譯它(ghc --make InteractWith)我得到這個錯誤:

$ ghc --make InteractWith 
[1 of 1] Compiling Main    (InteractWith.hs, InteractWith.o) 

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:309:0: 
    suffix or operands invalid for `push' 

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:358:0: 
    suffix or operands invalid for `push' 

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:384:0: 
    32-bit absolute addressing is not supported for x86-64 

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:384:0: 
    cannot do signed 4 byte relocation 

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:387:0: 
    32-bit absolute addressing is not supported for x86-64 

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:387:0: 
    cannot do signed 4 byte relocation 

我在Mac OS 10.6(Snow Leopard)上使用GHC 6.10.4。

回答

3

我在編譯Snow Leopard中幾乎所有的東西時都遇到類似的問題。我找到了解決辦法是用以下取代的/usr/bin/ghc的內容(這實際上只是一個shell腳本):

#!/bin/sh 

exec /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc -B/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/. -optc-m32 -opta-m32 -optl-m32 -dynload wrapped ${1+"[email protected]"} 

我認爲它實際上只是增加-optc-m32 -opta-m32 -optl-m32,但我不記得......

(我最初在互聯網上發現了這個地方,但我不記得它在哪裏,它也花了我一段時間。)

+0

這似乎解決了我的問題。非常感謝 :) –

0

你最近更新了Snow Leopard嗎?我相信這是在您嘗試使用Leopard構建的Snow Leopard中的可執行文件時發生的。