Skip to content

Commit ca712bc

Browse files
committed
Auto merge of rust-lang#85036 - Dylan-DPC:rollup-4qfabo3, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - rust-lang#84254 (illumos should put libc last in library search order) - rust-lang#84442 (Unify rustc and rustdoc parsing of `cfg()`) - rust-lang#84655 (Cleanup of `wasm`) - rust-lang#84866 (linker: Avoid library duplication with `/WHOLEARCHIVE`) - rust-lang#84930 (rename LLVM target for RustyHermit) - rust-lang#84991 (rustc: Support Rust-specific features in -Ctarget-feature) - rust-lang#85029 (SGX mutex is movable) - rust-lang#85030 (Rearrange SGX split module files) - rust-lang#85033 (some further small cleanups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e5f83d2 + 4284809 commit ca712bc

File tree

31 files changed

+199
-211
lines changed

31 files changed

+199
-211
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+23-15
Original file line numberDiff line numberDiff line change
@@ -339,24 +339,32 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
339339
Some(_) | None => {}
340340
};
341341

342+
let filter = |s: &str| {
343+
if s.is_empty() {
344+
return None;
345+
}
346+
let feature = if s.starts_with("+") || s.starts_with("-") {
347+
&s[1..]
348+
} else {
349+
return Some(s.to_string());
350+
};
351+
// Rustc-specific feature requests like `+crt-static` or `-crt-static`
352+
// are not passed down to LLVM.
353+
if RUSTC_SPECIFIC_FEATURES.contains(&feature) {
354+
return None;
355+
}
356+
// ... otherwise though we run through `to_llvm_feature` feature when
357+
// passing requests down to LLVM. This means that all in-language
358+
// features also work on the command line instead of having two
359+
// different names when the LLVM name and the Rust name differ.
360+
Some(format!("{}{}", &s[..1], to_llvm_feature(sess, feature)))
361+
};
362+
342363
// Features implied by an implicit or explicit `--target`.
343-
features.extend(
344-
sess.target
345-
.features
346-
.split(',')
347-
.filter(|f| !f.is_empty() && !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)))
348-
.map(String::from),
349-
);
364+
features.extend(sess.target.features.split(',').filter_map(&filter));
350365

351366
// -Ctarget-features
352-
features.extend(
353-
sess.opts
354-
.cg
355-
.target_feature
356-
.split(',')
357-
.filter(|f| !f.is_empty() && !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)))
358-
.map(String::from),
359-
);
367+
features.extend(sess.opts.cg.target_feature.split(',').filter_map(&filter));
360368

361369
features
362370
}

compiler/rustc_codegen_ssa/src/back/linker.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ impl<'a> Linker for GccLinker<'a> {
340340
}
341341

342342
fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool) {
343+
if self.sess.target.os == "illumos" && lib.as_str() == "c" {
344+
// libc will be added via late_link_args on illumos so that it will
345+
// appear last in the library search order.
346+
// FIXME: This should be replaced by a more complete and generic
347+
// mechanism for controlling the order of library arguments passed
348+
// to the linker.
349+
return;
350+
}
343351
if !as_needed {
344352
if self.sess.target.is_like_osx {
345353
// FIXME(81490): ld64 doesn't support these flags but macOS 11
@@ -813,11 +821,9 @@ impl<'a> Linker for MsvcLinker<'a> {
813821
}
814822

815823
fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
816-
self.link_staticlib(lib, verbatim);
817824
self.cmd.arg(format!("/WHOLEARCHIVE:{}{}", lib, if verbatim { "" } else { ".lib" }));
818825
}
819826
fn link_whole_rlib(&mut self, path: &Path) {
820-
self.link_rlib(path);
821827
let mut arg = OsString::from("/WHOLEARCHIVE:");
822828
arg.push(path);
823829
self.cmd.arg(arg);

compiler/rustc_expand/src/config.rs

+29-25
Original file line numberDiff line numberDiff line change
@@ -464,31 +464,9 @@ impl<'a> StripUnconfigured<'a> {
464464
return true;
465465
}
466466
};
467-
let error = |span, msg, suggestion: &str| {
468-
let mut err = self.sess.parse_sess.span_diagnostic.struct_span_err(span, msg);
469-
if !suggestion.is_empty() {
470-
err.span_suggestion(
471-
span,
472-
"expected syntax is",
473-
suggestion.into(),
474-
Applicability::MaybeIncorrect,
475-
);
476-
}
477-
err.emit();
478-
true
479-
};
480-
let span = meta_item.span;
481-
match meta_item.meta_item_list() {
482-
None => error(span, "`cfg` is not followed by parentheses", "cfg(/* predicate */)"),
483-
Some([]) => error(span, "`cfg` predicate is not specified", ""),
484-
Some([_, .., l]) => error(l.span(), "multiple `cfg` predicates are specified", ""),
485-
Some([single]) => match single.meta_item() {
486-
Some(meta_item) => {
487-
attr::cfg_matches(meta_item, &self.sess.parse_sess, self.features)
488-
}
489-
None => error(single.span(), "`cfg` predicate key cannot be a literal", ""),
490-
},
491-
}
467+
parse_cfg(&meta_item, &self.sess).map_or(true, |meta_item| {
468+
attr::cfg_matches(&meta_item, &self.sess.parse_sess, self.features)
469+
})
492470
})
493471
}
494472

