os_test: arm64: disable C++ and TLS tests depending on compiler
In 64-bit mode, the Thead Local Storage tests currently pass only with
Clang, or GCC 8 or later. Earlier GCC versions (6.2, 7.3) generate an
unsupported relocation type:
* regression_1006 Test Basic OS features
E/LD: e64_relocate:538 Unknown relocation type 1031
E/TC:?? 0 init_with_ldelf:232 ldelf failed with res: 0xffff0005
[...]
regression_1006 FAILED
TLS is not currently useful in itself, since OP-TEE doesn't have multi-
threaded TAs. It was implemented primarily to support C++ because the
GNU C++ runtime depends on it. To avoid failures in the regression
tests of people who upgrade their OP-TEE environment and who possibly
use older toolchains, the TLS tests should be ignored unless a "known
good" compiler is used.
Similarly, since the C++ tests depend on TLS, they need to be disabled
too with Aarch64 GCC < 8 (note they are already disabled with Clang).
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Tested-by: Jerome Forissier <jerome@forissier.org> (QEMU/QEMUv8, GCC 8.3/GCC 6.2/Clang 10)
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
diff --git a/ta/os_test/os_test.c b/ta/os_test/os_test.c
index 4329ed4..cac5820 100644
--- a/ta/os_test/os_test.c
+++ b/ta/os_test/os_test.c
@@ -1301,6 +1301,7 @@
return res;
}
+#if defined(__clang__) || !defined(__aarch64__) || __GNUC__ >= 8
__thread int os_test_tls_a;
__thread int os_test_tls_b = 42;
@@ -1332,6 +1333,17 @@
return TEE_SUCCESS;
}
+#else
+TEE_Result ta_entry_tls_test_main(void)
+{
+ return TEE_ERROR_NOT_SUPPORTED;
+}
+
+TEE_Result ta_entry_tls_test_shlib(void)
+{
+ return TEE_ERROR_NOT_SUPPORTED;
+}
+#endif
static int iterate_hdr_cb(struct dl_phdr_info *info __maybe_unused,
size_t size __unused, void *data)
diff --git a/ta/os_test/sub.mk b/ta/os_test/sub.mk
index 6f230c0..ba6853a 100644
--- a/ta/os_test/sub.mk
+++ b/ta/os_test/sub.mk
@@ -8,7 +8,9 @@
srcs-y += os_test.c
srcs-y += ta_entry.c
srcs-$(CFG_TA_FLOAT_SUPPORT) += test_float_subj.c
-ifneq ($(COMPILER),clang)
+# C++ tests don't work with Clang, and for Aarch64 they require GCC >= 8
+c++-supported := $(shell env echo -e '\#if !defined(__clang__) && (!defined(__aarch64__) || __GNUC__ >= 8)\ny\n\#endif' | $(CC$(sm)) -E -P -)
+ifeq ($(c++-supported),y)
# Profiling (-pg) is disabled for C++ tests because in case it is used for
# function tracing (CFG_FTRACE_SUPPORT=y) then the exception handling code in
# the C++ runtime won't be able to unwind the (modified) stack.
diff --git a/ta/os_test/ta_entry.c b/ta/os_test/ta_entry.c
index 1d8db88..9e3d277 100644
--- a/ta/os_test/ta_entry.c
+++ b/ta/os_test/ta_entry.c
@@ -121,7 +121,7 @@
case TA_OS_TEST_CMD_DL_PHDR_DL:
return ta_entry_dl_phdr_dl();
-#ifdef __clang__
+#if defined(__clang__) || (defined(__aarch64__) && __GNUC__ < 8)
case TA_OS_TEST_CMD_CXX_CTOR_MAIN:
case TA_OS_TEST_CMD_CXX_CTOR_SHLIB:
case TA_OS_TEST_CMD_CXX_CTOR_SHLIB_DL:
diff --git a/ta/os_test_lib/include/os_test_lib.h b/ta/os_test_lib/include/os_test_lib.h
index c04b15f..7629bc7 100644
--- a/ta/os_test_lib/include/os_test_lib.h
+++ b/ta/os_test_lib/include/os_test_lib.h
@@ -11,8 +11,10 @@
int os_test_shlib_add(int a, int b);
void os_test_shlib_panic(void);
+#if defined(__clang__) || !defined(__aarch64__) || __GNUC__ >= 8
extern __thread int os_test_shlib_tls_a;
extern __thread int os_test_shlib_tls_b;
+#endif
TEE_Result os_test_shlib_cxx_ctor(void);
diff --git a/ta/os_test_lib/os_test_lib.c b/ta/os_test_lib/os_test_lib.c
index 17eb9bb..a34a446 100644
--- a/ta/os_test_lib/os_test_lib.c
+++ b/ta/os_test_lib/os_test_lib.c
@@ -16,8 +16,10 @@
DMSG("os_test_global=%d", os_test_global);
}
+#if defined(__clang__) || !defined(__aarch64__) || __GNUC__ >= 8
__thread int os_test_shlib_tls_a;
__thread int os_test_shlib_tls_b = 123;
+#endif
int os_test_shlib_add(int a, int b)
{