diff --git a/SingleSource/UnitTests/AArch64/CMakeLists.txt b/SingleSource/UnitTests/AArch64/CMakeLists.txt index a553298a12..7358d8373b 100644 --- a/SingleSource/UnitTests/AArch64/CMakeLists.txt +++ b/SingleSource/UnitTests/AArch64/CMakeLists.txt @@ -1,10 +1,9 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + if(TARGET_OS STREQUAL "Linux") + list(APPEND CFLAGS --rtlib=compiler-rt) + list(APPEND LDFLAGS --rtlib=compiler-rt) + endif() if(ARCH STREQUAL "AArch64") - set(Source ) - # TODO: this test is currently only supported on Darwin platforms: - if (TARGET_OS MATCHES "Darwin") - list(APPEND Source acle-fmv-features.c) - endif() llvm_singlesource(PREFIX "aarch64-") endif() endif() diff --git a/SingleSource/UnitTests/AArch64/acle-fmv-features.c b/SingleSource/UnitTests/AArch64/acle-fmv-features.c index 97870670a1..1006687918 100644 --- a/SingleSource/UnitTests/AArch64/acle-fmv-features.c +++ b/SingleSource/UnitTests/AArch64/acle-fmv-features.c @@ -196,7 +196,15 @@ CHECK(ssbs2, { CHECK(bti, { // The only test for this requires reading a register that is only // accessible to EL1. - #if defined(__APPLE__) + #ifdef __linux__ + // On linux, the kernel intercepts the trap, and emulates it for EL0 processes. + int val = 0; + asm volatile("mrs %0, ID_AA64PFR1_EL1" : "=r"(val)); + // ID_AA64PFR1_EL1.BT, bits [3:0] = 0b0001 if Branch Target Identification + // mechanism implemented. + if ((val & 0xF) != 0x1) + return false; + #elif defined(__APPLE__) // On Apple platforms, we need to check a sysctl. int32_t val = 0; size_t size = sizeof(val);