[llvm] RuntimeLibcalls: Add bitset for available libcalls (PR #150869)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 04:08:44 PDT 2025
================
@@ -616,6 +618,21 @@ else ()
endif ()
endif ()
+foreach(i IN ITEMS 8 4)
+ try_compile(SIZEOF_UINTPTR_T_IS_${i}
+ SOURCE_FROM_CONTENT
+ "test-sizeof-uintptr_t.cpp"
+ "#include <cstdint>\n
+ static_assert(sizeof(uintptr_t) == ${i}); int main(){}"
+ CXX_STANDARD 17
+ LOG_DESCRIPTION "testing sizeof(uintptr_t)")
+
+ if(SIZEOF_UINTPTR_T_IS_${i})
+ set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T ${i})
+ break()
+ endif()
+endforeach()
----------------
s-barannikov wrote:
I get the correct value when using x32 ABI:
```cmake
cmake_minimum_required(VERSION 3.25)
project(test LANGUAGES C CXX)
message(STATUS "CMAKE_SIZEOF_VOID_P = ${CMAKE_SIZEOF_VOID_P}")
```
```shell
$ cmake . -DCMAKE_CXX_FLAGS="-mx32"
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
...
-- CMAKE_SIZEOF_VOID_P = 4
```
Internally, it does the same try_compile thing to get the size, except that it checks the size of `void *` instead of `uintptr_t`. I think they should be the same, but checking for uintptr_t size explicitly should be safer.
https://github.com/llvm/llvm-project/pull/150869
More information about the llvm-commits
mailing list