-
Notifications
You must be signed in to change notification settings - Fork 0
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
Rust Compatibility Issues #7
Comments
Hi, from yesterdays' fixes I am able to compile the exporting example in WSL but not on windows. For whatever reason the issue persists when compiling (running cargo check on https://github.com/DhruvDh/umm-next/tree/25c78bd4202a156515e172d9b75e1ca355cdbb5f) on windows with the following toolchain:
cargo check output on windows
|
@DhruvDh Thank you for your reply! There was something I forgot to push yesterday. The latest commit to the master branch should bring everything in sync. This time, I manually tested Everything seems to be working as expected now. Please note that for some nightly targets, we currently need to disable Rust LLD due to known issues in its implementation. This is not specific to Ad Astra but affects some other crates on crates.io as well. These issues do not occur with the Stable Rust toolchain. |
Hi, could you please specify which specific known issues regarding Rust's LLD are you talking about? I'm currently trying to categorize such issues for LLD stabilization. Thank you! |
Hi Jakub, Ad Astra uses the same approach for linking sections as the well-known linkme crate. I'm not an expert in linkers, but I'll try to explain in simple terms what my crate and linkme actually do. Both crates aim to automatically enumerate function pointers specified in special static fields across the Cargo dependency tree of the current project and collect these pointers into a single array located in a linker section, making them available for iteration. Ad Astra leverages this mechanism for Rust-code introspection metadata, while linkme uses it to gather custom pointers to user-defined values. Essentially, both crates attempt to implement a plugin-like system by utilizing linker features to consolidate "plugin" entry points in one place. The way my crate works (and linkme follows a similar approach under the hood) is by defining three static values that determine the start and end of the concatenated linker section, along with a static slice representing the collected functions: fn exporters() -> &'static [ExporterFn] {
unsafe extern "Rust" {
#[link_name = "__start_adastrexpr"]
static START: ExporterFn;
#[link_name = "__stop_adastrexpr"]
static STOP: ExporterFn;
}
#[used]
#[unsafe(link_section = "adastrexpr")]
static mut EMPTY: [ExporterFn; 0] = [];
let start = unsafe { addr_of!(START) };
let stop = unsafe { addr_of!(STOP) };
let len = ((stop as usize) - (start as usize)) / size_of::<ExporterFn>();
unsafe { slice::from_raw_parts::<'static, ExporterFn>(start, len) }
} To add a function to this list, the user defines (via a procedural macro) special static variables within the project's dependency tree: #[used]
#[cfg_attr(
any(
target_os = "none",
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_os = "psp",
target_os = "freebsd",
),
unsafe(link_section = "adastrexpr"),
)]
static __LINKED: extern "C" fn() = /* a pointer to a Rust function */; In my experience, this setup works flawlessly with the default LLD linker. However, when using Rust-LLD, users often encounter errors like the following:
I tested this on rustc 1.85.0-nightly (d49be02cf 2024-12-02), in dev mode. Users of the linkme crate have reported similar issues with Rust 1.85: dtolnay/linkme#111. David addressed this issue by modifying the build scripts to revert to the standard LLD linker in nightly: dtolnay/linkme#88. I applied the same workaround-fix in my [target.x86_64-unknown-linux-gnu]
rustflags=["-Zlinker-features=-lld"]
rustdocflags=["-Zlinker-features=-lld"] I can confirm that this issue is not reproducible in rustc 1.87.0-nightly (3ea711f17 2025-03-09). However, I'm not certain whether this is due to a fix in Rust-LLD or a change in the default linker used in the nightly version. I haven't conducted extensive testing outside the Linux environment, but from brief checks, this issue does not seem to affect Windows. I'm happy to provide more details if needed, and I hope that Rust-LLD will address this issue before stabilization. Regards, |
Ah, it's linkme. Yeah, this should work now, it's not a concidence: rust-lang/rust#137685. It's arguably a problem on the linkme side (or whatever else crate that uses the same start/stop section approach), rather than LLD's side, but we decided to stay conservative and support this use-case for now. Great, thanks! |
Even though Ad Astra 1.x targets Rust MSRV 1.79 with the 2021 edition, and I don't plan to raise the minimum requirements in the foreseeable future to comply with backward compatibility policies, the project's crates should remain compatible with the latest stable releases of Rust, including the 2024 edition.
This issue serves as an ongoing tracker for bugs and warnings arising from the latest Rust releases.
The text was updated successfully, but these errors were encountered: