[PATCH] D29379: [cmake] Generate symbol exports files in config subdir

Rudy Pons via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 00:45:28 PST 2017


Ilod created this revision.
Herald added a subscriber: mgorny.

When generating native symbols export files, these files are generated in CMAKE_CURRENT_BINARY_DIR. However, on multi-configuration build-systems, such as Xcode and MSVC, this folder is shared between all configurations.
On this case, switching configuration may make the build system think the file is up-to-date, and use the file from the other configuration (resulting in link error if referencing symbol no longer existing because of inlining, or in non-exported symbols in the reverse case).

This patch generate the files in the CMAKE_CFG_INTDIR subfolder, to have a different file for each configuration.


https://reviews.llvm.org/D29379

Files:
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -66,20 +66,20 @@
 
 function(add_llvm_symbol_exports target_name export_file)
   if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-    set(native_export_file "${target_name}.exports")
+    set(native_export_file "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target_name}.exports")
     add_custom_command(OUTPUT ${native_export_file}
       COMMAND sed -e "s/^/_/" < ${export_file} > ${native_export_file}
       DEPENDS ${export_file}
       VERBATIM
       COMMENT "Creating export file for ${target_name}")
     set_property(TARGET ${target_name} APPEND_STRING PROPERTY
-                 LINK_FLAGS " -Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+                 LINK_FLAGS " -Wl,-exported_symbols_list,${native_export_file}")
   elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
     set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                  LINK_FLAGS " -Wl,-bE:${export_file}")
   elseif(LLVM_HAVE_LINK_VERSION_SCRIPT)
     # Gold and BFD ld require a version script rather than a plain list.
-    set(native_export_file "${target_name}.exports")
+    set(native_export_file "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target_name}.exports")
     # FIXME: Don't write the "local:" line on OpenBSD.
     add_custom_command(OUTPUT ${native_export_file}
       COMMAND echo "{" > ${native_export_file}
@@ -92,21 +92,21 @@
       COMMENT "Creating export file for ${target_name}")
     if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
       set_property(TARGET ${target_name} APPEND_STRING PROPERTY
-                   LINK_FLAGS "  -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+                   LINK_FLAGS "  -Wl,-M,${native_export_file}")
     else()
       set_property(TARGET ${target_name} APPEND_STRING PROPERTY
-                   LINK_FLAGS "  -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+                   LINK_FLAGS "  -Wl,--version-script,${native_export_file}")
     endif()
   else()
-    set(native_export_file "${target_name}.def")
+    set(native_export_file "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target_name}.def")
 
     add_custom_command(OUTPUT ${native_export_file}
       COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print(''.join(['EXPORTS\\n']+sys.stdin.readlines(),))"
         < ${export_file} > ${native_export_file}
       DEPENDS ${export_file}
       VERBATIM
       COMMENT "Creating export file for ${target_name}")
-    set(export_file_linker_flag "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+    set(export_file_linker_flag "${native_export_file}")
     if(MSVC)
       set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"")
     endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29379.86586.patch
Type: text/x-patch
Size: 2868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/ca76a6a5/attachment.bin>


More information about the llvm-commits mailing list