Skip to content

Commit 7c80e7a

Browse files
xobsMaskRay
authored andcommitted
[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
1 parent 7c50bcb commit 7c80e7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/builtins/int_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef union {
6464
} udwords;
6565

6666
#if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \
67-
defined(__riscv) || defined(_WIN64)
67+
defined(__SIZEOF_INT128__) || defined(_WIN64)
6868
#define CRT_HAS_128BIT
6969
#endif
7070

0 commit comments

Comments
 (0)