diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake @@ -239,6 +239,10 @@ test_target_arch(wasm64 "" "--target=wasm64-unknown-unknown") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "ve") test_target_arch(ve "__ve__" "--target=ve-unknown-none") + elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "generic_ldbl80_test") + test_target_arch(generic_ldbl80 "" "-mlong-double-80 -DGENERIC_TARGET") + elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "generic_ldbl128_test") + test_target_arch(generic_ldbl128 "" "-mlong-double-128 -DGENERIC_TARGET") endif() set(COMPILER_RT_OS_SUFFIX "") endif() diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake --- a/compiler-rt/cmake/builtin-config-ix.cmake +++ b/compiler-rt/cmake/builtin-config-ix.cmake @@ -39,6 +39,17 @@ set(WASM64 wasm64) set(VE ve) +# Build as many generic LibCall implementations as possible while not using any +# target-specific implementations. +# This is intended for local testing only to help catch bugs for generic LibCall +# implementations that are normally shadowed by target-specific ones or +# not built at all (such as float128-related code on some X86 targets) on a +# developer machine. +# NB: The test results may be not absolutely reliable (at least when using +# non-default size of `long double` due to using system-provided libm), +# so false positives are possible. +set(GENERIC_FOR_TESTS generic_ldbl80 generic_ldbl128) + if(APPLE) set(ARM64 arm64 arm64e) set(ARM32 armv7 armv7k armv7s) @@ -49,7 +60,8 @@ ${X86} ${X86_64} ${ARM32} ${ARM64} ${HEXAGON} ${MIPS32} ${MIPS64} ${PPC64} ${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9} - ${WASM32} ${WASM64} ${VE}) + ${WASM32} ${WASM64} ${VE} + ${GENERIC_FOR_TESTS}) include(CompilerRTUtils) include(CompilerRTDarwinUtils) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -603,6 +603,16 @@ ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES}) +# For local testing only. +set(generic_ldbl80_SOURCES + ${GENERIC_SOURCES} + ${x86_80_BIT_SOURCES} +) +set(generic_ldbl128_SOURCES + ${GENERIC_SOURCES} + ${GENERIC_TF_SOURCES} +) + add_custom_target(builtins) set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc") diff --git a/compiler-rt/test/builtins/Unit/addtf3_test.c b/compiler-rt/test/builtins/Unit/addtf3_test.c --- a/compiler-rt/test/builtins/Unit/addtf3_test.c +++ b/compiler-rt/test/builtins/Unit/addtf3_test.c @@ -65,6 +65,7 @@ UINT64_C(0x61e58dd6c51eb77c))) return 1; +#if !defined(GENERIC_TARGET) #if (defined(__arm__) || defined(__aarch64__)) && defined(__ARM_FP) || \ defined(i386) || defined(__x86_64__) // Rounding mode tests on supported architectures @@ -95,6 +96,7 @@ UINT64_C(0x70a3d70a3d70a3d7))) return 1; #endif +#endif // !defined(GENERIC_TARGET) #else printf("skipped\n"); diff --git a/compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c b/compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c --- a/compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c +++ b/compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c @@ -6,7 +6,11 @@ #include "fp_lib.h" #include "int_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +// GENERIC_TARGET may have non-default sizeof(long double), so it is useless +// to compare __compiler_rt_logbl() against native logbl(). + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && \ + !defined(GENERIC_TARGET) int test__compiler_rt_logbl(fp_t x) { fp_t crt_value = __compiler_rt_logbl(x); @@ -38,7 +42,8 @@ #endif int main() { -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && \ + !defined(GENERIC_TARGET) const unsigned N = sizeof(cases) / sizeof(cases[0]); unsigned i; for (i = 0; i < N; ++i) { diff --git a/compiler-rt/test/builtins/Unit/divtc3_test.c b/compiler-rt/test/builtins/Unit/divtc3_test.c --- a/compiler-rt/test/builtins/Unit/divtc3_test.c +++ b/compiler-rt/test/builtins/Unit/divtc3_test.c @@ -6,6 +6,11 @@ // Bug 42493 // XFAIL: sparc-target-arch // + +// `long double` should have its default target-specific size +// to be `classify()`ed properly. +// XFAIL: generic_ldbl128-target-arch + #include #include "int_lib.h" diff --git a/compiler-rt/test/builtins/Unit/divxc3_test.c b/compiler-rt/test/builtins/Unit/divxc3_test.c --- a/compiler-rt/test/builtins/Unit/divxc3_test.c +++ b/compiler-rt/test/builtins/Unit/divxc3_test.c @@ -5,6 +5,10 @@ // UNSUPPORTED: mips // REQUIRES: c99-complex +// `long double` should have its default target-specific size +// to be `classify()`ed properly. +// XFAIL: generic_ldbl80-target-arch + #if !_ARCH_PPC #include "int_lib.h" diff --git a/compiler-rt/test/builtins/Unit/subtf3_test.c b/compiler-rt/test/builtins/Unit/subtf3_test.c --- a/compiler-rt/test/builtins/Unit/subtf3_test.c +++ b/compiler-rt/test/builtins/Unit/subtf3_test.c @@ -58,6 +58,7 @@ UINT64_C(0xa44a7bca780a166c))) return 1; +#if !defined(GENERIC_TARGET) #if (defined(__arm__) || defined(__aarch64__)) && defined(__ARM_FP) || \ defined(i386) || defined(__x86_64__) // Rounding mode tests on supported architectures @@ -87,6 +88,7 @@ UINT64_C(0x70a3d70a3d70a3d7))) return 1; #endif +#endif // !defined(GENERIC_TARGET) #else printf("skipped\n");