Skip to content

Commit 04081ca

Browse files
authored
[libc] Remove LIBC_ERRNO_MODE_SYSTEM mode. (#153077)
Use LIBC_ERRNO_MODE_SYSTEM_INLINE instead as the default for the "public packaging" (i.e. release mode) of an overlay build. The Bazel build has already switched to use it by default in 5ccc734. This should be a safe change, as LIBC_ERRNO_MODE_SYSTEM_INLINE works a drop-in (but simpler) LIBC_ERRNO_MODE_SYSTEM replacement. Remove the associated code paths and config settings. Fixes issue #143454.
1 parent db96363 commit 04081ca

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

libc/config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"errno": {
33
"LIBC_CONF_ERRNO_MODE": {
44
"value": "LIBC_ERRNO_MODE_DEFAULT",
5-
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, LIBC_ERRNO_MODE_SYSTEM, and LIBC_ERRNO_MODE_SYSTEM_INLINE."
5+
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM_INLINE."
66
}
77
},
88
"threads": {

libc/docs/configure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ to learn about the defaults for your platform and target.
2929
- ``LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR``: Enable -fstack-protector-strong to defend against stack smashing attack.
3030
- ``LIBC_CONF_KEEP_FRAME_POINTER``: Keep frame pointer in functions for better debugging experience.
3131
* **"errno" options**
32-
- ``LIBC_CONF_ERRNO_MODE``: The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, LIBC_ERRNO_MODE_SYSTEM, and LIBC_ERRNO_MODE_SYSTEM_INLINE.
32+
- ``LIBC_CONF_ERRNO_MODE``: The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM_INLINE.
3333
* **"general" options**
3434
- ``LIBC_ADD_NULL_CHECKS``: Add nullptr checks in the library's implementations to some functions for which passing nullptr is undefined behavior.
3535
* **"math" options**

libc/src/__support/libc_errno.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,19 @@
3737
// libc doesn't maintain any internal state, instead the embedder must define
3838
// `int *__llvm_libc_errno(void);` C function.
3939
#define LIBC_ERRNO_MODE_EXTERNAL 4
40-
// libc uses system `<errno.h>` `errno` macro directly in the overlay mode; in
41-
// fullbuild mode, effectively the same as `LIBC_ERRNO_MODE_EXTERNAL`.
42-
// In this mode, the public C++ symbol `LIBC_NAMESPACE::libc_errno ` is still
43-
// exported and get redirected to the system `errno` inside its implementation.
44-
45-
// TODO: Investigate deprecating LIBC_ERRNO_MODE_SYSTEM in favor of
46-
// LIBC_ERRNO_MODE_SYSTEM_INLINE.
47-
// https://github.com/llvm/llvm-project/issues/143454
48-
#define LIBC_ERRNO_MODE_SYSTEM 5
40+
// DEPRECATED: #define LIBC_ERRNO_MODE_SYSTEM 5
4941
// In this mode, the libc_errno is simply a macro resolved to `errno` from the
5042
// system header <errno.h>. There is no need to link against the
51-
// `libc.src.errno.errno` object.
43+
// `libc.src.errno.errno` object, and public C++ symbol
44+
// `LIBC_NAMESPACE::libc_errno` doesn't exist.
5245
#define LIBC_ERRNO_MODE_SYSTEM_INLINE 6
5346

5447
#if !defined(LIBC_ERRNO_MODE) || LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_DEFAULT
5548
#undef LIBC_ERRNO_MODE
5649
#if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING)
5750
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
5851
#else
59-
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
52+
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM_INLINE
6053
#endif
6154
#endif // LIBC_ERRNO_MODE
6255

@@ -65,15 +58,13 @@
6558
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \
6659
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SHARED && \
6760
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \
68-
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM && \
6961
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM_INLINE
7062
#error LIBC_ERRNO_MODE must be one of the following values: \
7163
LIBC_ERRNO_MODE_DEFAULT, \
7264
LIBC_ERRNO_MODE_UNDEFINED, \
7365
LIBC_ERRNO_MODE_THREAD_LOCAL, \
7466
LIBC_ERRNO_MODE_SHARED, \
7567
LIBC_ERRNO_MODE_EXTERNAL, \
76-
LIBC_ERRNO_MODE_SYSTEM, \
7768
LIBC_ERRNO_MODE_SYSTEM_INLINE.
7869
#endif
7970

libc/src/errno/libc_errno.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ Errno::operator int() { return shared_errno; }
4646
void Errno::operator=(int a) { *__llvm_libc_errno() = a; }
4747
Errno::operator int() { return *__llvm_libc_errno(); }
4848

49-
#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_SYSTEM
50-
51-
void Errno::operator=(int a) { errno = a; }
52-
Errno::operator int() { return errno; }
53-
5449
#endif
5550

5651
// Define the global `libc_errno` instance.

0 commit comments

Comments
 (0)