mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
We've long created shared objects on AIX using the linker's `-G` option (also offered by the XL front-end). The `-G` option implies `-brtl` and enables runtime linking. This has been largely unnecessary because we provide all dependencies on the link line and both XL and GNU compilers offer builtin behavior to export symbols. Since commit0f150b69d3(AIX: Explicitly compute shared object exports for both XL and GNU, 2019-07-11) we compute exports explicitly and consistently. Therefore runtime linking is no longer necessary for shared objects. We've also long created executables on AIX using the linker's `-brtl` option to enable runtime linking in case they load plugins at runtime. Since commit9f5c2040bf(AIX: Explicitly compute executable exports for both XL and GNU, 2019-07-12) and commit2fa920c0cd(AIX: Create import library for executables with exports, 2019-07-16) we now provide the linker enough information to fully resolve symbols in plugins up front. Therefore runtime linking is no longer necessary for executables. Drop use of `-G` for creating shared objects and use the XL `-qmkshrobj` and GCC `-shared` options instead. Both invoke the linker with the `-bM:SRE -bnoentry` options to create a shared object without runtime linking enabled. Also drop use of `-brtl` for creating executables. Issue: #19163
32 lines
1.5 KiB
CMake
32 lines
1.5 KiB
CMake
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
|
# This module is shared by multiple languages; use include blocker.
|
|
if(__AIX_COMPILER_XL)
|
|
return()
|
|
endif()
|
|
set(__AIX_COMPILER_XL 1)
|
|
|
|
macro(__aix_compiler_xl lang)
|
|
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:")
|
|
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
|
|
string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath")
|
|
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior
|
|
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ")
|
|
set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ")
|
|
|
|
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
|
|
|
|
# Construct the export list ourselves to pass only the object files so
|
|
# that we export only the symbols actually provided by the sources.
|
|
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
|
|
"\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>"
|
|
"<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
|
|
)
|
|
|
|
set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
|
|
"\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
|
|
"<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
|
endmacro()
|