[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
Fri Jun 6 15:57:22 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:

Ah, thanks for correction - I see now that by default including libc/shared from a non-llvm-libc code would pick `LIBC_ERRNO_MODE_THREAD_LOCAL`, and that's not what we want. I'm OK with somehow forcing `LIBC_ERRNO_MODE_SYSTEM` somehow, but wonder how to do it reliably. I.e. if you forget to include libc/shared/libc_common.h inside a different libc/shared/ header, you may end up transitively including libc/__support/libc_errno.h, and defining LIBC_ERRNO_MODE to something else...

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


More information about the llvm-commits mailing list