[llvm] 14696ba - [AIX] Update rpath for BUILD_SHARED_LIBS
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 20 13:31:59 PDT 2021
Author: Jinsong Ji
Date: 2021-03-20T20:31:43Z
New Revision: 14696baaf4c43fe53f738bc292bbe169eed93d5d
URL: https://github.com/llvm/llvm-project/commit/14696baaf4c43fe53f738bc292bbe169eed93d5d
DIFF: https://github.com/llvm/llvm-project/commit/14696baaf4c43fe53f738bc292bbe169eed93d5d.diff
LOG: [AIX] Update rpath for BUILD_SHARED_LIBS
BUILD_SHARED_LIBS build llvm component as shared library,
which can reduce the size a lot.
Normally, the binary use ORIGIN../lib to load component libraries,
unfortunatly, ORIGIN is not supported by AIX ld.
We hardcoded the build lib and install lib path in rpath for now
to enable BUILD_SHARED_LIBS build.
Understand that this is not perfect solution,
we can update this when we find better solution.
Reviewed By: hubert.reinterpretcast
Differential Revision: https://reviews.llvm.org/D98901
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index da1b78b4f530..2f055c779962 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2105,6 +2105,12 @@ function(llvm_setup_rpath name)
if (APPLE)
set(_install_name_dir INSTALL_NAME_DIR "@rpath")
set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND BUILD_SHARED_LIBS)
+ # $ORIGIN is not interpreted at link time by aix ld.
+ # Since BUILD_SHARED_LIBS is only recommended for use by developers,
+ # hardcode the rpath to build/install lib dir first in this mode.
+ # FIXME: update this when there is better solution.
+ set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
elseif(UNIX)
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index c250a776517d..0c575b6608b0 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -212,6 +212,11 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
append("-bcdtors:mbr"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
+ if(BUILD_SHARED_LIBS)
+ # See rpath handling in AddLLVM.cmake
+ # FIXME: Remove this warning if this rpath is no longer hardcoded.
+ message(WARNING "Build and install environment path info may be exposed; binaries will also be unrelocatable.")
+ endif()
endif()
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
More information about the llvm-commits
mailing list