我正在更新我的项目 llvm-fs 的工具,所以我安装了新版本的 mono 并尝试编译它。在 OS X 下将mono 3.10.0
与 fsharpc 3.1
一起使用,或在 ubuntu 下与fsharpc 3.0
一起使用mono 3.2.8
,编译失败并出现堆栈溢出:
Unhandled Exception:
System.StackOverflowException: The requested operation caused a stack overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_object_isinst (object,intptr)
at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
at Microsoft.FSharp.Compiler.Driver+DelayedDisposables.System-IDisposable-Dispose () [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter, Microsoft.FSharp.Compiler.ErrorLoggerProvider errorLoggerProvider) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.runMain (System.String[] argv) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.StackOverflowException: The requested operation caused a stack overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_object_isinst (object,intptr)
at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
at Microsoft.FSharp.Compiler.Driver+DelayedDisposables.System-IDisposable-Dispose () [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter, Microsoft.FSharp.Compiler.ErrorLoggerProvider errorLoggerProvider) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.runMain (System.String[] argv) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00000] in <filename unknown>:0
您可以通过执行以下操作在 Linux 或 OS X 上重现此错误:
git clone git@github.com:fsprojects/llvm-fs.git
cd llvm-fs/
FSC=fsharpc ./build.bash
在窗口fsc 12.0.30815.0
下,编译完成,没有错误:
fsc --nologo --debug --sig:LLVMFSharp.fsi --target:library --out:LLVMFSharp.dll src/LLVM/FFIUtil.fs src/LLVM/Generated.fs src/LLVM/Core.fs src/LLVM/BitReader.fs src/LLVM/ExecutionEngine.fs src/LLVM/Extra.fs src/LLVM/Target.fs src/LLVM/Quote.fs
这是一个已知问题,有什么方法可以解决它吗?我尝试将不同的选项传递给单声道运行时,但没有一个导致编译器正常退出。我确实记得过去单声道在尾声调用指令方面遇到了一些问题,但我认为这些问题大多得到了解决。谢谢!
这对于注释来说太长了,但是错误是由 generated .fs 中的这段代码触发的(因为注释掉它会停止堆栈溢出 - 一旦注释掉,稍后就会出现错误)(来自第 6496-6506 行):
[<DllImport(
llvmAssemblyName,
EntryPoint="LLVMRunFunction",
CallingConvention=CallingConvention.Cdecl,
CharSet=CharSet.Ansi)>]
extern void* (* LLVMGenericValueRef *) runFunctionNative(
void* (* LLVMExecutionEngineRef *) EE,
void* (* LLVMValueRef *) F,
uint32 NumArgs,
void* (* LLVMGenericValueRef* *) Args)
// I don't know how to generate an "F# friendly" version of LLVMRunFunction
输出签名文件的代码中发生崩溃。
禁用签名文件可以解决问题(但某处仍然存在潜在的错误)。