From: Sean Cross Date: Mon, 7 Nov 2022 03:02:08 +0000 (-0800) Subject: [builtins] Check __SIZEOF_INT128__ for CRT_HAS_128BIT X-Git-Tag: upstream/17.0.6~28388 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c80e7a2943ade7b999c14ad582b52035098e5ae;p=platform%2Fupstream%2Fllvm.git [builtins] Check __SIZEOF_INT128__ for CRT_HAS_128BIT When building libstd on Rust for a riscv32 target, `compiler-rt` fails to build with the following error: ``` running: "riscv-none-elf-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv32imac" "-mabi=ilp32" "-mcmodel=medany" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-fomit-frame-pointer" "-ffile-prefix-map=E:\\Code\\Xous\\rust-next\\src\\llvm-project\\compiler-rt=." "-DVISIBILITY_HIDDEN" "-o" "E:\\Code\\Xous\\rust-next\\target\\riscv32imac-unknown-xous-elf\\release\\build\\compiler_builtins-b0d7dd25c6999904\\out\\absvdi2.o" "-c" "E:\\Code\\Xous\\rust-next\\src\\llvm-project\\compiler-rt\\lib/builtins\\absvdi2.c" cargo:warning=In file included from E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\int_lib.h:99, cargo:warning= from E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\absvdi2.c:13: cargo:warning=E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\int_types.h:79:1: error: unable to emulate 'TI' cargo:warning= 79 | typedef int ti_int __attribute__((mode(TI))); cargo:warning= | ^~~~~~~ cargo:warning=E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\int_types.h:80:1: error: unable to emulate 'TI' cargo:warning= 80 | typedef unsigned tu_int __attribute__((mode(TI))); cargo:warning= | ^~~~~~~ exit code: 1 ``` This is because 128-bit support is gated on the `__riscv` compiler macro which is valid for both rv32 and rv64. However, only rv64 has 128-bit support, so this fails when building for rv32. Add a check for `__SIZEOF_INT128__` to ensure that 128-bit support is only enabled on targets that support it. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D137485 --- diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index 7a72de4..e94d315 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -64,7 +64,7 @@ typedef union { } udwords; #if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \ - defined(__riscv) || defined(_WIN64) + defined(__SIZEOF_INT128__) || defined(_WIN64) #define CRT_HAS_128BIT #endif