Skip to content

Commit 7fc1864

Browse files
committed
fix error message
1 parent 3398306 commit 7fc1864

File tree

1 file changed

+21
-20
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+21
-20
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,21 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
319319
for lib in codegen_results.crate_info.used_libraries.iter() {
320320
match lib.kind {
321321
NativeLibKind::Static { bundle: None | Some(true), whole_archive } => {
322+
if flavor == RlibFlavor::Normal
323+
&& whole_archive == Some(true)
324+
&& !sess.opts.unstable_opts.split_bundled_libs
325+
{
326+
// Don't allow mixing +bundle with +whole_archive since an rlib may contain
327+
// multiple native libs, some of which are +whole-archive and some of which are
328+
// -whole-archive and it isn't clear how we can currently handle such a
329+
// situation correctly.
330+
// See https://github.com/rust-lang/rust/issues/88085#issuecomment-901050897
331+
sess.err(
332+
"the linking modifiers `+bundle` and `+whole-archive` are not compatible \
333+
with each other when generating rlibs",
334+
);
335+
}
336+
322337
let Some(name) = lib.name else {
323338
continue;
324339
};
@@ -329,27 +344,13 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
329344
&lib_search_paths,
330345
sess,
331346
);
332-
if flavor == RlibFlavor::Normal {
333-
if whole_archive == Some(true) && !sess.opts.unstable_opts.split_bundled_libs {
334-
// Don't allow mixing +bundle with +whole_archive since an rlib may contain
335-
// multiple native libs, some of which are +whole-archive and some of which are
336-
// -whole-archive and it isn't clear how we can currently handle such a
337-
// situation correctly.
338-
// See https://github.com/rust-lang/rust/issues/88085#issuecomment-901050897
339-
sess.err(
340-
"the linking modifiers `+bundle` and `+whole-archive` are not compatible \
341-
with each other when generating rlibs",
342-
);
343-
}
344347

345-
if sess.opts.unstable_opts.split_bundled_libs {
346-
let suffix = &sess.target.staticlib_suffix;
347-
let crate_name = out_filename.to_str().unwrap();
348-
let bundle_lib =
349-
PathBuf::from(&format!("{crate_name}.bundle.{name}{suffix}"));
350-
fs::copy(location, bundle_lib).unwrap();
351-
continue;
352-
}
348+
if (flavor == RlibFlavor::Normal) && sess.opts.unstable_opts.split_bundled_libs {
349+
let suffix = &sess.target.staticlib_suffix;
350+
let crate_name = out_filename.to_str().unwrap();
351+
let bundle_lib = PathBuf::from(&format!("{crate_name}.bundle.{name}{suffix}"));
352+
fs::copy(location, bundle_lib).unwrap();
353+
continue;
353354
}
354355

355356
ab.add_archive(&location, |_| false).unwrap_or_else(|e| {

0 commit comments

Comments
 (0)