Skip to content

Commit

Permalink
Rollup merge of rust-lang#97328 - petrochenkov:nativice, r=michaelwoe…
Browse files Browse the repository at this point in the history
…rister

rustc: Fix ICE in native library error reporting

Fixes rust-lang#97299
  • Loading branch information
Dylan-DPC authored and ehuss committed Jun 1, 2022
1 parent 0a2d181 commit 054a2bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,11 @@ impl<'tcx> Collector<'tcx> {
// involved or not, library reordering and kind overriding without
// explicit `:rename` in particular.
if lib.has_modifiers() || passed_lib.has_modifiers() {
self.tcx.sess.span_err(
self.tcx.def_span(lib.foreign_module.unwrap()),
"overriding linking modifiers from command line is not supported"
);
let msg = "overriding linking modifiers from command line is not supported";
match lib.foreign_module {
Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg),
None => self.tcx.sess.err(msg),
};
}
if passed_lib.kind != NativeLibKind::Unspecified {
lib.kind = passed_lib.kind;
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/native-library-link-flags/modifiers-override-3.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: overriding linking modifiers from command line is not supported

error: aborting due to previous error

0 comments on commit 054a2bd

Please sign in to comment.