[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
Mon Jun 9 23:01:40 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
+
+#ifndef LIBC_NAMESPACE
----------------
lntue wrote:
Do you mean about the namespace or about the LIBC_ERRNO_MODE? For the current non-CMake users of libc++, they already have `LIBC_NAMESPACE` defined in their build system, so the `LIBC_NAMESPACE` will not be redefined here. On the other hand, for current non-CMake users of LLVM (without libc++), they might not have `LIBC_NAMESPACE` defined yet in their build system, and providing the default here will make sure that we won't break those users.
About the ODR violations, all of our functions that we define through `shared` here should be marked as `static`. Or maybe some macro like `LIBC_SHARED_FUNCTION` defaulted to `static` so that their symbols won't be exposed by default?
https://github.com/llvm/llvm-project/pull/143187
More information about the llvm-commits
mailing list