-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] make off_t 32b for 32b arm #77350
Conversation
Fixes the following diagnostic: llvm-project/libc/src/sys/mman/linux/mmap.cpp:44:59: error: implicit conversion loses integer precision: 'off_t' (aka 'long long') to 'long' [-Werror,-Wshorten-64-to-32] size, prot, flags, fd, offset); ^~~~~~ It looks like off_t is a curious types on different platforms. FWICT, it's 32b on arm (at least for arm-linux-gnueabi) but 64b elsewhere (including 32b riscv-linux-gnu).
@llvm/pr-subscribers-libc Author: Nick Desaulniers (nickdesaulniers) ChangesFixes the following diagnostic:
It looks like off_t is a curious types on different platforms. FWICT, it's 32b Full diff: https://github.com/llvm/llvm-project/pull/77350.diff 1 Files Affected:
diff --git a/libc/include/llvm-libc-types/off_t.h b/libc/include/llvm-libc-types/off_t.h
index 111b29aa68d875..f1c38d6bb5ad43 100644
--- a/libc/include/llvm-libc-types/off_t.h
+++ b/libc/include/llvm-libc-types/off_t.h
@@ -9,6 +9,10 @@
#ifndef __LLVM_LIBC_TYPES_OFF_T_H__
#define __LLVM_LIBC_TYPES_OFF_T_H__
+#if defined(__LP64__) || defined (__riscv)
typedef __INT64_TYPE__ off_t;
+#else
+typedef __INT32_TYPE__ off_t;
+#endif // __LP64__ || __riscv
#endif // __LLVM_LIBC_TYPES_OFF_T_H__
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
alternately, we could just check for |
bionic has some docs about this
No, i386 uses 32b. |
oh, looks like the build is still red :( |
|
This is still broken after llvm#77350. Disable the warning for now, and fix properly once the buildbot it back to green. Link: llvm#77395
While trying to enable -Werror (llvm#74506), the 32b ARM build bot reported an error stemming from -Wshorten-64-to-32 related to usages of `off_t`. I failed to fix these properly in llvm#77350 (the 32b ARM build is not a fullbuild) and llvm#77396. It turns out, the preprocessor defines `-D_LARGEFILE_SOURCE` and `-D_FILE_OFFSET_BITS=64` were being set for llvmlibc when using the cmake build system. In particular, these preprocessor defines are feature test macros used by glibc, and which have effects no the corresponding ABI for types like `off_t` (for instance, should `off_t` be 32b or 64b on 32b targets). But who was setting these? Turns out that the use of add_compile_definitions in llvm/cmake/modules/HandleLLVMOptions.cmake was setting these (and more), which is then inherited by every subdirectory. While some of these defines maybe make sense for host builds, they do not make sense for libraries for the target. The full list of defines being set prior to this commit: - `-D_GNU_SOURCE` - `-D_FILE_OFFSET_BITS=64` - `-D_DEBUG` - `-D_GLIBCXX_ASSERTIONS` - `-D_LARGEFILE_SOURCE` - `-D_FILE_OFFSET_BITS=64` - `-D__STDC_CONSTANT_MACROS` - `-D__STDC_FORMAT_MACROS` - `-D__STDC_LIMIT_MACROS` If we desire any of the above, we should manually reset them. Fix this by resetting COMPILE_DEFINITIONS for the libc/ subdirectory. Side note: to debug 'directory properties' in cmake, you first need to use `get_directory_property` to fetch the corresponding value into a variable first, then that variable can be printed via `message`. Link: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fFILE_005fOFFSET_005fBITS Link: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fFILE_005fOFFSET_005fBITS Fixes: llvm#77395
While trying to enable -Werror (#74506), the 32b ARM build bot reported an error stemming from -Wshorten-64-to-32 related to usages of `off_t`. I failed to fix these properly in #77350 (the 32b ARM build is not a fullbuild) and #77396. It turns out, the preprocessor defines `-D_LARGEFILE_SOURCE` and `-D_FILE_OFFSET_BITS=64` were being set for llvmlibc when using the cmake build system. In particular, these preprocessor defines are feature test macros used by glibc, and which have effects no the corresponding ABI for types like `off_t` (for instance, should `off_t` be 32b or 64b on 32b targets). But who was setting these? Turns out that the use of add_compile_definitions in llvm/cmake/modules/HandleLLVMOptions.cmake was setting these (and more), which is then inherited by every subdirectory. While some of these defines maybe make sense for host builds, they do not make sense for libraries for the target. The full list of defines being set prior to this commit: - `-D_GNU_SOURCE` - `-D_FILE_OFFSET_BITS=64` - `-D_DEBUG` - `-D_GLIBCXX_ASSERTIONS` - `-D_LARGEFILE_SOURCE` - `-D_FILE_OFFSET_BITS=64` - `-D__STDC_CONSTANT_MACROS` - `-D__STDC_FORMAT_MACROS` - `-D__STDC_LIMIT_MACROS` If we desire any of the above, we should manually reset them. Fix this by resetting COMPILE_DEFINITIONS for the libc/ subdirectory. Side note: to debug 'directory properties' in cmake, you first need to use `get_directory_property` to fetch the corresponding value into a variable first, then that variable can be printed via `message`. Link: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fFILE_005fOFFSET_005fBITS Link: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fFILE_005fOFFSET_005fBITS Fixes: #77395
This reverts commit ce1305a. The correct fix was commit f1f1875 ("[libc][cmake] reset COMPILE_DEFINITIONS (llvm#77810)") Link: llvm#77395
Fixes the following diagnostic: llvm-project/libc/src/sys/mman/linux/mmap.cpp:44:59: error: implicit conversion loses integer precision: 'off_t' (aka 'long long') to 'long' [-Werror,-Wshorten-64-to-32] size, prot, flags, fd, offset); ^~~~~~ It looks like off_t is a curious types on different platforms. FWICT, it's 32b on arm (at least for arm-linux-gnueabi) but 64b elsewhere (including 32b riscv32-linux-gnu).
This is still broken after llvm#77350. Disable the warning for now, and fix properly once the buildbot it back to green. Link: llvm#77395
While trying to enable -Werror (llvm#74506), the 32b ARM build bot reported an error stemming from -Wshorten-64-to-32 related to usages of `off_t`. I failed to fix these properly in llvm#77350 (the 32b ARM build is not a fullbuild) and llvm#77396. It turns out, the preprocessor defines `-D_LARGEFILE_SOURCE` and `-D_FILE_OFFSET_BITS=64` were being set for llvmlibc when using the cmake build system. In particular, these preprocessor defines are feature test macros used by glibc, and which have effects no the corresponding ABI for types like `off_t` (for instance, should `off_t` be 32b or 64b on 32b targets). But who was setting these? Turns out that the use of add_compile_definitions in llvm/cmake/modules/HandleLLVMOptions.cmake was setting these (and more), which is then inherited by every subdirectory. While some of these defines maybe make sense for host builds, they do not make sense for libraries for the target. The full list of defines being set prior to this commit: - `-D_GNU_SOURCE` - `-D_FILE_OFFSET_BITS=64` - `-D_DEBUG` - `-D_GLIBCXX_ASSERTIONS` - `-D_LARGEFILE_SOURCE` - `-D_FILE_OFFSET_BITS=64` - `-D__STDC_CONSTANT_MACROS` - `-D__STDC_FORMAT_MACROS` - `-D__STDC_LIMIT_MACROS` If we desire any of the above, we should manually reset them. Fix this by resetting COMPILE_DEFINITIONS for the libc/ subdirectory. Side note: to debug 'directory properties' in cmake, you first need to use `get_directory_property` to fetch the corresponding value into a variable first, then that variable can be printed via `message`. Link: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fFILE_005fOFFSET_005fBITS Link: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fFILE_005fOFFSET_005fBITS Fixes: llvm#77395
Fixes the following diagnostic:
It looks like off_t is a curious types on different platforms. FWICT, it's 32b
on arm (at least for arm-linux-gnueabi) but 64b elsewhere (including 32b
riscv32-linux-gnu).