Skip to content

Commit cd98bd8

Browse files
authored
Update to the latest nightly. (#161)
* Update to the latest nightly. Update the syntax for naked functions. * Update to Rust 1.85 for edition2024.
1 parent e8ecd7f commit cd98bd8

File tree

53 files changed

+2318
-2116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2318
-2116
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
build: [ubuntu, i686-linux, aarch64-linux, riscv64-linux]
26-
rust: [1.84, nightly-2025-03-05]
26+
rust: [1.85, nightly-2025-04-28]
2727
include:
2828
- build: ubuntu
2929
os: ubuntu-latest
@@ -51,7 +51,7 @@ jobs:
5151
qemu: qemu-riscv64 -L /usr/riscv64-linux-gnu
5252
qemu_target: riscv64-linux-user
5353
host_target: riscv64gc-unknown-linux-gnu
54-
- rust: nightly-2025-03-05
54+
- rust: nightly-2025-04-28
5555
features: nightly
5656
steps:
5757
- uses: actions/checkout@v4

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ description = "Program startup and thread support written in Rust"
88
documentation = "https://docs.rs/origin"
99
license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
1010
repository = "https://github.com/sunfishcode/origin"
11-
edition = "2021"
11+
edition = "2024"
1212
keywords = ["linux"]
1313
categories = ["no-std"]
1414
include = ["src", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md"]
15-
rust-version = "1.84"
15+
rust-version = "1.85"
1616

1717
[dependencies]
1818
linux-raw-sys = { version = "0.9.2", default-features = false, optional = true, features = ["general", "no_std", "elf"] }
@@ -44,7 +44,7 @@ alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-all
4444
# Use the unwinding crate if support for unwinding is needed. This depends on
4545
# nightly Rust. And it's not supported on ARM yet.
4646
[target.'cfg(not(target_arch = "arm"))'.dependencies.unwinding]
47-
version = "0.2.5"
47+
version = "0.2.6"
4848
default-features = false
4949
features = ["unwinder"]
5050
optional = true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This is used by [Mustang] and [Eyra] in their libc implementations, and in the
2828
[Origin Studio] project in its std implementation, which are three different
2929
ways to support building Rust programs written entirely in Rust.
3030

31-
It works with both stable (currently Rust >= 1.78) and nightly Rust. If you're
31+
It works with both stable (currently Rust >= 1.85) and nightly Rust. If you're
3232
using nightly Rust, enable the feature "nightly" to let origin use nightly-only
3333
features, which include proper support for unwinding, better safety checks, and
3434
better optimizations.

example-crates/basic/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "basic"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

example-crates/external-start/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "external-start"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

example-crates/external-start/src/main.rs

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,62 +19,66 @@ static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::Glob
1919
/// and start running the constructors but to immediately take over.
2020
///
2121
/// [here]: https://github.com/rust-lang/rfcs/pull/2735
22-
#[link_section = ".init_array.00000"]
22+
#[unsafe(link_section = ".init_array.00000")]
2323
#[used]
2424
static EARLY_INIT_ARRAY: unsafe extern "C" fn(i32, *mut *mut u8) = {
2525
unsafe extern "C" fn function(_argc: i32, argv: *mut *mut u8) {
26-
// Libc was calling constructors (we're one of them), but origin will
27-
// be doing that now, so just exit when we're called a second time.
28-
static FIRST: AtomicBool = AtomicBool::new(false);
29-
if FIRST
30-
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
31-
.is_err()
32-
{
33-
return;
34-
}
26+
unsafe {
27+
// Libc was calling constructors (we're one of them), but origin will
28+
// be doing that now, so just exit when we're called a second time.
29+
static FIRST: AtomicBool = AtomicBool::new(false);
30+
if FIRST
31+
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
32+
.is_err()
33+
{
34+
return;
35+
}
3536

36-
// Compute the initial stack address provided by the kernel.
37-
let mem = argv.sub(1);
37+
// Compute the initial stack address provided by the kernel.
38+
let mem = argv.sub(1);
3839

39-
origin::program::start(mem as _);
40+
origin::program::start(mem as _);
41+
}
4042
}
4143
function
4244
};
4345

44-
#[no_mangle]
46+
#[unsafe(no_mangle)]
4547
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
46-
eprintln!("Hello from main thread");
48+
unsafe {
49+
eprintln!("Hello from main thread");
4750

48-
program::at_exit(Box::new(|| {
49-
eprintln!("Hello from a `program::at_exit` handler")
50-
}));
51-
thread::at_exit(Box::new(|| {
52-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
53-
}));
51+
program::at_exit(Box::new(|| {
52+
eprintln!("Hello from a `program::at_exit` handler")
53+
}));
54+
thread::at_exit(Box::new(|| {
55+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
56+
}));
5457

55-
let thread = thread::create(
56-
|_args| {
57-
eprintln!("Hello from child thread");
58-
thread::at_exit(Box::new(|| {
59-
eprintln!("Hello from child thread's `thread::at_exit` handler")
60-
}));
61-
None
62-
},
63-
&[],
64-
thread::default_stack_size(),
65-
thread::default_guard_size(),
66-
)
67-
.unwrap();
58+
let thread = thread::create(
59+
|_args| {
60+
eprintln!("Hello from child thread");
61+
thread::at_exit(Box::new(|| {
62+
eprintln!("Hello from child thread's `thread::at_exit` handler")
63+
}));
64+
None
65+
},
66+
&[],
67+
thread::default_stack_size(),
68+
thread::default_guard_size(),
69+
)
70+
.unwrap();
6871

69-
thread::join(thread);
72+
thread::join(thread);
7073

71-
eprintln!("Goodbye from main");
72-
program::exit(0);
74+
eprintln!("Goodbye from main");
75+
program::exit(0);
76+
}
7377
}
7478

7579
// Libc calls `main` so we need to provide a definition to satisfy the
7680
// linker, however origin gains control before libc can call this `main`.
77-
#[no_mangle]
81+
#[unsafe(no_mangle)]
7882
unsafe fn main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
7983
eprintln!("Main was not supposed to be called!");
8084
program::trap();

example-crates/origin-start-dynamic-linker/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "origin-start-dynamic-linker"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[lib]

example-crates/origin-start-dynamic-linker/src/lib.rs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,35 @@ use origin::{program, thread};
1212
#[global_allocator]
1313
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
1414

15-
#[no_mangle]
15+
#[unsafe(no_mangle)]
1616
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
17-
eprintln!("Hello from main thread");
18-
19-
program::at_exit(Box::new(|| {
20-
eprintln!("Hello from a `program::at_exit` handler")
21-
}));
22-
thread::at_exit(Box::new(|| {
23-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
24-
}));
25-
26-
let thread = thread::create(
27-
|_args| {
28-
eprintln!("Hello from child thread");
29-
thread::at_exit(Box::new(|| {
30-
eprintln!("Hello from child thread's `thread::at_exit` handler")
31-
}));
32-
None
33-
},
34-
&[],
35-
thread::default_stack_size(),
36-
thread::default_guard_size(),
37-
)
38-
.unwrap();
39-
40-
thread::join(thread);
41-
42-
eprintln!("Goodbye from main");
43-
program::exit(0);
17+
unsafe {
18+
eprintln!("Hello from main thread");
19+
20+
program::at_exit(Box::new(|| {
21+
eprintln!("Hello from a `program::at_exit` handler")
22+
}));
23+
thread::at_exit(Box::new(|| {
24+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
25+
}));
26+
27+
let thread = thread::create(
28+
|_args| {
29+
eprintln!("Hello from child thread");
30+
thread::at_exit(Box::new(|| {
31+
eprintln!("Hello from child thread's `thread::at_exit` handler")
32+
}));
33+
None
34+
},
35+
&[],
36+
thread::default_stack_size(),
37+
thread::default_guard_size(),
38+
)
39+
.unwrap();
40+
41+
thread::join(thread);
42+
43+
eprintln!("Goodbye from main");
44+
program::exit(0);
45+
}
4446
}

