-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Windows: Enable issue 70093 link tests #134918
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
tests/ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Ensure that `#[link]` attributes are entirely ignore when using `-Zlink-directives=no`. | ||
|
||
//@ run-pass | ||
//@ compile-flags: -Zlink-directives=no | ||
//@ ignore-fuchsia - missing __libc_start_main for some reason (#84733) | ||
//@ ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling | ||
|
||
// Usually these `#[link]` attribute would cause `libsome-random-non-existent-library` | ||
// to be passed to the linker, causing it to fail because the file doesn't exist. | ||
// However, with -Zlink-directives=no, the `#[link]` is ignored. | ||
#[link(name = "some-random-non-existent-library", kind = "static")] | ||
extern "C" {} | ||
|
||
fn main() {} |
26 changes: 26 additions & 0 deletions
26
tests/ui/link-native-libs/issue-70093/link-native-libraries.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Ensure that rust does not pass native libraries to the linker when | ||
// `-Zlink-native-libraries=no` is used. | ||
|
||
//@ run-pass | ||
//@ compile-flags: -Zlink-native-libraries=no -Cdefault-linker-libraries=yes | ||
//@ ignore-fuchsia - missing __libc_start_main for some reason (#84733) | ||
//@ ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling | ||
|
||
//@ revisions: other | ||
//@[other] ignore-msvc | ||
|
||
//@ revisions: msvc | ||
// On Windows MSVC, default-linker-libraries=yes doesn't work because | ||
// rustc drives the linker directly instead of going through another compiler. | ||
// Therefore rustc would need to implement default-linker-libraries itself but doesn't. | ||
// So instead we use -Clink-arg to directly set the required msvcrt.lib as a link arg. | ||
//@[msvc] compile-flags: -Clink-arg=msvcrt.lib | ||
//@[msvc] only-msvc | ||
|
||
// Usually these `#[link]` attribute would cause `libsome-random-non-existent-library` | ||
// to be passed to the linker, causing it to fail because the file doesn't exist. | ||
// However, -Zlink-native-libraries=no disables that. | ||
#[link(name = "some-random-non-existent-library", kind = "static")] | ||
extern "C" {} | ||
|
||
fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: could we slightly document what this test is actually checking?
I opened two tracking issues:
-Z link-directives
#134947-Z link-native-libraries
#134948But the original issue #70093 is not very obvious in what this test is actually trying to check for. If it's not obvious to you either, then I guess throw in a FIXME(#134947, #134948) lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests were the first time I'd heard of
link-directives
andlink-native-libraries
but I think I get the intent. Let me see what I can write.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for me, which is how I found out they had no MCPs nor tracking issues, and
-Zlink-directives
I believe has zero documentation either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, I think they have a lot of overlap with each other. And also with using the
-l
compiler flag when used to override native libs (but that currently has a much more limited effect).