[llvm] [CMake] Fix -DLLVM_LINK_LLVM_DYLIB=on builds when using ninja multi config (PR #65451)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 27 04:33:01 PDT 2023
https://github.com/ur4t updated https://github.com/llvm/llvm-project/pull/65451
>From 5c20a2768b641d128a8a9ed696a86501c2e4c3a9 Mon Sep 17 00:00:00 2001
From: ur4t <46435411+ur4t at users.noreply.github.com>
Date: Thu, 17 Aug 2023 23:21:39 +0800
Subject: [PATCH 1/2] [llvm][CMake] Fix llvm shared library when using ninja
multi config
---
llvm/tools/llvm-shlib/CMakeLists.txt | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index 4f6a2cbfbba308e..0d01d8e880e1fcf 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -41,9 +41,22 @@ if(LLVM_BUILD_LLVM_DYLIB)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
- ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map)
+
+ if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
+ # Replace the special string with a per config directory.
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} PER_CONF_LIBRARY_DIR ${LLVM_LIBRARY_DIR})
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+ ${PER_CONF_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
+ )
+ endforeach()
+ else()
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+ ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
+ )
+ endif()
# GNU ld doesn't resolve symbols in the version script.
set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
>From 72e1dc0bc7768a131df4b1dcb5d6bda44afc4bba Mon Sep 17 00:00:00 2001
From: ur4t <46435411+ur4t at users.noreply.github.com>
Date: Wed, 27 Sep 2023 19:31:19 +0800
Subject: [PATCH 2/2] [CMake] adjust if style in
llvm/tools/llvm-shlib/CMakeLists.txt
---
llvm/tools/llvm-shlib/CMakeLists.txt | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index 0d01d8e880e1fcf..ffdb67fb34a4dcc 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -42,7 +42,12 @@ if(LLVM_BUILD_LLVM_DYLIB)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
- if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+ ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
+ )
+ else()
foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
# Replace the special string with a per config directory.
string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} PER_CONF_LIBRARY_DIR ${LLVM_LIBRARY_DIR})
@@ -51,11 +56,6 @@ if(LLVM_BUILD_LLVM_DYLIB)
${PER_CONF_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
)
endforeach()
- else()
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
- ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
- )
endif()
# GNU ld doesn't resolve symbols in the version script.
@@ -160,7 +160,10 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND MSVC)
# Need to separate lib names with newlines.
string(REPLACE ";" "\n" FILE_CONTENT "${FULL_LIB_NAMES}")
- if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ # Write out the full lib names into file to be read by the python script.
+ file(WRITE ${LIBSFILE} "${FILE_CONTENT}")
+ else()
foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
# Replace the special string with a per config directory.
string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} PER_CONF_CONTENT "${FILE_CONTENT}")
@@ -170,9 +173,6 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND MSVC)
# ${CMAKE_CFG_INTDIR} correctly and select the right one.
file(WRITE ${LLVM_BINARY_DIR}/${BUILD_MODE}/libllvm-c.args "${PER_CONF_CONTENT}")
endforeach()
- else()
- # Write out the full lib names into file to be read by the python script.
- file(WRITE ${LIBSFILE} "${FILE_CONTENT}")
endif()
# Generate the exports file dynamically.
@@ -194,5 +194,5 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND MSVC)
# Make sure we search LLVMSupport first, before the CRT libs
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -INCLUDE:malloc")
endif()
-
+
endif()
More information about the llvm-commits
mailing list