diff --git a/libcxx/cmake/caches/AIX.cmake b/libcxx/cmake/caches/AIX.cmake index 31d9a2d4b7275..142399e404c9d 100644 --- a/libcxx/cmake/caches/AIX.cmake +++ b/libcxx/cmake/caches/AIX.cmake @@ -1,5 +1,4 @@ set(CMAKE_BUILD_TYPE Release CACHE STRING "") -set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "") set(CMAKE_C_FLAGS "-D__LIBC_NO_CPP_MATH_OVERLOADS__" CACHE STRING "") set(CMAKE_CXX_FLAGS "-D__LIBC_NO_CPP_MATH_OVERLOADS__" CACHE STRING "") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-G -Wl,-bcdtors:all:-2147483548:s" CACHE STRING "") diff --git a/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp b/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp index 6c84e0dfff2ba..a97adcd7c50c6 100644 --- a/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp +++ b/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp @@ -27,15 +27,21 @@ // Make sure the install_name is /usr/lib. // -// In particular, make sure we don't use any @rpath in the load commands. When building as -// a system library, it is important to hardcode the installation paths in the dylib, because -// various tools like dyld and ld64 will treat us specially if they recognize us as being a -// system library. +// In particular, make sure we don't use any @rpath-relative paths in the load commands. +// When building as a system library, it is important to hardcode the installation paths +// in the dylib, because various tools like dyld and ld64 will treat us specially if they +// recognize us as being a system library. // // TODO: We currently don't do that correctly in the CMake build. // // XRUNX: otool -L "%{lib}/libc++.1.dylib" | grep '/usr/lib/libc++.1.dylib' -// XRUNX: ! otool -l "%{lib}/libc++.1.dylib" | grep -E "LC_RPATH|@loader_path|@rpath" +// XRUNX: otool -l "%{lib}/libc++.1.dylib" | grep --invert-match -E "@loader_path|@rpath" + +// Make sure we don't set a RPATH when we build the library. Since we are building a system +// library, we are supposed to find our dependencies at the usual system-provided locations, +// which doesn't require setting a RPATH in the library itself. +// +// RUN: otool -l "%{lib}/libc++.1.dylib" | grep --invert-match -e "LC_RPATH" // Make sure the compatibility_version of libc++ is 1.0.0. // Failure to respect this can result in applications not being able to find libc++ diff --git a/libcxx/test/libcxx/vendor/llvm/apple-install-properties.sh.cpp b/libcxx/test/libcxx/vendor/llvm/apple-install-properties.sh.cpp new file mode 100644 index 0000000000000..e89cefe252ef6 --- /dev/null +++ b/libcxx/test/libcxx/vendor/llvm/apple-install-properties.sh.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// REQUIRES: stdlib=libc++ && target={{.+}}-apple-{{.+}} + +// This file checks various properties of the installation of libc++ when built as +// part of the LLVM releases, on Apple platforms. + +// Make sure we install the libc++ headers in the right location. +// +// RUN: stat "%{include}/__config" + +// Make sure we install libc++.1.dylib and libc++experimental.a in the right location. +// +// RUN: stat "%{lib}/libc++.1.dylib" +// RUN: stat "%{lib}/libc++experimental.a" + +// Make sure we install a symlink from libc++.dylib to libc++.1.dylib. +// +// RUN: stat "%{lib}/libc++.dylib" +// RUN: readlink "%{lib}/libc++.dylib" | grep "libc++.1.dylib" + +// Make sure we don't set a RPATH when we build the library. Since we are building a system +// library, we are supposed to find our dependencies at the usual system-provided locations, +// which doesn't require setting a RPATH in the library itself. +// +// RUN: otool -l "%{lib}/libc++.1.dylib" | grep --invert-match -e "LC_RPATH" + +// Make sure the compatibility_version of libc++ is 1.0.0. +// Failure to respect this can result in applications not being able to find libc++ +// when they are loaded by dyld, if the compatibility version was bumped. +// +// RUN: otool -L "%{lib}/libc++.1.dylib" | grep "libc++.1.dylib" | grep "compatibility version 1.0.0" diff --git a/libcxxabi/test/vendor/apple/system-install-properties.sh.cpp b/libcxxabi/test/vendor/apple/system-install-properties.sh.cpp index d4df7b3dff692..8a72cc648ecd0 100644 --- a/libcxxabi/test/vendor/apple/system-install-properties.sh.cpp +++ b/libcxxabi/test/vendor/apple/system-install-properties.sh.cpp @@ -37,7 +37,13 @@ // TODO: We currently don't do that correctly in the CMake build. // // XRUNX: otool -L "%{lib}/libc++abi.dylib" | grep '/usr/lib/libc++abi.dylib' -// XRUNX: ! otool -l "%{lib}/libc++abi.dylib" | grep -E "LC_RPATH|@loader_path|@rpath" +// XRUNX: otool -l "%{lib}/libc++abi.dylib" | grep --invert-match -E "LC_RPATH|@loader_path|@rpath" + +// Make sure we don't set a RPATH when we build the library. Since we are building a system +// library, we are supposed to find our dependencies at the usual system-provided locations, +// which doesn't require setting a RPATH in the library itself. +// +// RUN: otool -l "%{lib}/libc++abi.dylib" | grep --invert-match -e "LC_RPATH" // Make sure the compatibility_version of libc++abi is 1.0.0. Failure to respect this can result // in applications not being able to find libc++abi when they are loaded by dyld, if the diff --git a/libcxxabi/test/vendor/llvm/apple-install-properties.sh.cpp b/libcxxabi/test/vendor/llvm/apple-install-properties.sh.cpp new file mode 100644 index 0000000000000..0d6cfd84256ca --- /dev/null +++ b/libcxxabi/test/vendor/llvm/apple-install-properties.sh.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// REQUIRES: stdlib=libc++ && target={{.+}}-apple-{{.+}} + +// This file checks various properties of the installation of libc++abi when built as +// part of the LLVM releases, on Apple platforms. + +// Make sure we install the libc++abi headers in the right location. +// +// RUN: stat "%{include}/cxxabi.h" + +// Make sure we install libc++abi.dylib in the right location. +// +// RUN: stat "%{lib}/libc++abi.1.dylib" + +// Make sure we install a symlink from libc++abi.dylib to libc++abi.1.dylib. +// +// RUN: stat "%{lib}/libc++abi.dylib" +// RUN: readlink "%{lib}/libc++abi.dylib" | grep "libc++abi.1.dylib" + +// Make sure we don't set a RPATH when we build the library. Since we are building a system +// library, we are supposed to find our dependencies at the usual system-provided locations, +// which doesn't require setting a RPATH in the library itself. +// +// RUN: otool -l "%{lib}/libc++abi.dylib" | grep --invert-match -e "LC_RPATH" + +// Make sure the compatibility_version of libc++abi is 1.0.0. Failure to respect this can result +// in applications not being able to find libc++abi when they are loaded by dyld, if the +// compatibility version was bumped. +// +// RUN: otool -L "%{lib}/libc++abi.dylib" | grep "libc++abi.1.dylib" | grep "compatibility version 1.0.0" diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 010ec879e44a3..36c4e78c26075 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -1,6 +1,8 @@ # This file handles building LLVM runtime sub-projects. cmake_minimum_required(VERSION 3.20.0) +set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) + # Add path for custom and the LLVM build's modules to the CMake module path. set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake