[llvm-dev] Compile LLVM into LLVM IR with non-Xcode Clang
Chris Bieneman via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 1 10:11:36 PDT 2017
Sorry for the delayed response.
The problem is that libtool (or ar/ranlib), and ld need to be able to read the bitcode files in order to generate symbol tables for the archives and to link the final binaries. You've updated your clang to generate new bitcode, but the libtool, and ld on the system can't read the bitcode.
There are two ways to get around this.
(1) You can allow LLVM's build system to do all the hard work for you by configuring your initial LLVM build with this command:
cmake -G <generator> -C <path to clang>/cmake/caches/Apple-stage1.cmake
Then build the "stage2" target. This will take a long time to run, but it will build clang, then use that clang to build a second LTO'd clang where you can rip apart the LLVM archives.
(2) Alternatively you can set two CMake options DARWIN_LTO_LIBRARY and DYLD_LIBRARY_PATH. DARWIN_LTO_LIBRARY needs to point to the lib/libLTO.dylib which matches your clang and DYLD_LIBRARY_PATH needs to point to the lib directory containing the libLTO.dylib.
Hope this helps!
-Chris
> On Aug 4, 2017, at 10:28 PM, Mackenzie Moore via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Hi everyone,
>
> I was able to compile LLVM to LLVM IR. However, when I read the results into my program, I got "warning: ignoring debug info with an invalid version (700000003)." I figured out it was because the Clang that comes with Xcode uses an LLVM that's older than the LLVM I compiled from source, and LLVM's IR isn't backwards compatible. I've tried using the following CMake flags:
> -DCMAKE_C_COMPILER=<path to clang built from source>
> -DCMAKE_CXX_COMPILER=<path to clang++ built from source>
>
> I also tried exporting the CC and CXX variables before invoking CMake. Both attempts lead to the following message:
>
> Scanning dependencies of target LLVMDemangle
> [ 0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o
> [ 0%] Linking CXX static library ../libLLVMDemangle.a
> error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o is not an object file (not allowed in a library)
> make[2]: *** [lib/libLLVMDemangle.a] Error 1
> make[1]: *** [lib/Demangle/CMakeFiles/LLVMDemangle.dir/all] Error 2
> make: *** [all] Error 2
>
> How do I get CMake to use the correct Clang binary?
>
> Thanks,
> Mackenzie
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
More information about the llvm-dev
mailing list