-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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] Support configurable errno modes #98287
Conversation
Rather than selecting the errno implementation based on the platform which doesn't provide the necessary flexibility, make it configurable. The errno value location is returned by __errno_location() which is a solution used by glibc.
@llvm/pr-subscribers-libc Author: Petr Hosek (petrhosek) ChangesRather than selecting the errno implementation based on the platform which doesn't provide the necessary flexibility, make it configurable. The errno value location is returned by Full diff: https://github.com/llvm/llvm-project/pull/98287.diff 8 Files Affected:
diff --git a/libc/config/baremetal/config.json b/libc/config/baremetal/config.json
index dda4c42425755..9e66b682039f7 100644
--- a/libc/config/baremetal/config.json
+++ b/libc/config/baremetal/config.json
@@ -1,4 +1,9 @@
{
+ "errno": {
+ "LIBC_CONF_ERRNO_MODE": {
+ "value": "LIBC_ERRNO_MODE_LOCATION"
+ }
+ },
"printf": {
"LIBC_CONF_PRINTF_DISABLE_FLOAT": {
"value": true
diff --git a/libc/config/config.json b/libc/config/config.json
index e8feab20175f4..6c59ce95fdcc4 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -1,4 +1,10 @@
{
+ "errno": {
+ "LIBC_CONF_ERRNO_MODE": {
+ "value": "",
+ "doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_NONE, LIBC_ERRNO_MODE_INTERNAL, LIBC_ERRNO_MODE_EXTERNAL, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_GLOBAL, and LIBC_ERRNO_MODE_LOCATION."
+ }
+ },
"printf": {
"LIBC_CONF_PRINTF_DISABLE_FLOAT": {
"value": false,
diff --git a/libc/config/gpu/config.json b/libc/config/gpu/config.json
index 71107d26ea7ab..390aafad92b95 100644
--- a/libc/config/gpu/config.json
+++ b/libc/config/gpu/config.json
@@ -1,4 +1,9 @@
{
+ "errno": {
+ "LIBC_CONF_ERRNO_MODE": {
+ "value": "LIBC_ERRNO_MODE_GLOBAL"
+ }
+ },
"printf": {
"LIBC_CONF_PRINTF_DISABLE_FLOAT": {
"value": true
diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst
index 9c641ef94570f..e1aaa28ee9b91 100644
--- a/libc/docs/configure.rst
+++ b/libc/docs/configure.rst
@@ -28,6 +28,8 @@ to learn about the defaults for your platform and target.
* **"codegen" options**
- ``LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR``: Enable -fstack-protector-strong to defend against stack smashing attack.
- ``LIBC_CONF_KEEP_FRAME_POINTER``: Keep frame pointer in functions for better debugging experience.
+* **"errno" options**
+ - ``LIBC_CONF_ERRNO_MODE``: The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_NONE, LIBC_ERRNO_MODE_INTERNAL, LIBC_ERRNO_MODE_EXTERNAL, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_GLOBAL, and LIBC_ERRNO_MODE_LOCATION.
* **"malloc" options**
- ``LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE``: Default size for the constinit freelist buffer used for the freelist malloc implementation (default 1o 1GB).
* **"math" options**
diff --git a/libc/include/errno.h.def b/libc/include/errno.h.def
index 1f7120e63bfc9..298f02116a25f 100644
--- a/libc/include/errno.h.def
+++ b/libc/include/errno.h.def
@@ -25,18 +25,12 @@
#include "llvm-libc-macros/generic-error-number-macros.h"
#endif
-#if defined(__AMDGPU__) || defined(__NVPTX__)
-extern int __llvmlibc_errno; // Not thread_local!
-#else
-#ifdef __cplusplus
-extern "C" {
-extern thread_local int __llvmlibc_errno;
-}
-#else
-extern _Thread_local int __llvmlibc_errno;
-#endif // __cplusplus
-#endif
+__BEGIN_C_DECLS
+
+int *__errno_location(void) __NOEXCEPT;
+
+__END_C_DECLS
-#define errno __llvmlibc_errno
+#define errno (*__errno_location())
#endif // LLVM_LIBC_ERRNO_H
diff --git a/libc/src/errno/CMakeLists.txt b/libc/src/errno/CMakeLists.txt
index 2622e51261cc3..ca049143874ac 100644
--- a/libc/src/errno/CMakeLists.txt
+++ b/libc/src/errno/CMakeLists.txt
@@ -9,6 +9,17 @@ if(LLVM_LIBC_FULL_BUILD)
set(full_build_flag "-DLIBC_FULL_BUILD")
endif()
+if(LIBC_CONF_ERRNO_MODE)
+ set(errno_config_copts "-DLIBC_ERRNO_MODE=${LIBC_CONF_ERRNO_MODE}")
+else()
+ if(LLVM_LIBC_FULL_BUILD)
+ set(errno_mode "LIBC_ERRNO_MODE_THREAD_LOCAL")
+ else()
+ set(errno_mode "LIBC_ERRNO_MODE_EXTERNAL")
+ endif()
+ set(errno_config_copts "-DLIBC_ERRNO_MODE=${errno_mode}")
+endif()
+
add_entrypoint_object(
errno
SRCS
@@ -17,6 +28,7 @@ add_entrypoint_object(
libc_errno.h # Include this
COMPILE_OPTIONS
${full_build_flag}
+ ${errno_config_copts}
DEPENDS
libc.hdr.errno_macros
libc.src.__support.common
diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp
index bd1438c226143..ccc7467ed22ff 100644
--- a/libc/src/errno/libc_errno.cpp
+++ b/libc/src/errno/libc_errno.cpp
@@ -9,44 +9,100 @@
#include "libc_errno.h"
#include "src/__support/CPP/atomic.h"
-#ifdef LIBC_TARGET_ARCH_IS_GPU
-// LIBC_THREAD_LOCAL on GPU currently does nothing. So essentially this is just
-// a global errno for gpu to use for now.
+#define LIBC_ERRNO_MODE_NONE 0x01
+#define LIBC_ERRNO_MODE_INTERNAL 0x02
+#define LIBC_ERRNO_MODE_EXTERNAL 0x04
+#define LIBC_ERRNO_MODE_THREAD_LOCAL 0x08
+#define LIBC_ERRNO_MODE_GLOBAL 0x10
+#define LIBC_ERRNO_MODE_LOCATION 0x20
+
+#ifndef LIBC_ERRNO_MODE
+#error LIBC_ERRNO_MODE is not defined
+#endif
+
+#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_NONE && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_INTERNAL && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_GLOBAL && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_LOCATION
+#error LIBC_ERRNO_MODE must be one of the following values: \
+LIBC_ERRNO_MODE_NONE, \
+LIBC_ERRNO_MODE_INTERNAL, \
+LIBC_ERRNO_MODE_EXTERNAL, \
+LIBC_ERRNO_MODE_THREAD_LOCAL, \
+LIBC_ERRNO_MODE_GLOBAL, \
+LIBC_ERRNO_MODE_LOCATION
+#endif
+
+namespace LIBC_NAMESPACE {
+
+// Define the global `libc_errno` instance.
+Errno libc_errno;
+
+#if LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_NONE
+
extern "C" {
-LIBC_THREAD_LOCAL LIBC_NAMESPACE::cpp::Atomic<int> __llvmlibc_errno;
+const int __llvmlibc_errno = 0;
+int *__errno_location(void) { return &__llvmlibc_errno; }
}
-void LIBC_NAMESPACE::Errno::operator=(int a) {
- __llvmlibc_errno.store(a, cpp::MemoryOrder::RELAXED);
+void Errno::operator=(int) {}
+Errno::operator int() { return 0; }
+
+#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_INTERNAL
+
+LIBC_THREAD_LOCAL int __llvmlibc_internal_errno;
+
+extern "C" {
+int *__errno_location(void) { return &__llvmlibc_internal_errno; }
}
-LIBC_NAMESPACE::Errno::operator int() {
- return __llvmlibc_errno.load(cpp::MemoryOrder::RELAXED);
+
+void Errno::operator=(int a) { __llvmlibc_internal_errno = a; }
+Errno::operator int() { return __llvmlibc_internal_errno; }
+
+#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_EXTERNAL
+
+extern "C" {
+int *__errno_location(void) { return &errno; }
}
-#elif !defined(LIBC_COPT_PUBLIC_PACKAGING)
-// This mode is for unit testing. We just use our internal errno.
-LIBC_THREAD_LOCAL int __llvmlibc_internal_errno;
+void Errno::operator=(int a) { errno = a; }
+Errno::operator int() { return errno; }
-void LIBC_NAMESPACE::Errno::operator=(int a) { __llvmlibc_internal_errno = a; }
-LIBC_NAMESPACE::Errno::operator int() { return __llvmlibc_internal_errno; }
+#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_THREAD_LOCAL
-#elif defined(LIBC_FULL_BUILD)
-// This mode is for public libc archive, hermetic, and integration tests.
-// In full build mode, we provide the errno storage ourselves.
extern "C" {
LIBC_THREAD_LOCAL int __llvmlibc_errno;
+int *__errno_location(void) { return &__llvmlibc_errno; }
}
-void LIBC_NAMESPACE::Errno::operator=(int a) { __llvmlibc_errno = a; }
-LIBC_NAMESPACE::Errno::operator int() { return __llvmlibc_errno; }
+void Errno::operator=(int a) { __llvmlibc_errno = a; }
+Errno::operator int() { return __llvmlibc_errno; }
-#else
-void LIBC_NAMESPACE::Errno::operator=(int a) { errno = a; }
-LIBC_NAMESPACE::Errno::operator int() { return errno; }
+#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_GLOBAL
-#endif // LIBC_FULL_BUILD
+extern "C" {
+LIBC_NAMESPACE::cpp::Atomic<int> __llvmlibc_errno;
+int *__errno_location(void) { return &__llvmlibc_errno; }
+}
+
+void Errno::operator=(int a) {
+ __llvmlibc_errno.store(a, cpp::MemoryOrder::RELAXED);
+}
+Errno::operator int() {
+ return __llvmlibc_errno.load(cpp::MemoryOrder::RELAXED);
+}
+
+#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_LOCATION
+
+extern "C" {
+int *__errno_location(void);
+}
+
+void Errno::operator=(int a) { *__errno_location() = a; }
+Errno::operator int() { return *__errno_location(); }
+
+#endif
-namespace LIBC_NAMESPACE {
-// Define the global `libc_errno` instance.
-Errno libc_errno;
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/errno/libc_errno.h b/libc/src/errno/libc_errno.h
index df67ea3b42faa..a5c1e3e485407 100644
--- a/libc/src/errno/libc_errno.h
+++ b/libc/src/errno/libc_errno.h
@@ -31,6 +31,7 @@
// - Still depend on libc.src.errno.errno
namespace LIBC_NAMESPACE {
+
struct Errno {
void operator=(int);
operator int();
|
You can test this locally with the following command:git-clang-format --diff 062844615db5e141da118c1ad780bf102537f40a 1ff0acc44a2443ff87ae2decad282b0a604ca5f6 --extensions cpp,h -- libc/src/errno/errno.h libc/src/errno/libc_errno.cpp libc/src/errno/libc_errno.h View the diff from clang-format here.diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp
index f7bd3a3b9e..12e5637ed1 100644
--- a/libc/src/errno/libc_errno.cpp
+++ b/libc/src/errno/libc_errno.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "libc_errno.h"
-#include "src/errno/errno.h"
#include "src/__support/macros/config.h"
+#include "src/errno/errno.h"
// libc never stores a value; `errno` macro uses get link-time failure.
#define LIBC_ERRNO_MODE_UNDEFINED 1
|
libc/src/errno/libc_errno.cpp
Outdated
#define LIBC_ERRNO_MODE_LOCATION 0x20 | ||
|
||
#ifndef LIBC_ERRNO_MODE | ||
#error LIBC_ERRNO_MODE is not defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new flag, so I think we should provide the default value for LIBC_ERRNO_MODE
which matches the current behavior instead of errors to not break downstream users.
#ifndef LIBC_ERRNO_MODE
#ifndef LIBC_COPT_PUBLIC_PACKAGING
// This mode is for unit testing. We just use our internal errno.
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_INTERNAL
#elif defined(LIBC_FULL_BUILD)
// In full build mode, we provide the errno storage ourselves.
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
#else
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_EXTERNAL
#endif
#endif // LIBC_ERRNO_MODE
Then you can remove the default setting in the CMakeLists.txt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the concept, we mostly provide a global errno just to make things like libc++ happy. Though maybe it would be better to disable it there as well...
libc/config/config.json
Outdated
"errno": { | ||
"LIBC_CONF_ERRNO_MODE": { | ||
"value": "", | ||
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_NONE, LIBC_ERRNO_MODE_INTERNAL, LIBC_ERRNO_MODE_EXTERNAL, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_GLOBAL, and LIBC_ERRNO_MODE_SYSTEM." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really think this needs to not only enumerate the modes but document what each one means. That would make this spot the right place to bikeshed the names, none of which I really like so far.
Perhaps:
UNDEFINED
: libc never stores a value;errno
macro uses get link-time failureEXTERNAL_ABI
: embedder must defineint *__llvm_libc_errno(void);
C functionTHREAD_LOCAL
: libc maintains per-thread state (requires C++thread_local
support for libc implementation code)SHARED_ATOMIC
: libc maintains anatomic_int
used by all threads, contrary to standard C semantics (requires use of atomics in libc implementation code, may produce libcalls an embedder must supply)SHARED_THREAD_UNSAFE
: libc maintains a plainint
used by all threads, contrary to standard C semantics unless always single-threaded; nothing prevents data racesSYSTEM_HEADER
: In overlay mode, system<errno.h>
errno
macro is used directly by libc. In fullbuild mode, effectively the same asEXTERNAL_ABI
(or perhaps we make it an error to choose this in fullbuild mode).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it makes sense to distinguish the "shared atomic" and "shared thread unsafe" modes? Right now these are only used by the GPU port which uses the atomic version. Specifically the only reason for the "shared thread unsafe" mode seems to be avoiding the use of atomics, but we already use those elsewhere so I'm not sure how useful that is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today's "baremetal" is a very specific set of choices about an embedded-style use case. I'm confident that there will in the long run be embedded-style use cases that are purely single-threaded and want to avoid the overhead (or need for useless libcall stubs that do nothing) of atomics. I think it will certainly be the right thing for all libc code that might ever be useful in some minimal embedded context to be configurable to avoid atomics at the cost of any kind of thread safety. I don't think it will ever be wise enough to be acceptable to "achieve" that via hacks like -DLIBC_THREAD_LOCAL=
or making cpp::Atomic
configurable to itself not actually be atomic. Instead, I think each and every case (so far, rand
and errno
) merits its own intentional and explicit configuration choice so in each context someone has to decide what semantics, and tradeoffs between formally standards-compliant and/or de facto norm semantics and other context-specific factors, are right for them.
For today, it doesn't matter if we support everything that we should in principle support in terms of configuration options. The taxonomy above I think covers all the options for errno
in particular that I anticipate we will support long term. The subset of THREAD_LOCAL
, SHARED_ATOMIC
, and SHARED_THREAD_UNSAFE
is probably a common vocabulary that makes sense for the broader general class of cases that includes rand
, while the other options here are idiosyncratic to errno
.
libc/src/errno/libc_errno.cpp
Outdated
LIBC_ERRNO_MODE_SYSTEM | ||
#endif | ||
|
||
namespace LIBC_NAMESPACE { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to update to LIBC_NAMESPACE_DECL
when that stuff lands. (I'm not sure it technically matters as long as it was done in libc_errno.h, but I think uniformity it what we're going for regardless.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, I expect this change is going to land after that one.
libc/src/errno/libc_errno.cpp
Outdated
void Errno::operator=(int a) { __libc_errno = a; } | ||
Errno::operator int() { return __libc_errno; } | ||
|
||
#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_GLOBAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this mode should be called "SHARED_ATOMIC" or something like that. ISTM there should be another "SHARED_THREAD_UNSAFE" or the like that's just a plain variable.
Again, these variables should have names appropriate for a local linkage implementation detail, and it doesn't hurt to use different names specific to each different implementation here.
libc/src/errno/libc_errno.cpp
Outdated
extern "C" { | ||
LIBC_THREAD_LOCAL int __llvmlibc_errno; | ||
int *__llvm_libc_errno(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a declaration here. It's already in <errno.h>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't include errno.h
in the full build mode, should we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a policy about using a hdr/errno_macros.h
wrapper instead of doing it directly, but yeah. In some fashion, the authoritative header file declaration of any public ABI function you're defining really ought to be in scope in the implementation file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there may be a case to be made that there should be an __llvm_libc_errno.h
in this directory to declare the function like we have for other public (ABI) functions. But then that would go with the __llvm_libc_errno.cpp
implementation file for just that function, which isn't what we want to do since we want it and the Errno
internal class implemented together.
I'm not sure what the precedent is (or if there is any yet) for other non-functions in the API, i.e. having an errno.h
that's responsible for errno
inside the libc implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the precedent is (or if there is any yet) for other non-functions in the API, i.e. having an
errno.h
that's responsible forerrno
inside the libc implementation.
We use https://github.com/llvm/llvm-project/blob/0b15f89182a4b2a4c46ad207fa2e282ad35f12ee/libc/src/errno/libc_errno.h for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That header has that name because it's implementing LIBC_NAMESPACE::libc_errno
. It's true that today it does include hdr/errno_macros.h
, but that only defines the E*
constants (necessarily, i.e. in all build modes).
That's a different issue from whether when there is a variable (or variable-like API, such as errno
) in the public API, we have a symbol_name.h
header for it in src/something/
like we do for functions in the public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other case I can think of is https://github.com/llvm/llvm-project/blob/7868033d2e846fa30c20455ca819fad29d9d795e/libc/src/assert/assert.h which would suggest having errno.h
in https://github.com/llvm/llvm-project/tree/7868033d2e846fa30c20455ca819fad29d9d795e/libc/src/errno
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I introduced src/errno/errno.h
in the latest revision.
libc/src/errno/libc_errno.cpp
Outdated
return __llvmlibc_errno.load(cpp::MemoryOrder::RELAXED); | ||
|
||
extern "C" { | ||
int *__llvm_libc_errno() { return &global_errno; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is kind of a problem. You can't really make the user access via the function call (i.e. the errno
macro--the only API) be atomic. The errno
macro has to be a "modifiable lvalue" (equivalent to C++ lvalue reference) of type int
. If cpp::Atomic<T>
lets you convert its address to T*
implicitly somehow that's highly questionable.
So in reality I don't think SHARED_ATOMIC
is actually an option here, unlike the general case a la rand
. There is no way in the C API/ABI to force the user to use an accessor other than normal pointer dereference. (A C++-only definition of errno
could be like libc_errno
and turn loads and stores into library calls, but there's no way to do that in C.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was just looking at that. cpp::Atomic<T>
lets you access the underlying value but accessing the value that way won't be atomic so I don't think this is really viable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to using just regular global.
@@ -1,4 +1,10 @@ | |||
{ | |||
"errno": { | |||
"LIBC_CONF_ERRNO_MODE": { | |||
"value": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would probably be best to make the default value LIBC_ERRNO_MODE_THREAD_LOCAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but the problem is that we currently don't have any mechanism to distinguish the overlay from the full build mode, and in the overlay mode we want to default to LIBC_ERRNO_MODE_SYSTEM
.
libc/docs/configure.rst
Outdated
@@ -28,6 +28,13 @@ to learn about the defaults for your platform and target. | |||
* **"codegen" options** | |||
- ``LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR``: Enable -fstack-protector-strong to defend against stack smashing attack. | |||
- ``LIBC_CONF_KEEP_FRAME_POINTER``: Keep frame pointer in functions for better debugging experience. | |||
* **"errno" options** | |||
- ``LIBC_CONF_ERRNO_MODE``: The implementation used for errno, acceptable values are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file gets auto-generated, so the docs here need to be also in the json file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think JSON is particularly suited for multiline strings so I moved the explanation of different modes as comments to the implementation file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now. I think we could refine a little how we make the overlay vs full mode setting interact with the option, but it's a little hairy to decide what we want and it doesn't seem crucial. Likewise I think we should clarify and fully specify the plan about per-function/symbol headers and how that relates to errno/__llvm_libc_errno inside the tree. But that too is not urgent. When we do that we should start using -Wprototypes
or whatever it is that complains if we define __llvm_libc_errno
without a prior header declaration being in scope.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/104/builds/2085 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/43/builds/2045 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/93/builds/2001 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/188/builds/1439 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/182/builds/1011 Here is the relevant piece of the build log for the reference:
|
This addresses the build error introduced in llvm#98287 where src/errno/errno.h is included instead of the system errno.h. We instead move the declaration to libc_errno.h.
This addresses the build error introduced in #98287 where src/errno/errno.h is included instead of the system errno.h. We instead move the declaration to libc_errno.h.
Rather than selecting the errno implementation based on the platform which doesn't provide the necessary flexibility, make it configurable. The errno value location is returned by `int *__llvm_libc_errno()` which is a common design used by other C libraries.
This addresses the build error introduced in llvm#98287 where src/errno/errno.h is included instead of the system errno.h. We instead move the declaration to libc_errno.h.
This addresses the build error introduced in llvm#98287 where src/errno/errno.h is included instead of the system errno.h. We instead move the declaration to libc_errno.h.
Rather than selecting the errno implementation based on the platform which doesn't provide the necessary flexibility, make it configurable. The errno value location is returned by `int *__llvm_libc_errno()` which is a common design used by other C libraries.
This addresses the build error introduced in llvm#98287 where src/errno/errno.h is included instead of the system errno.h. We instead move the declaration to libc_errno.h.
Rather than selecting the errno implementation based on the platform which doesn't provide the necessary flexibility, make it configurable.
The errno value location is returned by
__errno_location()
which is a solution used by glibc.