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.soRunning 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)
Eli Gottlieb <eligottlieb at gmail.com> writes:> 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):Yep, llvm_map_components_to_libraries gets confused by the existence of both gtest and gtest_main and enters an infinite loop. A workaround is to not pass "all" to llvm_map_components_to_libraries but a list of required components.
Óscar Fuentes <ofv at wanadoo.es> writes:> Yep, llvm_map_components_to_libraries gets confused by the existence of > both gtest and gtest_main and enters an infinite loop. A workaround is > to not pass "all" to llvm_map_components_to_libraries but a list of > required components.This patch *seems* to fix the problem (cmake regexps are not thoroughly documented): --- a/cmake/modules/LLVM-Config.cmake +++ b/cmake/modules/LLVM-Config.cmake @@ -160,7 +160,7 @@ function(explicit_map_components_to_libraries out_libs) list(REVERSE expanded_components) list(APPEND processed ${lib}) # Find the maximum index that doesn't have to be re-processed: - while(NOT "${expanded_components}" MATCHES "^${processed}.*" ) + while(NOT "${expanded_components}" MATCHES "^${processed}(;)|(.*)") list(REMOVE_AT processed -1) endwhile() list(LENGTH processed cursor) However, using "all" as the component to be linked is still broken, as it passes to the linker -lLTO_static and -lprofile_rt-static, which are non-existant libraries on a static build. On the case of LTO_static the fix probably is diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt index 9112976..60fc902 100644 --- a/tools/lto/CMakeLists.txt +++ b/tools/lto/CMakeLists.txt @@ -23,5 +23,4 @@ endif() if( NOT BUILD_SHARED_LIBS ) add_llvm_library(${LTO_STATIC_TARGET_NAME} ${SOURCES}) - set_property(TARGET ${LTO_STATIC_TARGET_NAME} PROPERTY OUTPUT_NAME "LTO") endif() In the case of profile_rt-static, the fix probably is: diff --git a/runtime/libprofile/CMakeLists.txt b/runtime/libprofile/CMakeLists.txt index 414ad00..2794c4d 100644 --- a/runtime/libprofile/CMakeLists.txt +++ b/runtime/libprofile/CMakeLists.txt @@ -9,9 +9,6 @@ set(SOURCES ) add_llvm_library( profile_rt-static ${SOURCES} ) -set_target_properties( profile_rt-static - PROPERTIES - OUTPUT_NAME "profile_rt" ) add_llvm_loadable_module( profile_rt-shared ${SOURCES} ) set_target_properties( profile_rt-shared And do we really want gtest, gtest_main and maybe other internal libraries to be listed when the user requires "all" LLVM components?