Skip to content

Commit

Permalink
Auto merge of rust-lang#85036 - Dylan-DPC:rollup-4qfabo3, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed May 7, 2021
2 parents e5f83d2 + 4284809 commit ca712bc
Show file tree
Hide file tree
Showing 31 changed files with 199 additions and 211 deletions.
38 changes: 23 additions & 15 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,24 +339,32 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
Some(_) | None => {}
};

let filter = |s: &str| {
if s.is_empty() {
return None;
}
let feature = if s.starts_with("+") || s.starts_with("-") {
&s[1..]
} else {
return Some(s.to_string());
};
// Rustc-specific feature requests like `+crt-static` or `-crt-static`
// are not passed down to LLVM.
if RUSTC_SPECIFIC_FEATURES.contains(&feature) {
return None;
}
// ... otherwise though we run through `to_llvm_feature` feature when
// passing requests down to LLVM. This means that all in-language
// features also work on the command line instead of having two
// different names when the LLVM name and the Rust name differ.
Some(format!("{}{}", &s[..1], to_llvm_feature(sess, feature)))
};

// Features implied by an implicit or explicit `--target`.
features.extend(
sess.target
.features
.split(',')
.filter(|f| !f.is_empty() && !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)))
.map(String::from),
);
features.extend(sess.target.features.split(',').filter_map(&filter));

// -Ctarget-features
features.extend(
sess.opts
.cg
.target_feature
.split(',')
.filter(|f| !f.is_empty() && !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)))
.map(String::from),
);
features.extend(sess.opts.cg.target_feature.split(',').filter_map(&filter));

features
}
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ impl<'a> Linker for GccLinker<'a> {
}

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

fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
self.link_staticlib(lib, verbatim);
self.cmd.arg(format!("/WHOLEARCHIVE:{}{}", lib, if verbatim { "" } else { ".lib" }));
}
fn link_whole_rlib(&mut self, path: &Path) {
self.link_rlib(path);
let mut arg = OsString::from("/WHOLEARCHIVE:");
arg.push(path);
self.cmd.arg(arg);
Expand Down
54 changes: 29 additions & 25 deletions compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,31 +464,9 @@ impl<'a> StripUnconfigured<'a> {
return true;
}
};
let error = |span, msg, suggestion: &str| {
let mut err = self.sess.parse_sess.span_diagnostic.struct_span_err(span, msg);
if !suggestion.is_empty() {
err.span_suggestion(
span,
"expected syntax is",
suggestion.into(),
Applicability::MaybeIncorrect,
);
}
err.emit();
true
};
let span = meta_item.span;
match meta_item.meta_item_list() {
None => error(span, "`cfg` is not followed by parentheses", "cfg(/* predicate */)"),
Some([]) => error(span, "`cfg` predicate is not specified", ""),
Some([_, .., l]) => error(l.span(), "multiple `cfg` predicates are specified", ""),
Some([single]) => match single.meta_item() {
Some(meta_item) => {
attr::cfg_matches(meta_item, &self.sess.parse_sess, self.features)
}
None => error(single.span(), "`cfg` predicate key cannot be a literal", ""),
},
}
parse_cfg(&meta_item, &self.sess).map_or(true, |meta_item| {
attr::cfg_matches(&meta_item, &self.sess.parse_sess, self.features)
})
})
}

Expand Down Expand Up @@ -532,6 +510,32 @@ impl<'a> StripUnconfigured<'a> {
}
}

pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a MetaItem> {
let error = |span, msg, suggestion: &str| {
let mut err = sess.parse_sess.span_diagnostic.struct_span_err(span, msg);
if !suggestion.is_empty() {
err.span_suggestion(
span,
"expected syntax is",
suggestion.into(),
Applicability::HasPlaceholders,
);
}
err.emit();
None
};
let span = meta_item.span;
match meta_item.meta_item_list() {
None => error(span, "`cfg` is not followed by parentheses", "cfg(/* predicate */)"),
Some([]) => error(span, "`cfg` predicate is not specified", ""),
Some([_, .., l]) => error(l.span(), "multiple `cfg` predicates are specified", ""),
Some([single]) => match single.meta_item() {
Some(meta_item) => Some(meta_item),
None => error(single.span(), "`cfg` predicate key cannot be a literal", ""),
},
}
}

fn is_cfg(sess: &Session, attr: &Attribute) -> bool {
sess.check_name(attr, sym::cfg)
}
11 changes: 11 additions & 0 deletions compiler/rustc_target/src/spec/illumos_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ pub fn opts() -> TargetOptions {
late_link_args.insert(
LinkerFlavor::Gcc,
vec![
// The illumos libc contains a stack unwinding implementation, as
// does libgcc_s. The latter implementation includes several
// additional symbols that are not always in base libc. To force
// the consistent use of just one unwinder, we ensure libc appears
// after libgcc_s in the NEEDED list for the resultant binary by
// ignoring any attempts to add it as a dynamic dependency until the
// very end.
// FIXME: This should be replaced by a more complete and generic
// mechanism for controlling the order of library arguments passed
// to the linker.
"-lc".to_string(),
// LLVM will insert calls to the stack protector functions
// "__stack_chk_fail" and "__stack_chk_guard" into code in native
// object files. Some platforms include these symbols directly in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
base.stack_probes = StackProbeType::Call;

Target {
llvm_target: "x86_64-unknown-none-elf".to_string(),
llvm_target: "x86_64-unknown-hermit".to_string(),
pointer_width: 64,
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(in super::super) fn select_obligations_where_possible(
&self,
fallback_has_occurred: bool,
mutate_fullfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
) {
let result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
if let Err(mut errors) = result {
mutate_fullfillment_errors(&mut errors);
mutate_fulfillment_errors(&mut errors);
self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
error.obligation.predicate.kind().skip_binder()
{
// If any of the type arguments in this path segment caused the
// `FullfillmentError`, point at its span (#61860).
// `FulfillmentError`, point at its span (#61860).
for arg in path
.segments
.iter()
Expand Down
Loading

0 comments on commit ca712bc

Please sign in to comment.