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

Fix linkage1 test which fails due to --as-needed #12983

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/test/auxiliary/linkage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@

#[no_mangle]
pub static foo: int = 3;

pub fn bar() {}
7 changes: 7 additions & 0 deletions src/test/run-pass/linkage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ extern {
}

fn main() {
// It appears that the --as-needed flag to linkers will not pull in a dynamic
// library unless it satisfies a non weak undefined symbol. The 'other' crate
// is compiled as a dynamic library where it would only be used for a
// weak-symbol as part of an executable, so the dynamic library woudl be
// discarded. By adding and calling `other::bar`, we get around this problem.
other::bar();

assert!(!foo.is_null());
assert_eq!(unsafe { *foo }, 3);
assert!(something_that_should_never_exist.is_null());
Expand Down