Skip to content

Commit 9b9b5f9

Browse files
authored
Reduce the complexity around all possible feature combinations (#107)
* Unconditionally enable the set_thread_id feature If set_current_id_after_a_fork is isn't used, --gc-sections will already automatically remove it from the executable. * Fix the compile time assertion about origin-program requiring either origin-start or external-start Also move a couple of feature deps from origin-start/external-start to origin-program.
1 parent 5f3c81f commit 9b9b5f9

4 files changed

Lines changed: 5 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,26 @@ rustc-dep-of-std = [
6565
"dep:compiler_builtins",
6666
]
6767

68-
# Enable the `set_current_id_after_a_fork` function.
69-
set_thread_id = []
70-
7168
# Use origin's implementation of program startup and shutdown.
72-
origin-program = []
69+
origin-program = ["rustix/use-explicitly-provided-auxv", "rustix/runtime"]
7370

7471
# Use origin's implementation of thread startup and shutdown.
7572
#
7673
# To use threads, it's also necessary to enable the "thread" feature.
77-
origin-thread = ["memoffset", "rustix/runtime", "origin-program"]
74+
origin-thread = ["memoffset", "origin-program"]
7875

7976
# Use origin's implementation of signal handle registrtion.
8077
#
8178
# To use threads, it's also necessary to enable the "signal" feature.
8279
origin-signal = ["rustix/runtime"]
8380

8481
# Use origin's `_start` definition.
85-
origin-start = ["rustix/use-explicitly-provided-auxv", "rustix/runtime", "origin-program"]
82+
origin-start = ["origin-program"]
8683

8784
# Don't use origin's `_start` definition, but export a `start` function which
8885
# is meant to be run very early in program startup and passed a pointer to
8986
# the initial stack. Don't enable this when enabling "origin-start".
90-
external-start = ["rustix/use-explicitly-provided-auxv", "rustix/runtime", "origin-program"]
87+
external-start = ["origin-program"]
9188

9289
# The loggers depend on a `.init_array` entry to initialize themselves, and
9390
# `env_logger` needs it so that `c-scape` can initialize environment variables

src/program.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use linux_raw_sys::ctypes::c_int;
3838
use rustix_futex_sync::Mutex;
3939

4040
#[cfg(all(
41-
feature = "program-start",
41+
feature = "origin-program",
4242
not(any(feature = "origin-start", feature = "external-start"))
4343
))]
4444
compile_error!("\"origin-program\" depends on either \"origin-start\" or \"external-start\".");

src/thread/libc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ pub fn current_id() -> ThreadId {
196196
/// This must only be called immediately after a `fork` before any other
197197
/// threads are created. `tid` must be the same value as what [`gettid`] would
198198
/// return.
199-
#[cfg(feature = "set_thread_id")]
200199
#[doc(hidden)]
201200
#[inline]
202201
pub unsafe fn set_current_id_after_a_fork(tid: ThreadId) {

src/thread/linux_raw.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,6 @@ pub fn current_id() -> ThreadId {
989989
/// This must only be called immediately after a `fork` before any other
990990
/// threads are created. `tid` must be the same value as what [`gettid`] would
991991
/// return.
992-
#[cfg(feature = "set_thread_id")]
993-
#[cfg_attr(doc_cfg, doc(cfg(feature = "set_thread_id")))]
994992
#[doc(hidden)]
995993
#[inline]
996994
pub unsafe fn set_current_id_after_a_fork(tid: ThreadId) {

0 commit comments

Comments
 (0)