[llvm] 06e0a32 - [CMake] Fix BUILD_SHARED_LIBS build on Solaris

Rainer Orth via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 01:01:17 PDT 2023


Author: Rainer Orth
Date: 2023-09-15T10:00:49+02:00
New Revision: 06e0a32178d0bd47ff6b5331acfee03f5bc7c8ff

URL: https://github.com/llvm/llvm-project/commit/06e0a32178d0bd47ff6b5331acfee03f5bc7c8ff
DIFF: https://github.com/llvm/llvm-project/commit/06e0a32178d0bd47ff6b5331acfee03f5bc7c8ff.diff

LOG: [CMake] Fix BUILD_SHARED_LIBS build on Solaris

LLVM currently doesn't build with `-DBUILD_SHARED_LIBS=ON` on Solaris:
`libLLVMTargetParser.so` uses `libkstat` functions without linking it.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: <https://reviews.llvm.org/D158846

Added: 
    

Modified: 
    llvm/lib/TargetParser/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TargetParser/CMakeLists.txt b/llvm/lib/TargetParser/CMakeLists.txt
index 3a911aa12f8e80e..da1e352b0373387 100644
--- a/llvm/lib/TargetParser/CMakeLists.txt
+++ b/llvm/lib/TargetParser/CMakeLists.txt
@@ -8,6 +8,11 @@ if (HAS_WERROR_GLOBAL_CTORS AND NOT LLVM_HAS_NOGLOBAL_CTOR_MUTEX)
   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 @@ add_llvm_component_library(LLVMTargetParser
   Unix
   Windows
 
+  LINK_LIBS
+  ${system_libs}
+
   LINK_COMPONENTS
   Support
 


        


More information about the llvm-commits mailing list