rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.01k stars 12.79k forks source link

Tracking Issue for native link modifier `as-needed` #99424

Open petrochenkov opened 2 years ago

petrochenkov commented 2 years ago

This is a tracking issue for native link modifier as-needed, which is a part of RFC "Linking modifiers for native libraries" (https://github.com/rust-lang/rust/issues/81490, https://github.com/rust-lang/rfcs/pull/2951). The feature gate for the issue is #![feature(native_link_modifiers_as_needed)].

About tracking issues

Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

The modifier is not yet implemented for some Tier 1 targets (Apple targets).

Implementation history

GoldsteinE commented 2 years ago

What prevents this from moving forward? Can I help with stabilization somehow?

petrochenkov commented 2 years ago

AFAIK, it's still not implemented on some tier 1 platforms (Apple targets).

GoldsteinE commented 2 years ago

I don’t think I can help with that — I don’t own Mac. :(

wesleywiser commented 10 months ago

Visited during the compiler team tracking issue triage meeting. Our understanding is that the implementation of this feature is complete but there are some not-quite resolved questions regarding support for older Apple linkers. As such, we're tentatively marking this as S-tracking-needs-to-bake while those questions are resolved.

kamyuentse commented 8 months ago

I use println!("cargo:rustc-link-lib=dylib:-as-needed=mylib"); on build.rs. And got error: linking modifier as-needed is unstable and only accepted on the nightly compiler. I already use the nightly toolchain.

rustc 1.79.0-nightly (85e449a32 2024-03-22)

hietalajulius commented 2 weeks ago

I use println!("cargo:rustc-link-lib=dylib:-as-needed=mylib"); on build.rs. And got error: linking modifier as-needed is unstable and only accepted on the nightly compiler. I already use the nightly toolchain.

rustc 1.79.0-nightly (85e449a 2024-03-22)

@kamyuentse did you end up resolving this somehow?

bjorn3 commented 2 weeks ago

Maybe running cargo with RUSTFLAGS="-Zunstable-features as env var is required?

hietalajulius commented 2 weeks ago

Maybe running cargo with RUSTFLAGS="-Zunstable-features as env var is required?

Hmm yeah thanks, setting RUSTFLAGS="-Zunstable-options works when running a binary from the crate itself (call it crate_a) where the build.rs uses -as-needed. When running a binary from another crate (say crate_b) that depends on crate_a, I keep getting error: linking modifier as-needed is unstable and only accepted on the nightly compiler.

Hmm ok that does the trick even in the ^^ case, weird I could have sworn it didn't at first :D