iron-kaleidoscope icon indicating copy to clipboard operation
iron-kaleidoscope copied to clipboard

Linker failure on OS X

Open hawkw opened this issue 8 years ago • 4 comments

Trying to build iron-kaleidoscope with a fresh clone of the project (after running $ cargo update), I get the following error message:

$ cargo build
   Compiling semver v0.1.20
   Compiling gcc v0.3.19
   Compiling rustc-serialize v0.3.16
   Compiling regex-syntax v0.2.2
   Compiling strsim v0.3.0
   Compiling libc v0.1.10
   Compiling bitflags v0.3.2
   Compiling memchr v0.1.6
   Compiling aho-corasick v0.3.4
   Compiling llvm-sys v0.2.1
   Compiling cmake v0.1.7
   Compiling iron_llvm v0.0.1 (https://github.com/jauhien/iron-llvm.git#8800226c)
   Compiling regex v0.1.41
   Compiling regex_macros v0.1.21
   Compiling docopt v0.6.74
   Compiling docopt_macros v0.6.74
   Compiling iron_kaleidoscope v0.0.1 (file:///Users/hawk/Development/iron-kaleidoscope)
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/iron_kaleidoscope.0.o" "-o" "/Users/hawk/Development/iron-kaleidoscope/target/debug/iron_kaleidoscope" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/hawk/Development/iron-kaleidoscope/target/debug" "-L" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps" "-L" "/Users/hawk/Development/iron-kaleidoscope/target/debug/build/iron_llvm-f0a3a981c282c1de/out" "-L" "/usr/local/Cellar/llvm/3.6.2/lib" "-L" "/Users/hawk/Development/iron-kaleidoscope/target/debug/build/llvm-sys-9bcc4041ad5d7b40/out" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/hawk/Development/iron-kaleidoscope/.rust/lib/x86_64-apple-darwin" "-L" "/Users/hawk/Development/iron-kaleidoscope/lib/x86_64-apple-darwin" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libdocopt-398ed9badedc4dd3.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/libiron_kaleidoscope.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libregex-c5abedf84fe61ddb.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libaho_corasick-713d9a23dcd56f15.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/librustc_serialize-7ff5bfc027146194.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libregex_syntax-6d9e9f3bd76497d4.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libmemchr-1ef94c8f78e37fc7.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libiron_llvm-f0a3a981c282c1de.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libllvm_sys-9bcc4041ad5d7b40.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/liblibc-144c435538abd757.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libstrsim-f37b8d6da2e1c859.rlib" "/Users/hawk/Development/iron-kaleidoscope/target/debug/deps/libbitflags-c495827ddcd6a202.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-10cbabc2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-10cbabc2.rlib" "-l" "LLVMLTO" "-l" "LLVMObjCARCOpts" "-l" "LLVMLinker" "-l" "LLVMBitWriter" "-l" "LLVMIRReader" "-l" "LLVMAsmParser" "-l" "LLVMXCoreDisassembler" "-l" "LLVMXCoreCodeGen" "-l" "LLVMXCoreDesc" "-l" "LLVMXCoreInfo" "-l" "LLVMXCoreAsmPrinter" "-l" "LLVMSystemZDisassembler" "-l" "LLVMSystemZCodeGen" "-l" "LLVMSystemZAsmParser" "-l" "LLVMSystemZDesc" "-l" "LLVMSystemZInfo" "-l" "LLVMSystemZAsmPrinter" "-l" "LLVMSparcDisassembler" "-l" "LLVMSparcCodeGen" "-l" "LLVMSparcAsmParser" "-l" "LLVMSparcDesc" "-l" "LLVMSparcInfo" "-l" "LLVMSparcAsmPrinter" "-l" "LLVMR600CodeGen" "-l" "LLVMipo" "-l" "LLVMVectorize" "-l" "LLVMR600AsmParser" "-l" "LLVMR600Desc" "-l" "LLVMR600Info" "-l" "LLVMR600AsmPrinter" "-l" "LLVMPowerPCDisassembler" "-l" "LLVMPowerPCCodeGen" "-l" "LLVMPowerPCAsmParser" "-l" "LLVMPowerPCDesc" "-l" "LLVMPowerPCInfo" "-l" "LLVMPowerPCAsmPrinter" "-l" "LLVMNVPTXCodeGen" "-l" "LLVMNVPTXDesc" "-l" "LLVMNVPTXInfo" "-l" "LLVMNVPTXAsmPrinter" "-l" "LLVMMSP430CodeGen" "-l" "LLVMMSP430Desc" "-l" "LLVMMSP430Info" "-l" "LLVMMSP430AsmPrinter" "-l" "LLVMMipsDisassembler" "-l" "LLVMMipsCodeGen" "-l" "LLVMMipsAsmParser" "-l" "LLVMMipsDesc" "-l" "LLVMMipsInfo" "-l" "LLVMMipsAsmPrinter" "-l" "LLVMHexagonDisassembler" "-l" "LLVMHexagonCodeGen" "-l" "LLVMHexagonDesc" "-l" "LLVMHexagonInfo" "-l" "LLVMCppBackendCodeGen" "-l" "LLVMCppBackendInfo" "-l" "LLVMARMDisassembler" "-l" "LLVMARMCodeGen" "-l" "LLVMARMAsmParser" "-l" "LLVMARMDesc" "-l" "LLVMARMInfo" "-l" "LLVMARMAsmPrinter" "-l" "LLVMAArch64Disassembler" "-l" "LLVMAArch64CodeGen" "-l" "LLVMAArch64AsmParser" "-l" "LLVMAArch64Desc" "-l" "LLVMAArch64Info" "-l" "LLVMAArch64AsmPrinter" "-l" "LLVMAArch64Utils" "-l" "LLVMTableGen" "-l" "LLVMDebugInfo" "-l" "LLVMOption" "-l" "LLVMX86Disassembler" "-l" "LLVMX86AsmParser" "-l" "LLVMX86CodeGen" "-l" "LLVMSelectionDAG" "-l" "LLVMAsmPrinter" "-l" "LLVMX86Desc" "-l" "LLVMMCDisassembler" "-l" "LLVMX86Info" "-l" "LLVMX86AsmPrinter" "-l" "LLVMX86Utils" "-l" "LLVMMCJIT" "-l" "LLVMLineEditor" "-l" "LLVMInstrumentation" "-l" "LLVMInterpreter" "-l" "LLVMExecutionEngine" "-l" "LLVMRuntimeDyld" "-l" "LLVMCodeGen" "-l" "LLVMScalarOpts" "-l" "LLVMProfileData" "-l" "LLVMObject" "-l" "LLVMMCParser" "-l" "LLVMBitReader" "-l" "LLVMInstCombine" "-l" "LLVMTransformUtils" "-l" "LLVMipa" "-l" "LLVMAnalysis" "-l" "LLVMTarget" "-l" "LLVMMC" "-l" "LLVMCore" "-l" "LLVMSupport" "-l" "curses" "-l" "pthread" "-l" "z" "-l" "m" "-l" "stdc++" "-l" "c" "-l" "m" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: ld: warning: directory not found for option '-L/Users/hawk/Development/iron-kaleidoscope/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/hawk/Development/iron-kaleidoscope/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
  "typeinfo for llvm::RTDyldMemoryManager", referenced from:
      _LLVM_BSMMCallParentGetSymbolAddress in libiron_llvm-f0a3a981c282c1de.rlib(memory-manager-wrappers.cc.o)
  "typeinfo for llvm::SectionMemoryManager", referenced from:
      _LLVM_BSMMCallParentGetSymbolAddress in libiron_llvm-f0a3a981c282c1de.rlib(memory-manager-wrappers.cc.o)
      typeinfo for (anonymous namespace)::BindingSectionMemoryManager in libiron_llvm-f0a3a981c282c1de.rlib(memory-manager-wrappers.cc.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `iron_kaleidoscope`.

To learn more, run the command again with --verbose.

This could be a config issue on my part, but I'm not sure what is configured incorrectly.

hawkw avatar Oct 25 '15 18:10 hawkw

Hi, I have the same problem. It seems a link problem, but I have no idea. Do you have any solution?

jihoonson avatar Dec 30 '15 09:12 jihoonson

This error seems to be because of iron-llvm issue. I'll try to look at it.

jauhien avatar Jan 01 '16 22:01 jauhien

I found a solution for this problem. Surprisingly, the solution is rebuilding llvm with the following options.

-DLLVM_TARGETS_TO_BUILD:STRING="X86" -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_PIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF

LLVM_ENABLE_PIC seems to relate to this problem, but it is enabled by default. Maybe, zlib or terminfo are related, but I cannot understand what the real problem is.

jihoonson avatar Jan 02 '16 15:01 jihoonson

I can confirm this issue aswell, everything ran fine up until chapter 3 adding JIT.

cbrewster avatar Feb 11 '16 18:02 cbrewster