[Openmp-commits] [PATCH] D146925: [OpenMP] Fix building the second import library when built in the main llvm build root

Martin Storsjö via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Mar 26 14:58:32 PDT 2023


mstorsjo created this revision.
mstorsjo added reviewers: vadikp-intel, hans.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1.
Herald added a project: OpenMP.

Pass an absolute path to initial import library in this case, to
make it clear which file is intended. (For the generated build
files, cmake still uses relative paths as suitable.)

The issue was that the initial import library was stored in
ARCHIVE_OUTPUT_DIRECTORY as lib/libomp.dll.lib, while the same
file added as a source file to the second import library was
interpreted as runtime/src/libomp.dll.lib.

This is an alternative to D146894 <https://reviews.llvm.org/D146894>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146925

Files:
  openmp/runtime/src/CMakeLists.txt


Index: openmp/runtime/src/CMakeLists.txt
===================================================================
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -213,6 +213,10 @@
 else()
   set(LIBOMP_LIBRARY_DIR ${LIBOMP_LIBRARY_DIR} PARENT_SCOPE)
 endif()
+get_target_property(LIBOMP_ARCHIVE_DIR omp ARCHIVE_OUTPUT_DIRECTORY)
+if(NOT LIBOMP_ARCHIVE_DIR)
+  set(LIBOMP_ARCHIVE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+endif()
 set(LIBOMP_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
 
 # Add symbolic links to libomp
@@ -297,8 +301,8 @@
     )
     # while this is merely generating an import library off the one generated with the runtime dll,
     # kmp_global.cpp will satisfy the librarian's apparent ask to see the actual exported DATA items
-    set_source_files_properties(${LIBOMP_GENERATED_IMP_LIB_FILENAME} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
-    add_library(${LIBOMP_IMP_LIB_TARGET} STATIC ${LIBOMP_GENERATED_IMP_LIB_FILENAME} kmp_global.cpp)
+    set_source_files_properties(${LIBOMP_ARCHIVE_DIR}/${LIBOMP_GENERATED_IMP_LIB_FILENAME} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
+    add_library(${LIBOMP_IMP_LIB_TARGET} STATIC ${LIBOMP_ARCHIVE_DIR}/${LIBOMP_GENERATED_IMP_LIB_FILENAME} kmp_global.cpp)
     set_target_properties(${LIBOMP_IMP_LIB_TARGET} PROPERTIES
         PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" LINKER_LANGUAGE C
         STATIC_LIBRARY_OPTIONS "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/${LIBOMPIMP_GENERATED_DEF_FILE}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146925.508442.patch
Type: text/x-patch
Size: 1530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230326/dfc829de/attachment.bin>


More information about the Openmp-commits mailing list