[compiler-rt] [compiler-rt] Work around incompatible Windows definitions of (S)SIZE_T (PR #106311)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 02:30:17 PDT 2024
mstorsjo wrote:
> I can't successfully build the libraries since I get linker errors, but I've confirmed that the latest version of this patch fixes the compilation errors reported by @mstorsjo
Indeed, this version does build successfully with MSVC, and it does get past the earlier quoted errors when building for mingw targets, but for mingw x86_64 (and MSVC x86_64 too), it fails on other issues due to some of the other, new static asserts you've added here:
```
/home/martin/code/llvm-mingw/llvm-project/compiler-rt/lib/interception/interception_type_test.cpp:44:16: error: static assertion failed due to requirement 'sizeof(unsigned long long) == sizeof(long)':
44 | COMPILER_CHECK(sizeof(::OFF_T) == sizeof(off_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/martin/code/llvm-mingw/llvm-project/compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:357:44: note: expanded from macro 'COMPILER_CHECK'
357 | #define COMPILER_CHECK(pred) static_assert(pred, "")
| ^~~~
/home/martin/code/llvm-mingw/llvm-project/compiler-rt/lib/interception/interception_type_test.cpp:44:32: note: expression evaluates to '8 == 4'
44 | COMPILER_CHECK(sizeof(::OFF_T) == sizeof(off_t));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/home/martin/code/llvm-mingw/llvm-project/compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:357:44: note: expanded from macro 'COMPILER_CHECK'
357 | #define COMPILER_CHECK(pred) static_assert(pred, "")
| ^~~~
1 error generated.
```
FWIW, it should be quite easy to test the build for mingw targets, with llvm-mingw. To do that:
1. Clone https://github.com/mstorsjo/llvm-mingw
2. Within your `llvm-mingw` checkout, check out (or symlink) your `llvm-project` repo, so that you have `llvm-mingw/llvm-project` containing your compiler-rt code to be tested
3. Grab an existing release, e.g. https://github.com/mstorsjo/llvm-mingw/releases/tag/20240820, and download a suitable package for you (e.g. an x86_64 linux build), e.g. [llvm-mingw-20240820-ucrt-ubuntu-20.04-x86_64.tar.xz](https://github.com/mstorsjo/llvm-mingw/releases/download/20240820/llvm-mingw-20240820-ucrt-ubuntu-20.04-x86_64.tar.xz), and unpack that somewhere
4. Within the `llvm-mingw` directory, run `./build-compiler-rt.sh --build-sanitizers <path-to-unpacked-toolchain>`. That uses the toolchain from step 3, which is expected to be unpacked in `<path-to-unpacked-toolchain>`, building the compiler-rt code in `llvm-mingw/llvm-project` and installing it on top of your unpacked toolchain. This tries building it for both `i686` and `x86_64`.
The compiler-rt sanitizers are buildable for armv7 and aarch64 too, but the `build-compiler-rt.sh` script skips that for now (it's not buildable for armv7 in the 19.x release branch), but if you want to, you can rip out the code for skipping those arches in the script, in order to test building for all 4 architectures.
https://github.com/llvm/llvm-project/pull/106311
More information about the llvm-commits
mailing list