[PATCH] D158846: [CMake] Fix BUILD_SHARED_LIBS build on Solaris
Rainer Orth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 00:35:13 PDT 2023
ro updated this revision to Diff 555976.
ro added a comment.
Always link LLVM libs and `libbenchmark` with `libm` if it exists.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158846/new/
https://reviews.llvm.org/D158846
Files:
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/TargetParser/CMakeLists.txt
third-party/benchmark/CMakeLists.txt
third-party/benchmark/src/CMakeLists.txt
Index: third-party/benchmark/src/CMakeLists.txt
===================================================================
--- third-party/benchmark/src/CMakeLists.txt
+++ third-party/benchmark/src/CMakeLists.txt
@@ -42,6 +42,9 @@
target_link_libraries(benchmark PRIVATE rt)
endif(HAVE_LIB_RT)
+if(HAVE_LIB_M)
+ target_link_libraries(benchmark PRIVATE m)
+endif()
# We need extra libraries on Windows
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
Index: third-party/benchmark/CMakeLists.txt
===================================================================
--- third-party/benchmark/CMakeLists.txt
+++ third-party/benchmark/CMakeLists.txt
@@ -129,6 +129,7 @@
include(CheckLibraryExists)
check_library_exists(rt shm_open "" HAVE_LIB_RT)
+check_library_exists(m ceil "" HAVE_LIB_M)
if (BENCHMARK_BUILD_32_BITS)
add_required_cxx_compiler_flag(-m32)
Index: llvm/lib/TargetParser/CMakeLists.txt
===================================================================
--- llvm/lib/TargetParser/CMakeLists.txt
+++ llvm/lib/TargetParser/CMakeLists.txt
@@ -8,6 +8,11 @@
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=global-constructors")
endif()
+# Solaris code uses kstat, so specify dependency explicitly for shared builds.
+if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+ set(system_libs kstat)
+endif()
+
add_llvm_component_library(LLVMTargetParser
AArch64TargetParser.cpp
ARMTargetParserCommon.cpp
@@ -25,6 +30,9 @@
Unix
Windows
+ LINK_LIBS
+ ${system_libs}
+
LINK_COMPONENTS
Support
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -3,6 +3,7 @@
include(LLVMProcessSources)
include(LLVM-Config)
include(DetermineGCCCompatible)
+include(CheckLibraryExists)
function(llvm_update_compile_flags name)
get_property(sources TARGET ${name} PROPERTY SOURCES)
@@ -683,6 +684,12 @@
set(libtype PRIVATE)
endif()
+ # Many LLVM libs require libm, so do this globally.
+ check_library_exists(m ceil "" HAVE_LIBM)
+ if(HAVE_LIBM)
+ set_target_properties(${name} PROPERTIES INTERFACE_LINK_LIBRARIES m)
+ endif()
+
if(ARG_MODULE AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS AND ARG_PLUGIN_TOOL AND (WIN32 OR CYGWIN))
# On DLL platforms symbols are imported from the tool by linking against it.
set(llvm_libs ${ARG_PLUGIN_TOOL})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158846.555976.patch
Type: text/x-patch
Size: 2412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230906/856e52e4/attachment.bin>
More information about the llvm-commits
mailing list