Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,20 @@ ccache - the main reason for not removing `./build` automatically, aside from
simplifying the debugging in case of errors, is not to run `rm -rf` with
computed paths, as this can be harmful to the host system in case of
misconfiguration.

## Testing run-time libraries

It is possible to make use of the build directories configured during a
non-containerized build to execute the tests of run-time libraries.
On an x86_64 host, this requires qemu-user to be installed.

```bash
./build.sh sources ...
./build.sh host-build
cd build/compiler-rt-full-aarch64-linux-pauthtest
ninja check-profile
```

Not all test cases currently pass, nevertheless this environment is basically
usable to evaluate the changes to these libraries against their regression
test suites.
12 changes: 12 additions & 0 deletions cmake/compiler-rt-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ set(COMPILER_RT_BUILD_SANITIZERS FALSE CACHE BOOL "" FORCE)
set(COMPILER_RT_BUILD_XRAY FALSE CACHE BOOL "" FORCE)
set(COMPILER_RT_BUILD_MEMPROF FALSE CACHE BOOL "" FORCE)
set(COMPILER_RT_BUILD_ORC FALSE CACHE BOOL "" FORCE)

# Enable `check-*` targets, so that they can be manually executed after
# building the toolchain with `./build.sh host-build`.
set(test_cflags "")
set(sysroot_lib_path "${TOOLCHAIN_BUILD_INSTALL_DIR}/${TOOLCHAIN_BUILD_TARGET}/usr/lib")
string(APPEND test_cflags " -march=armv8.3-a+pauth")
string(APPEND test_cflags " -Wl,--rpath=${sysroot_lib_path}")
string(APPEND test_cflags " -L ${sysroot_lib_path}")
string(APPEND test_cflags " -Wl,--dynamic-linker=${sysroot_lib_path}/libc.so")
set(COMPILER_RT_TEST_COMPILER_CFLAGS "${test_cflags}" CACHE STRING "" FORCE)
set(COMPILER_RT_CAN_EXECUTE_TESTS TRUE CACHE BOOL "" FORCE)
set(COMPILER_RT_INCLUDE_TESTS TRUE CACHE BOOL "" FORCE)
8 changes: 8 additions & 0 deletions scripts/build-compiler-rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cd "$(dirname "$0")"
. ./global-vars

COMPILER_RT_INSTALL_PREFIX="$("$INSTALL_DIR/bin/clang" --print-resource-dir)"
normalized_triple="$("$INSTALL_DIR/bin/clang" -target $CROSS_TARGET --print-target-triple)"

# Assertion: COMPILER_RT_INSTALL_PREFIX should be under INSTALL_DIR.
rel_install_prefix="$(realpath --relative-to="$INSTALL_DIR" "$COMPILER_RT_INSTALL_PREFIX")"
Expand All @@ -27,4 +28,11 @@ cmake \
-C "$CMAKE_DIR/compiler-rt-common.cmake" \
-C "$CMAKE_DIR/compiler-rt-${COMPILER_RT_BUILD}.cmake"

# Provide the run-time libraries to link the tests executables.
mkdir -p "${BUILD_DIR}/lib/${normalized_triple}"
ln -sr "${COMPILER_RT_INSTALL_PREFIX}/lib/${normalized_triple}/clang_rt.crtbegin.o" \
"${COMPILER_RT_INSTALL_PREFIX}/lib/${normalized_triple}/clang_rt.crtend.o" \
"${COMPILER_RT_INSTALL_PREFIX}/lib/${normalized_triple}/libclang_rt.builtins.a" \
"${BUILD_DIR}/lib/${normalized_triple}"

cmake --build "$BUILD_DIR" --target install -- -j$CPU_COUNT