Skip to content

Add negative test coverage for -Clink-self-contained and -Zlinker-features #140997

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

Merged
merged 2 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add some negative test coverage for malformed -Clink-self-contained
… flags
  • Loading branch information
jieyouxu committed May 15, 2025
commit 3e051afec7a0223c86bdab9cd751b32f6a988465
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `*lld` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

23 changes: 23 additions & 0 deletions tests/ui/linking/link-self-contained-malformed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Check that malformed `-Clink-self-contained` invocations are properly rejected.

//@ revisions: no_value
//@[no_value] compile-flags: -Clink-self-contained=
//[no_value]~? ERROR incorrect value `` for codegen option `link-self-contained`

//@ revisions: invalid_modifier
//@[invalid_modifier] compile-flags: -Clink-self-contained=*lld
//[invalid_modifier]~? ERROR incorrect value `*lld` for codegen option `link-self-contained`

//@ revisions: unknown_value
//@[unknown_value] compile-flags: -Clink-self-contained=unknown
//[unknown_value]~? ERROR incorrect value `unknown` for codegen option `link-self-contained`

//@ revisions: unknown_modifier_value
//@[unknown_modifier_value] compile-flags: -Clink-self-contained=-unknown
//[unknown_modifier_value]~? ERROR incorrect value `-unknown` for codegen option `link-self-contained`

//@ revisions: unknown_boolean
//@[unknown_boolean] compile-flags: -Clink-self-contained=maybe
//[unknown_boolean]~? ERROR incorrect value `maybe` for codegen option `link-self-contained`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `maybe` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `-unknown` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `unknown` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected