Skip to content
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

Tracking Issue for -Z link-directives #134947

Open
2 of 4 tasks
jieyouxu opened this issue Dec 31, 2024 · 1 comment
Open
2 of 4 tasks

Tracking Issue for -Z link-directives #134947

jieyouxu opened this issue Dec 31, 2024 · 1 comment
Labels
A-CLI Area: Command-line interface (CLI) to the compiler A-linkage Area: linking into static, shared libraries and binaries C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jieyouxu
Copy link
Member

jieyouxu commented Dec 31, 2024

This is a tracking issue for the unstable rustc flag -Z link-directives where

-Zlink-directives=no will ignored #[link] directives while compiling a crate, so nothing is emitted into the crate's metadata. The assumption is that the build system already knows about the crate's native dependencies and can provide them at link time without these directives.

PR description of #107675 (comment)

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

  • Missing unstable flag documentation?
  • What does this unstable rustc flag -Z link-directives do, exactly?
  • How does it relate to the stable #[link] attribute?
  • What does this mean for the #[link] attribute (which is a stable attribute)?
  • How does this unstable flag relate to -Z link-native-libraries?

Implementation history

Related links

@jieyouxu jieyouxu added A-CLI Area: Command-line interface (CLI) to the compiler A-linkage Area: linking into static, shared libraries and binaries C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 31, 2024
@ChrisDenton
Copy link
Member

Unless I'm missing some nuance, this is almost exactly like -l oldname:newname except that it removes oldname instead of replacing it. And like -l it is also limited to the crate that's currently being compiled. This is different to link-native-libraries, which has a global effect.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 31, 2024
Windows: Enable issue 70093 link tests

Tracking issue for `-Z link-native-libraries`: rust-lang#134948
Tracking issue for `-Z link-directives`: rust-lang#134947

`-Zlink-native-libraries=no` and `-Zlink-directives=no` *should* work on Windows, at least for msvc. The fly in ointment is that `default-linker-libraries` doesn't. On unixy platforms rustc calls another compiler which in turn calls the linker along with the default libraries. On MSVC rustc calls the linker directly therefore it would need to be the one to implement `default-linker-libraries`. Except it doesn't so we workaround that in the test by using `-C link-arg` to talk to the linker.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 31, 2024
Rollup merge of rust-lang#134918 - ChrisDenton:issue-70093, r=jieyouxu

Windows: Enable issue 70093 link tests

Tracking issue for `-Z link-native-libraries`: rust-lang#134948
Tracking issue for `-Z link-directives`: rust-lang#134947

`-Zlink-native-libraries=no` and `-Zlink-directives=no` *should* work on Windows, at least for msvc. The fly in ointment is that `default-linker-libraries` doesn't. On unixy platforms rustc calls another compiler which in turn calls the linker along with the default libraries. On MSVC rustc calls the linker directly therefore it would need to be the one to implement `default-linker-libraries`. Except it doesn't so we workaround that in the test by using `-C link-arg` to talk to the linker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: Command-line interface (CLI) to the compiler A-linkage Area: linking into static, shared libraries and binaries C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants