[libc] [llvm] [libc] Move libc_errno.h to libc/src/__support and make LIBC_ERRNO_MODE_SYSTEM to be header-only. (PR #143187)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 18:28:50 PDT 2025
================
@@ -46,4 +46,7 @@ LIBC_CONFIGURE_OPTIONS = [
# Documentation in libc/src/__support/libc_assert.h
# "LIBC_COPT_USE_C_ASSERT",
+
+ # Use system errno.
+ "LIBC_ERRNO_MODE=LIBC_ERRNO_MODE_SYSTEM",
----------------
lntue wrote:
The problem was that originally (and even right now), only the entry points have separate objects that are built with and without `-DLIBC_COPT_PUBLIC_PACKAGING`. And other object libraries (from `add_object_library`) were flip-flopping between having internal targets or not, with or without `-DLIBC_COPT_PUBLIC_PACKAGING` or not. And the `errno` which was evolved into `libc_errno` to address different needs, ended up with different configurations for `-DLIBC_COPT_PUBLIC_PACKAGING`, and it was and odd-ball, being an entrypoint (even though the standard has `errno` as a macro), and allowed other objects / entrypoints to depend on.
And those were hard to untangle without too much rewriting most of the cmake builds and not affecting downstream non-cmake users. So we decided to let all the internal usages of `errno` use `LIBC_NAMESPACE::libc_errno` instead, and let the `libc_errno` entrypoint objects deal with different configurations.
My upcoming cmake fix / refactor will make the roles of each cmake targets clearer and more consistent, allowing us to get away from the current indirection of the original `LIBC_ERRNO_MODE_SYSTEM`.
In the mean time, I would call the clean `#define libc_errno errno` mode `LIBC_ERRNO_MODE_SYSTEM_INLINE`, and preserve the `LIBC_ERRNO_MODE_SYSTEM` as before.
https://github.com/llvm/llvm-project/pull/143187
More information about the llvm-commits
mailing list