@@ -532,6 +510,32 @@ impl<'a> StripUnconfigured<'a> {
532510
}
533511
}
534512

513+
pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a MetaItem> {
514+
let error = |span, msg, suggestion: &str| {
515+
let mut err = sess.parse_sess.span_diagnostic.struct_span_err(span, msg);
516+
if !suggestion.is_empty() {
517+
err.span_suggestion(
518+
span,
519+
"expected syntax is",
520+
suggestion.into(),
521+
Applicability::HasPlaceholders,
522+
);
523+
}
524+
err.emit();
525+
None
526+
};
527+
let span = meta_item.span;
528+
match meta_item.meta_item_list() {
529+
None => error(span, "`cfg` is not followed by parentheses", "cfg(/* predicate */)"),
530+
Some([]) => error(span, "`cfg` predicate is not specified", ""),
531+
Some([_, .., l]) => error(l.span(), "multiple `cfg` predicates are specified", ""),
532+
Some([single]) => match single.meta_item() {
533+
Some(meta_item) => Some(meta_item),
534+
None => error(single.span(), "`cfg` predicate key cannot be a literal", ""),
535+
},
536+
}
537+
}
538+
535539
fn is_cfg(sess: &Session, attr: &Attribute) -> bool {
536540
sess.check_name(attr, sym::cfg)
537541
}

compiler/rustc_target/src/spec/illumos_base.rs

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ pub fn opts() -> TargetOptions {
66
late_link_args.insert(
77
LinkerFlavor::Gcc,
88
vec![
9+
// The illumos libc contains a stack unwinding implementation, as
10+
// does libgcc_s. The latter implementation includes several
11+
// additional symbols that are not always in base libc. To force
12+
// the consistent use of just one unwinder, we ensure libc appears
13+
// after libgcc_s in the NEEDED list for the resultant binary by
14+
// ignoring any attempts to add it as a dynamic dependency until the
15+
// very end.
16+
// FIXME: This should be replaced by a more complete and generic
17+
// mechanism for controlling the order of library arguments passed
18+
// to the linker.
19+
"-lc".to_string(),
920
// LLVM will insert calls to the stack protector functions
1021
// "__stack_chk_fail" and "__stack_chk_guard" into code in native
1122
// object files. Some platforms include these symbols directly in

compiler/rustc_target/src/spec/x86_64_unknown_none_hermitkernel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
base.stack_probes = StackProbeType::Call;
1212

1313
Target {
14-
llvm_target: "x86_64-unknown-none-elf".to_string(),
14+
llvm_target: "x86_64-unknown-hermit".to_string(),
1515
pointer_width: 64,
1616
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1717
.to_string(),

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
720720
pub(in super::super) fn select_obligations_where_possible(
721721
&self,
722722
fallback_has_occurred: bool,
723-
mutate_fullfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
723+
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
724724
) {
725725
let result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
726726
if let Err(mut errors) = result {
727-
mutate_fullfillment_errors(&mut errors);
727+
mutate_fulfillment_errors(&mut errors);
728728
self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred);
729729
}
730730
}

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
986986
error.obligation.predicate.kind().skip_binder()
987987
{
988988
// If any of the type arguments in this path segment caused the
989-
// `FullfillmentError`, point at its span (#61860).
989+
// `FulfillmentError`, point at its span (#61860).
990990
for arg in path
991991
.segments
992992
.iter()

0 commit comments

Comments
 (0)