From eca5347d2b33d69fb9d189a158c7fcd55fb3f44a Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Thu, 23 May 2024 22:41:10 +0000 Subject: [PATCH] ANDROID: kleaf: fix kselftests build for arm 32bit When the kselftests are built for 32b ARM, we use the compiler flag '--target=arm-linux-androideabi31' but do not specify the default CPU target. This causes calls to '__sync_bool_compare_and_swap' in the kselftest harness to be expanded to a libcall to '__sync_val_compare_and_swap_1'. This function is explicitly deprecated by GCC's own docs, and LLVM's compiler-rt does not provide it, resulting in a linkage failure when building the selftests for arm32. Explicitly specify a target CPU so that LLVM can expand this intrinsic call inline properly. The kernel should look to use (the admittedly less ergonomic) '__atomic_compare_exchange' instead. Bug: 342476493 Suggested-by: Nick Desaulniers Suggested-by: Yifan Hong Change-Id: Ife1137ed4a19c48403e1a8c6a8af39d7e19f53b0 Signed-off-by: Carlos Llamas --- BUILD.bazel | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index c57158d132e5..bbd22c58e039 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1099,6 +1099,10 @@ cc_binary_with_abi( cc_binary_with_abi( name = "kselftest_rtc_rtctest", srcs = ["tools/testing/selftests/rtc/rtctest.c"], + copts = select({ + ":arm": ["-mcpu=cortex-a8"], + "//conditions:default": [], + }), path_prefix = _KSELFTEST_DIR, target_compatible_with = ["@platforms//os:android"], visibility = ["//visibility:private"],