[libc] [llvm] [libc] Move libc_errno.h to libc/src/__support and make LIBC_ERRNO_MODE_SYSTEM to be header-only. (PR #143187)

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 15:08:35 PDT 2025


================
@@ -0,0 +1,20 @@
+//===-- Common defines for sharing LLVM libc with LLVM projects -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_LIBC_COMMON_H
+#define LLVM_LIBC_SHARED_LIBC_COMMON_H
+
+// Use system errno.
+#undef LIBC_ERRNO_MODE
+#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
----------------
vonosmas wrote:

Is there a use case when `LIBC_ERRNO_MODE` may be explicitly set to **something else** but `LIBC_ERRNO_MODE_SYSTEM_INLINE` when using llvm-libc code though `libc/shared`? If no, then how about we:

1. Teach llvm-libc headers to "understand" when they are being used in "shared" mode (i.e. by `#define LIBC_SHARED_MODE` in `libc/shared/libc_common.h` header, or by omitting this header file entirely, and using this define in every `libc/shared/` file which currently is modified to include `libc/shared/libc_common.h`)
2. In `src/__support/libc_errno.h`: make it an error to explicitly `#define LIBC_ERRNO_MODE` to anything but `LIBC_ERRNO_MODE_SYSTEM_INLINE`.


https://github.com/llvm/llvm-project/pull/143187


More information about the llvm-commits mailing list