diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/native-library-link-flags | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
18 files changed, 131 insertions, 0 deletions
diff --git a/src/test/ui/native-library-link-flags/empty-kind-1.rs b/src/test/ui/native-library-link-flags/empty-kind-1.rs new file mode 100644 index 000000000..18937856d --- /dev/null +++ b/src/test/ui/native-library-link-flags/empty-kind-1.rs @@ -0,0 +1,6 @@ +// Unspecified kind should fail with an error + +// compile-flags: -l =mylib +// error-pattern: unknown library kind ``, expected one of: static, dylib, framework, link-arg + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/empty-kind-1.stderr b/src/test/ui/native-library-link-flags/empty-kind-1.stderr new file mode 100644 index 000000000..3e5b05493 --- /dev/null +++ b/src/test/ui/native-library-link-flags/empty-kind-1.stderr @@ -0,0 +1,2 @@ +error: unknown library kind ``, expected one of: static, dylib, framework, link-arg + diff --git a/src/test/ui/native-library-link-flags/empty-kind-2.rs b/src/test/ui/native-library-link-flags/empty-kind-2.rs new file mode 100644 index 000000000..851eb63fc --- /dev/null +++ b/src/test/ui/native-library-link-flags/empty-kind-2.rs @@ -0,0 +1,6 @@ +// Unspecified kind should fail with an error + +// compile-flags: -l :+bundle=mylib +// error-pattern: unknown library kind ``, expected one of: static, dylib, framework, link-arg + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/empty-kind-2.stderr b/src/test/ui/native-library-link-flags/empty-kind-2.stderr new file mode 100644 index 000000000..3e5b05493 --- /dev/null +++ b/src/test/ui/native-library-link-flags/empty-kind-2.stderr @@ -0,0 +1,2 @@ +error: unknown library kind ``, expected one of: static, dylib, framework, link-arg + diff --git a/src/test/ui/native-library-link-flags/link-arg-error.rs b/src/test/ui/native-library-link-flags/link-arg-error.rs new file mode 100644 index 000000000..e041650d0 --- /dev/null +++ b/src/test/ui/native-library-link-flags/link-arg-error.rs @@ -0,0 +1,4 @@ +// compile-flags: -l link-arg:+bundle=arg -Z unstable-options +// error-pattern: linking modifier `bundle` is only compatible with `static` linking kind + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/link-arg-error.stderr b/src/test/ui/native-library-link-flags/link-arg-error.stderr new file mode 100644 index 000000000..e1d01e141 --- /dev/null +++ b/src/test/ui/native-library-link-flags/link-arg-error.stderr @@ -0,0 +1,2 @@ +error: linking modifier `bundle` is only compatible with `static` linking kind + diff --git a/src/test/ui/native-library-link-flags/link-arg-from-rs.rs b/src/test/ui/native-library-link-flags/link-arg-from-rs.rs new file mode 100644 index 000000000..075e4d9e7 --- /dev/null +++ b/src/test/ui/native-library-link-flags/link-arg-from-rs.rs @@ -0,0 +1,8 @@ +// link-arg is not supposed to be usable in #[link] attributes + +// compile-flags: +// error-pattern: error[E0458]: unknown link kind `link-arg`, expected one of: static, dylib, framework, raw-dylib + +#[link(kind = "link-arg")] +extern "C" {} +pub fn main() {} diff --git a/src/test/ui/native-library-link-flags/link-arg-from-rs.stderr b/src/test/ui/native-library-link-flags/link-arg-from-rs.stderr new file mode 100644 index 000000000..69a7825c0 --- /dev/null +++ b/src/test/ui/native-library-link-flags/link-arg-from-rs.stderr @@ -0,0 +1,16 @@ +error[E0458]: unknown link kind `link-arg`, expected one of: static, dylib, framework, raw-dylib + --> $DIR/link-arg-from-rs.rs:6:15 + | +LL | #[link(kind = "link-arg")] + | ^^^^^^^^^^ unknown link kind + +error[E0459]: `#[link]` attribute requires a `name = "string"` argument + --> $DIR/link-arg-from-rs.rs:6:1 + | +LL | #[link(kind = "link-arg")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0458, E0459. +For more information about an error, try `rustc --explain E0458`. diff --git a/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs new file mode 100644 index 000000000..066048795 --- /dev/null +++ b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunstable-options --crate-type rlib +// build-fail +// error-pattern: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs + +#[link(name = "mylib", kind = "static", modifiers = "+bundle,+whole-archive")] +extern "C" { } + +fn main() { } diff --git a/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr new file mode 100644 index 000000000..246efb8d6 --- /dev/null +++ b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr @@ -0,0 +1,6 @@ +error: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs + +error: could not find native static library `mylib`, perhaps an -L flag is missing? + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs new file mode 100644 index 000000000..1d0768d99 --- /dev/null +++ b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs @@ -0,0 +1,7 @@ +// Mixing +bundle and +whole-archive is not allowed + +// compile-flags: -l static:+bundle,+whole-archive=mylib -Zunstable-options --crate-type rlib +// build-fail +// error-pattern: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs + +fn main() { } diff --git a/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr new file mode 100644 index 000000000..246efb8d6 --- /dev/null +++ b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr @@ -0,0 +1,6 @@ +error: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs + +error: could not find native static library `mylib`, perhaps an -L flag is missing? + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/native-library-link-flags/modifiers-override-2.rs b/src/test/ui/native-library-link-flags/modifiers-override-2.rs new file mode 100644 index 000000000..333f6786b --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-2.rs @@ -0,0 +1,3 @@ +// compile-flags:-lstatic:+whole-archive,-whole-archive=foo + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/modifiers-override-2.stderr b/src/test/ui/native-library-link-flags/modifiers-override-2.stderr new file mode 100644 index 000000000..aa5b59c5b --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-2.stderr @@ -0,0 +1,2 @@ +error: multiple `whole-archive` modifiers in a single `-l` option + diff --git a/src/test/ui/native-library-link-flags/modifiers-override-3.rs b/src/test/ui/native-library-link-flags/modifiers-override-3.rs new file mode 100644 index 000000000..b28c53c6b --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-3.rs @@ -0,0 +1,7 @@ +// Regression test for issue #97299, one command line library with modifiers +// overrides another command line library with modifiers. + +// compile-flags:-lstatic:+whole-archive=foo -lstatic:+whole-archive=foo +// error-pattern: overriding linking modifiers from command line is not supported + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/modifiers-override-3.stderr b/src/test/ui/native-library-link-flags/modifiers-override-3.stderr new file mode 100644 index 000000000..365e56181 --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-3.stderr @@ -0,0 +1,4 @@ +error: overriding linking modifiers from command line is not supported + +error: aborting due to previous error + diff --git a/src/test/ui/native-library-link-flags/modifiers-override.rs b/src/test/ui/native-library-link-flags/modifiers-override.rs new file mode 100644 index 000000000..42cdb5004 --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override.rs @@ -0,0 +1,16 @@ +// compile-flags:-ldylib:+as-needed=foo -lstatic=bar -Zunstable-options + +#[link(name = "foo")] +#[link( + name = "bar", + kind = "static", + modifiers = "+whole-archive,-whole-archive", + //~^ ERROR multiple `whole-archive` modifiers in a single `modifiers` argument + modifiers = "+bundle" + //~^ ERROR multiple `modifiers` arguments in a single `#[link]` attribute +)] +extern "C" {} +//~^ ERROR overriding linking modifiers from command line is not supported +//~| ERROR overriding linking modifiers from command line is not supported + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/modifiers-override.stderr b/src/test/ui/native-library-link-flags/modifiers-override.stderr new file mode 100644 index 000000000..eb3ab55c3 --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override.stderr @@ -0,0 +1,26 @@ +error: multiple `modifiers` arguments in a single `#[link]` attribute + --> $DIR/modifiers-override.rs:9:5 + | +LL | modifiers = "+bundle" + | ^^^^^^^^^^^^^^^^^^^^^ + +error: multiple `whole-archive` modifiers in a single `modifiers` argument + --> $DIR/modifiers-override.rs:7:17 + | +LL | modifiers = "+whole-archive,-whole-archive", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: overriding linking modifiers from command line is not supported + --> $DIR/modifiers-override.rs:12:1 + | +LL | extern "C" {} + | ^^^^^^^^^^^^^ + +error: overriding linking modifiers from command line is not supported + --> $DIR/modifiers-override.rs:12:1 + | +LL | extern "C" {} + | ^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + |