“无法进行带符号的 4 字节重定位”编译时
我正在浏览 现实世界 Haskell,并找到示例:
-- 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。
I'm going through Real world Haskell, and got to the example:
-- 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
But when I try to compile it (ghc --make InteractWith
) I get this error:
$ 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
I'm using GHC 6.10.4 on Mac OS 10.6 (Snow Leopard).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 Snow Leopard 中编译几乎所有内容时都遇到了类似的问题。我找到的解决方案是将
/usr/bin/ghc
的内容(实际上只是一个 shell 脚本)替换为以下内容:我认为它实际上只是添加
-optc-m32 - opta-m32 -optl-m32
但我不记得了...(我最初在互联网上的某个地方找到了这个,但我不记得在哪里。它也花了我一段时间。)
I was having similar problems compiling almost anything in Snow Leopard. The solution I found was to replace the contents of
/usr/bin/ghc
(which is actually just a shell script) with the following:I think it's actually just adding
-optc-m32 -opta-m32 -optl-m32
but I can't remember...(I originally found this somewhere on the internets, but I don't remember where. It did take me a while too.)
您最近更新到 Snow Leopard 了吗?我相信当您尝试在 Snow Leopard 中使用使用 Leopard 构建的可执行文件时,就会发生这种情况。
Did you update to Snow Leopard recently? I believe this happens when you're trying to use an executable in Snow Leopard that was built using Leopard.