For RISCV32, we must force enable int128 for compiling long double routines using the flag -fforce-enable-int128.
Related clang patch: https://reviews.llvm.org/D43105
Differential D43106
[RISCV] Force enable int128 for compiling long double routines mgrang on Feb 8 2018, 5:51 PM. Authored by
Details For RISCV32, we must force enable int128 for compiling long double routines using the flag -fforce-enable-int128. Related clang patch: https://reviews.llvm.org/D43105
Diff Detail
Event Timeline
Comment Actions Yeah, I think I would feel safer with this being limited to targets where we know that we have an explicit contract for __int128_t. Can you please limit this to the RISCV architecture for the time being? Comment Actions RISCV ABI doc specifies the calling convention for __int128_t ("Scalars wider than 2✕XLEN are passed by reference and are replaced in the argument list with the address."). And llc, at least, appears to correctly honor that. So I think we're okay in terms of ABI stability, but someone should verify that clang emits appropriate IR. Comment Actions Correct, the presence or absence of __int128_t will have no impact on the calling convention. Clang should handle it just fine, and D43106 should be updated to demonstrate this through a test - I'll add a more detailed comment there. Comment Actions Hi all: I propose it should check in the foreach (arch ${BUILTIN_SUPPORTED_ARCH}), because COMPILER_RT_DEFAULT_TARGET_ARCH is not always set (I only set COMPILER_RT_DEFAULT_TARGET_TRIPLE instead of COMPILER_RT_DEFAULT_TARGET_ARCH in my build). And that place seems more like right place to put target specific compilation flags. diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt index 991108b..364a4f6 100644 --- a/lib/builtins/CMakeLists.txt +++ b/lib/builtins/CMakeLists.txt @@ -546,6 +546,12 @@ else () list(APPEND BUILTIN_CFLAGS -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET) endif() + # For RISC-V 32 bits, we must force enable int128 for compiling long + # double routines. + if("${arch}" STREQUAL "riscv32") + list(APPEND BUILTIN_CFLAGS -fforce-enable-int128) + endif() + add_compiler_rt_runtime(clang_rt.builtins STATIC ARCHS ${arch} Comment Actions So, do we want to enable this flag only based on a CMake macro like COMPILER_RT_HAS_FINT128_FLAG, or always add -fforce-enable-int128 to compiler-rt builds for RISCV32? Comment Actions
I think it reasonable since RISCV32 LLVM can't compile compiler-rt without this flag. For RISCV32 GCC, here is no way to build compiler-rt since it don't support either int128_t or -fforce-enable-int128. |
Does it possible only append this flag for target which has sizeof (long double) == 16 and !defined(SIZEOF_INT128)?