[LLVMdev] Problem in LLVM CMake modules

Eli Gottlieb eligottlieb at gmail.com
Sat Jul 7 13:49:01 PDT 2012


Hi again,
     I'm trying to upgrade my LLVM bindings in Java from 2.9 to 3.1. To 
do so, I regenerated the JNI bindings from fresh LLVM 3.1 headers, and 
did a slight rewrite of my CMakeLists.txt file for building the C code.

     Problem is, cmake no longer finishes at all.  I receive the 
following output, and then it just runs forever (while still responding 
to a CTRL-C):

> eli at eli-netbook:~/Programs/jllvm/src/org/jllvm/bindings$ cmake .
> -- The C compiler identification is GNU
> -- The CXX compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc
> -- Check for working C compiler: /usr/bin/gcc -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/c++
> -- Check for working CXX compiler: /usr/bin/c++ -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Found Java: /usr/lib/jvm/java-6-openjdk-amd64/bin/java (found 
> version "1.6.0.24")
> -- Found JNI: /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/libjawt.so
Running CMake with --debug-output yields no additional information, and 
running cmake with gdb attached just gives me a backtrace with no signs 
of abnormal operation.

I've tried the old "comment stuff out and see what causes the symptom to 
reappear" method of debugging, and it's definitely the 
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES all) line in my 
CMakeLists.txt.  I've attached CMakeLists.txt for reference.

Could anyone perhaps tell me why CMake can't finish?

Cheers,
--Eli Gottlieb
-------------- next part --------------
cmake_minimum_required (VERSION 2.6)
project (jllvm)
add_library(jllvm SHARED Analysis_wrap.c BitReader_wrap.c BitWriter_wrap.c Core_wrap.c EnhancedDisassembly_wrap.c ExecutionEngine_wrap.c LinkTimeOptimizer_wrap.c lto_wrap.c Target_wrap.c Transforms/IPO_wrap.c Transforms/Scalar_wrap.c)
install(TARGETS jllvm DESTINATION lib/)
add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )

# A convenience variable:
set(LLVM_ROOT "/usr/" CACHE /usr/ "Root of LLVM install.")
set(CMAKE_INSTALL_PREFIX "/usr")
# A bit of a sanity check:
if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
endif()
# We incorporate the CMake features provided by LLVM:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
include(LLVMConfig)
# Now set the header and library paths:
include_directories( ${LLVM_ROOT}/include )
link_directories( ${LLVM_ROOT}/lib )
add_definitions( ${LLVM_DEFINITIONS} )
# Make sure to include the headers required for Java and JNI.
FIND_PACKAGE(Java REQUIRED)
FIND_PACKAGE(JNI REQUIRED)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
# Let's suppose we want to build a JIT compiler with support for
# binary code (no interpreter):
#llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native)
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES all)
# Finally, we link the LLVM libraries to our executable:
target_link_libraries(jllvm ${REQ_LLVM_LIBRARIES})
# LLVM typically comes installed as static libraries, so make sure to link in the C++ runtimes.
set_target_properties(jllvm PROPERTIES LINKER_LANGUAGE CXX)


More information about the llvm-dev mailing list