diff --git a/libcxx/cmake/caches/AIX.cmake b/libcxx/cmake/caches/AIX.cmake new file mode 100644 --- /dev/null +++ b/libcxx/cmake/caches/AIX.cmake @@ -0,0 +1,21 @@ +set(CMAKE_BUILD_TYPE Release CACHE STRING "") +set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "") +set(CMAKE_C_FLAGS "-D_ALL_SOURCE -mignore-xcoff-visibility" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-D_ALL_SOURCE -mignore-xcoff-visibility" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-G -Wl,-bcdtors:all:-2147483548:s" CACHE STRING "") + +set(LIBCXX_ABI_VERSION "1" CACHE STRING "") +set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "") +set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "") +set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") +set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "") +set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") +set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "") +set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") + +set(LIBCXXABI_ENABLE_SHARED ON CACHE BOOL "") +set(LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") + +set(LIBUNWIND_ENABLE_SHARED ON CACHE BOOL "") +set(LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") diff --git a/libcxx/utils/ci/aix-install-libcxx.sh b/libcxx/utils/ci/aix-install-libcxx.sh new file mode 100755 --- /dev/null +++ b/libcxx/utils/ci/aix-install-libcxx.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +#===----------------------------------------------------------------------===## +# +# 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 +# +#===----------------------------------------------------------------------===## + +set -e + +PROGNAME="$(basename "${0}")" + +function error() { printf "error: %s\n" "$*"; exit 1; } + +function usage() { +cat < Path to the root of the LLVM monorepo. Only the libcxx, + libcxxabi and libunwind directories are required. + +--build-dir Path to the directory to use for building. This will + contain intermediate build products. + +--install-dir Path to the directory to install the library to. + +--cache The CMake cache to use to control how the library gets built. +EOF +} + +while [[ $# -gt 0 ]]; do + case ${1} in + -h|--help) + usage + exit 0 + ;; + --llvm-root) + llvm_root="${2}" + shift; shift + ;; + --build-dir) + build_dir="${2}" + shift; shift + ;; + --install-dir) + install_dir="${2}" + shift; shift + ;; + --cache) + cache="${2}" + shift; shift + ;; + *) + error "Unknown argument '${1}'" + ;; + esac +done + +for arg in llvm_root build_dir install_dir cache; do + if [ -z ${!arg+x} ]; then + error "Missing required argument '--${arg//_/-}'" + elif [ "${!arg}" == "" ]; then + error "Argument to --${arg//_/-} must not be empty" + fi +done + +# Allow using relative paths +function realpath() { + if [[ $1 = /* ]]; then echo "$1"; else echo "$(pwd)/${1#./}"; fi +} +for arg in llvm_root build_dir install_dir cache; do + path="$(realpath "${!arg}")" + eval "${arg}=\"${path}\"" +done + +function step() { + separator="$(printf "%0.s-" $(seq 1 ${#1}))" + echo + echo "${separator}" + echo "${1}" + echo "${separator}" +} + +for bitmode in 32 64; do + step "Building libc++.a, libc++abi.a and libunwind.a for ${bitmode}-bit" + mkdir -p "${build_dir}/${bitmode}" + (cd "${build_dir}/${bitmode}" && + env OBJECT_MODE="${bitmode}" cmake "${llvm_root}/llvm" \ + -C "${cache}" \ + -GNinja \ + -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi;libunwind" \ + -DCMAKE_INSTALL_PREFIX="${build_dir}/${bitmode}-install" + ) + env OBJECT_MODE="${bitmode}" cmake --build "${build_dir}/${bitmode}" --target install-cxx install-cxxabi install-unwind +done + + +step "Merging the resulting 32-bit and 64-bit libc++.a, libc++abi.a and libunwind.a into single libraries" +if [[ ! -d "${install_dir}/lib" ]]; then + mkdir -p "${install_dir}/lib" +fi + +LIBS="libc++ libc++abi libunwind" +cd "${install_dir}/lib" +for lib in ${LIBS}; do + cp "${build_dir}/32/lib/${lib}.a" . + ar -X64 -x "${build_dir}/64/lib/${lib}.a" + ar -X64 r "${lib}.a" "${lib}.so.1" + rm "${lib}.so.1" +done + +# Install the headers by copying the headers from one of the builds into the +# install directory. Headers from both bitmodes should be the same. +headers_prefix="${install_dir}" + +step "Installing the libc++, libc++abi and libunwind headers to ${headers_prefix}/include" +cp -r "${build_dir}/32-install/include" "${headers_prefix}/include" +cp -r "${llvm_root}/libcxxabi/include/*" "${headers_prefix}/include" # TODO: libcxxabi should install its headers in CMake + +step "Installing the libc++, libc++abi and libunwind licenses" +mkdir -p "${headers_prefix}/notices" +cp "${llvm_root}/libcxx/LICENSE.TXT" "${headers_prefix}/notices/libcxx.txt" +cp "${llvm_root}/libcxxabi/LICENSE.TXT" "${headers_prefix}/notices/libcxxabi.txt" +cp "${llvm_root}/libunwind/LICENSE.TXT" "${headers_prefix}/notices/libunwind.txt"