From 2c1488cabe58bc4d30d71e24c3f4f93151ba203a Mon Sep 17 00:00:00 2001 From: HONG Yifan Date: Wed, 25 Sep 2024 12:02:38 -0700 Subject: [PATCH] ANDROID: Add bionic-compat.h to kselftests. Bionic does not provide pthread_cancel(). Copy bionic-compat.h from previous fork of kselftests to here to solve the issue. Link: https://android.googlesource.com/platform/external/linux-kselftest/+/refs/heads/main/android/include/bionic-compat.h Bug: 369330443 Change-Id: Ifa1b5cbe55d6e8ab007787d94e31902ed8dfc37c Signed-off-by: HONG Yifan Signed-off-by: Edward Liaw --- BUILD.bazel | 17 ++++++++++++----- .../selftests/android/include/bionic-compat.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tools/testing/selftests/android/include/bionic-compat.h diff --git a/BUILD.bazel b/BUILD.bazel index 6de0a2ef51d6..f7cfe267ee9e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1295,6 +1295,12 @@ _KSELFTEST_COPTS = [ "-O3", "-pthread", "-std=gnu99", + "-include", + paths.join( + package_relative_label(":x").workspace_root, + package_relative_label(":x").package, + "tools/testing/selftests/android/include/bionic-compat.h", + ), ] + select({ ":arm": ["-mcpu=cortex-a8"], "//conditions:default": [], @@ -1326,7 +1332,9 @@ config_setting( cc_library( name = "kselftest_headers_lib", - hdrs = glob(["tools/testing/selftests/*.h"]), + hdrs = glob(["tools/testing/selftests/*.h"]) + [ + "tools/testing/selftests/android/include/bionic-compat.h", + ], copts = _KSELFTEST_COPTS, defines = [ "_GNU_SOURCE=", @@ -1398,6 +1406,9 @@ cc_library( ], copts = _KSELFTEST_COPTS, visibility = ["//visibility:private"], + deps = [ + ":kselftest_headers_lib", + ], ) cc_binary_with_abi( @@ -1408,7 +1419,6 @@ cc_binary_with_abi( target_compatible_with = ["@platforms//os:android"], visibility = ["//visibility:private"], deps = [ - ":kselftest_headers_lib", ":kselftest_vdso", ], ) @@ -1421,7 +1431,6 @@ cc_binary_with_abi( target_compatible_with = ["@platforms//os:android"], visibility = ["//visibility:private"], deps = [ - ":kselftest_headers_lib", ":kselftest_vdso", ], ) @@ -1434,7 +1443,6 @@ cc_binary_with_abi( target_compatible_with = ["@platforms//os:android"], visibility = ["//visibility:private"], deps = [ - ":kselftest_headers_lib", ":kselftest_vdso", ], ) @@ -1447,7 +1455,6 @@ cc_binary_with_abi( target_compatible_with = ["@platforms//os:android"], visibility = ["//visibility:private"], deps = [ - ":kselftest_headers_lib", ":kselftest_vdso", ], ) diff --git a/tools/testing/selftests/android/include/bionic-compat.h b/tools/testing/selftests/android/include/bionic-compat.h new file mode 100644 index 000000000000..109fb44247eb --- /dev/null +++ b/tools/testing/selftests/android/include/bionic-compat.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __BIONIC_COMPAT_H +#define __BIONIC_COMPAT_H + +#define _GNU_SOURCE +#include + +static inline int pthread_cancel(pthread_t thread) +{ + return 0; +} + +#endif /* __BIONIC_COMPAT_H */