diff --git a/libcxx/cmake/caches/Armv6M-picolibc.cmake b/libcxx/cmake/caches/Armv6M-picolibc.cmake new file mode 100644 --- /dev/null +++ b/libcxx/cmake/caches/Armv6M-picolibc.cmake @@ -0,0 +1,38 @@ +set(CMAKE_ASM_COMPILER_TARGET "armv6m-none-eabi" CACHE STRING "") +set(CMAKE_CXX_COMPILER_TARGET "armv6m-none-eabi" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-mfloat-abi=soft" CACHE STRING "") +set(CMAKE_C_COMPILER_TARGET "armv6m-none-eabi" CACHE STRING "") +set(CMAKE_C_FLAGS "-mfloat-abi=soft" CACHE STRING "") +set(CMAKE_SYSTEM_NAME Generic CACHE STRING "") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "") +set(COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "") +set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "") +set(COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "") +set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "") +set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "") +set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "") +set(LIBCXXABI_BAREMETAL ON CACHE BOOL "") +set(LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "") +set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "") +set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "") +set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "") +set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") +set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") +set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE STRING "") +set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "") +set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "") +set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "") +set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "") +set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "") +set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "") +set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "") +set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "") +set(LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "") +set(LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") +set(LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "") +set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") +set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "") diff --git a/libcxx/utils/ci/BOT_OWNERS.txt b/libcxx/utils/ci/BOT_OWNERS.txt --- a/libcxx/utils/ci/BOT_OWNERS.txt +++ b/libcxx/utils/ci/BOT_OWNERS.txt @@ -10,7 +10,7 @@ N: Linaro Toolchain Working Group E: linaro-toolchain@lists.linaro.org -D: Armv7, Armv8, AArch64 +D: Arm platforms N: LLVM on Power E: powerllvm@ca.ibm.com diff --git a/libcxx/utils/ci/build-picolibc.sh b/libcxx/utils/ci/build-picolibc.sh new file mode 100755 --- /dev/null +++ b/libcxx/utils/ci/build-picolibc.sh @@ -0,0 +1,95 @@ +#!/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 directory to use for building. + +--install-dir Path to the directory to install the library to. +EOF +} + +while [[ $# -gt 0 ]]; do + case ${1} in + -h|--help) + usage + exit 0 + ;; + --build-dir) + build_dir="${2}" + shift; shift + ;; + --install-dir) + install_dir="${2}" + shift; shift + ;; + *) + error "Unknown argument '${1}'" + ;; + esac +done + +for arg in build_dir install_dir; do + if [ -z ${!arg+x} ]; then + error "Missing required argument '--${arg//_/-}'" + elif [ "${!arg}" == "" ]; then + error "Argument to --${arg//_/-} must not be empty" + fi +done + + +echo "--- Downloading picolibc" +picolibc_source_dir="${build_dir}/picolibc-source" +picolibc_build_dir="${build_dir}/picolibc-build" +mkdir -p "${picolibc_source_dir}" +mkdir -p "${picolibc_build_dir}" +# Download the version of picolibc that was the latest at the time this script was written. +curl -L "https://github.com/picolibc/picolibc/archive/refs/tags/1.8.2.tar.gz" | tar -xz --strip-components=1 -C "${picolibc_source_dir}" + + +cat < "${picolibc_build_dir}/meson-cross-build.txt" +[binaries] +c = ['clang', '--target=armv6m-none-eabi', '-mfloat-abi=soft', '-nostdlib'] +ar = 'llvm-ar' +as = 'llvm-as' +ld = 'lld' +strip = 'llvm-strip' +[host_machine] +system = 'none' +cpu_family = 'arm' +cpu = 'arm' +endian = 'little' +[properties] +skip_sanity_check = true +EOF + +venv_dir="${build_dir}/meson-venv" +python3 -m venv "${venv_dir}" +# Install the version of meson that was the latest at the time this script was written. +"${venv_dir}/bin/pip" install "meson==1.1.1" + +"${venv_dir}/bin/meson" setup \ + -Dincludedir=include -Dlibdir=lib -Dspecsdir=none -Dmultilib=false \ + --prefix "${install_dir}" \ + --cross-file "${picolibc_build_dir}/meson-cross-build.txt" \ + "${picolibc_build_dir}" \ + "${picolibc_source_dir}" + +"${venv_dir}/bin/meson" install -C "${picolibc_build_dir}" diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -993,6 +993,20 @@ limit: 2 timeout_in_minutes: 120 + - label: "Armv6-M picolibc" + command: "libcxx/utils/ci/run-buildbot armv6m-picolibc" + artifact_paths: + - "**/test-results.xml" + - "**/*.abilist" + agents: + queue: "libcxx-builders-linaro-arm" + arch: "aarch64" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + timeout_in_minutes: 120 + - group: "AIX" steps: - label: "AIX (32-bit)" diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -603,6 +603,27 @@ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake" check-runtimes ;; +armv6m-picolibc) + clean + + # To make it easier to get this builder up and running, build picolibc + # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds. + # This could be optimised by building picolibc into the Docker container. + ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \ + --build-dir "${BUILD_DIR}" \ + --install-dir "${INSTALL_DIR}" + + # -Wno-atomic-alignment to disable warning-as-error: + # cxx_atomic_impl.h:376:12: large atomic operation may incur significant performance + # penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) + flags="--sysroot=${INSTALL_DIR} -Wno-atomic-alignment" + generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv6M-picolibc.cmake" \ + -DCMAKE_C_FLAGS="${flags}" \ + -DCMAKE_CXX_FLAGS="${flags}" + + echo "--- Installing libc++, libc++abi and libunwind to a fake location" + ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi install-unwind +;; clang-cl-dll) clean # TODO: Currently, building with the experimental library breaks running