[PATCH] Adding llvm-shlib to CMake build system with a few new bells and whistles

Reid Kleckner rnk at google.com
Tue Oct 21 13:52:25 PDT 2014


At a really high level, I wonder why we don't annotate the entire LLVM C API as __attribute__((visibility("default"))) / dllexport / whatever is needed on MachO.

================
Comment at: tools/llvm-shlib/CMakeLists.txt:54
@@ +53,3 @@
+    
+    set(LIB_PATH ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
+
----------------
I'm not sure if this is always correct with funky generators like VS and XCode.

================
Comment at: tools/llvm-shlib/CMakeLists.txt:59
@@ +58,3 @@
+    add_custom_command(OUTPUT ${LIB_PATH}.exports
+      COMMAND nm ${LIB_PATH} | awk "/T _LLVM/ { print $3 }" | sort -u | sed -e "s/^_//g" > ${LIB_PATH}.exports
+      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib
----------------
Linux (and other OSs) won't add this leading underscore to functions with extern "C" linkage, so nm's output will look like 'T LLVM*'.

================
Comment at: tools/llvm-shlib/CMakeLists.txt:59
@@ +58,3 @@
+    add_custom_command(OUTPUT ${LIB_PATH}.exports
+      COMMAND nm ${LIB_PATH} | awk "/T _LLVM/ { print $3 }" | sort -u | sed -e "s/^_//g" > ${LIB_PATH}.exports
+      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib
----------------
rnk wrote:
> Linux (and other OSs) won't add this leading underscore to functions with extern "C" linkage, so nm's output will look like 'T LLVM*'.
It looks like you can skip the removal of leading underscores, add_llvm_symbol_exports appears to do this for you on Mac.

http://reviews.llvm.org/D5890






More information about the llvm-commits mailing list