rust3ds / pthread-3ds

PThread implementation for Nintendo 3DS Horizon OS targets. Keep in mind that Horizon OS uses a cooperative, and not preemptive, threading model.
Apache License 2.0
12 stars 7 forks source link

Possibly no longer need `init()` function? #21

Closed ian-h-chamberlain closed 1 year ago

ian-h-chamberlain commented 1 year ago

It looks like https://github.com/rust-lang/rust/issues/47384 has been fixed since 1.62, so I wonder if we might be able to rely on #[no_mangle] and drop all the init() functions we needed to export everything? Same might apply for rust-linker-fix-3ds but this crate has a lot more of them so maybe a better place to start testing.

Meziu commented 1 year ago

It'd be great! I'll try when I can.

Meziu commented 1 year ago

It works! I've opened 3 PRs for the case:

ian-h-chamberlain commented 1 year ago

That's great! It looks like from your changes that it still requires a function from the given crate to be imported, is that correct? Otherwise we might as well just delete the init function entirely from here and rust-linker-fix-3ds. See also my comment https://github.com/rust3ds/ctru-rs/pull/92#discussion_r1106437245

AzureMarker commented 1 year ago

Wow, I'm surprised it works, since I still ran into issues and had to open this issue: https://github.com/rust-lang/rust/issues/94348

ian-h-chamberlain commented 1 year ago

yeah, I think the intention (based on https://github.com/rust-lang/rust/issues/94348#issuecomment-1079794684) was always that #[no_mangle] functions should no be discarded by the compiler, so the use cases for #[used] are primarily on static variables? but it seems like enough stuff got moved around that it works how we want it to now?

@AzureMarker I wonder if you would still be able to reproduce that issue or not given that this seems to be working for the 3ds libs now.

Meziu commented 1 year ago

but it seems like enough stuff got moved around that it works how we want it to now?

That’s my guess. The “fix” for that issue completely revamped the linking setup made by the compiler.

Meziu commented 1 year ago

I feel like a weight has been lifted from the toolchain!