[all-commits] [llvm/llvm-project] 7c80e7: [builtins] Check __SIZEOF_INT128__ for CRT_HAS_128BIT

Sean Cross via All-commits all-commits at lists.llvm.org
Sun Nov 6 19:02:20 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c80e7a2943ade7b999c14ad582b52035098e5ae
      https://github.com/llvm/llvm-project/commit/7c80e7a2943ade7b999c14ad582b52035098e5ae
  Author: Sean Cross <sean at xobs.io>
  Date:   2022-11-06 (Sun, 06 Nov 2022)

  Changed paths:
    M compiler-rt/lib/builtins/int_types.h

  Log Message:
  -----------
  [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




More information about the All-commits mailing list