From: Tim Kientzle Date: Wed, 31 Dec 2025 23:31:55 +0000 (-0800) Subject: Merge pull request #2835 from jmcarp/build-illumos X-Git-Tag: v3.8.5~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ee2199ea91471016f569f1ed8b1ff4b34bf2c74;p=thirdparty%2Flibarchive.git Merge pull request #2835 from jmcarp/build-illumos Skip unsupported linker options on illumos. (cherry picked from commit e663efb43073c3e51bfc72db61073f8c414391ff) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f32ecec53..3ab629133 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,12 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR # either of the following two, yet neither is supported as of 3.0.2 # - check_linker_flag - does not exist # - try_compile - does not support linker flags - IF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + IF(CMAKE_SYSTEM_NAME MATCHES "Darwin") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip") + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + # SunOS linker doesn't support --gc-sections + ELSE() # Place the functions and data into separate sections, allowing the linker # to garbage collect the unused ones. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections") @@ -148,10 +153,7 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR # Printing the discarded section is "too much", so enable on demand. #SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,--print-gc-sections") #SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--print-gc-sections") - ELSE() - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip") - ENDIF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + ENDIF() ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR CMAKE_C_COMPILER_ID MATCHES "^Clang$" AND NOT MSVC) IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")