example-crates/origin-start-lto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "origin-start-lto"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

example-crates/origin-start-lto/src/main.rs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,35 @@ use origin::{program, thread};
1212
#[global_allocator]
1313
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
1414

15-
#[no_mangle]
15+
#[unsafe(no_mangle)]
1616
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
17-
eprintln!("Hello from main thread");
18-
19-
program::at_exit(Box::new(|| {
20-
eprintln!("Hello from a `program::at_exit` handler")
21-
}));
22-
thread::at_exit(Box::new(|| {
23-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
24-
}));
25-
26-
let thread = thread::create(
27-
|_args| {
28-
eprintln!("Hello from child thread");
29-
thread::at_exit(Box::new(|| {
30-
eprintln!("Hello from child thread's `thread::at_exit` handler")
31-
}));
32-
None
33-
},
34-
&[],
35-
thread::default_stack_size(),
36-
thread::default_guard_size(),
37-
)
38-
.unwrap();
39-
40-
thread::join(thread);
41-
42-
eprintln!("Goodbye from main");
43-
program::exit(0);
17+
unsafe {
18+
eprintln!("Hello from main thread");
19+
20+
program::at_exit(Box::new(|| {
21+
eprintln!("Hello from a `program::at_exit` handler")
22+
}));
23+
thread::at_exit(Box::new(|| {
24+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
25+
}));
26+
27+
let thread = thread::create(
28+
|_args| {
29+
eprintln!("Hello from child thread");
30+
thread::at_exit(Box::new(|| {
31+
eprintln!("Hello from child thread's `thread::at_exit` handler")
32+
}));
33+
None
34+
},
35+
&[],
36+
thread::default_stack_size(),
37+
thread::default_guard_size(),
38+
)
39+
.unwrap();
40+
41+
thread::join(thread);
42+
43+
eprintln!("Goodbye from main");
44+
program::exit(0);
45+
}
4446
}

example-crates/origin-start-no-alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "origin-start-no-alloc"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

example-crates/origin-start-no-alloc/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use atomic_dbg::eprintln;
77
use origin::program;
88

9-
#[no_mangle]
9+
#[unsafe(no_mangle)]
1010
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
1111
eprintln!("Hello!");
1212

example-crates/origin-start-panic-abort/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "origin-start-panic-abort"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

0 commit comments

Comments
 (0)