Skip to content
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

rustc: Stabilize -C target-feature=+crt-static #41757

Merged
merged 1 commit into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 16 additions & 3 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,24 @@ impl RustcDefaultCalls {
node: ast::MetaItemKind::Word,
span: DUMMY_SP,
});
if !allow_unstable_cfg && gated_cfg.is_some() {
continue;

// Note that crt-static is a specially recognized cfg
// directive that's printed out here as part of
// rust-lang/rust#37406, but in general the
// `target_feature` cfg is gated under
// rust-lang/rust#29717. For now this is just
// specifically allowing the crt-static cfg and that's
// it, this is intended to get into Cargo and then go
// through to build scripts.
let value = value.as_ref().map(|s| s.as_str());
let value = value.as_ref().map(|s| s.as_ref());
if name != "target_feature" || value != Some("crt-static") {
if !allow_unstable_cfg && gated_cfg.is_some() {
continue;
}
}

cfgs.push(if let &Some(ref value) = value {
cfgs.push(if let Some(value) = value {
format!("{}=\"{}\"", name, value)
} else {
format!("{}", name)
Expand Down
11 changes: 0 additions & 11 deletions src/librustc_driver/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use syntax::ast;
use llvm::LLVMRustHasFeature;
use rustc::session::Session;
use rustc_trans::back::write::create_target_machine;
use syntax::feature_gate::UnstableFeatures;
use syntax::symbol::Symbol;
use libc::c_char;

Expand Down Expand Up @@ -50,8 +49,6 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) {
}

let requested_features = sess.opts.cg.target_feature.split(',');
let unstable_options = sess.opts.debugging_opts.unstable_options;
let is_nightly = UnstableFeatures::from_environment().is_nightly_build();
let found_negative = requested_features.clone().any(|r| r == "-crt-static");
let found_positive = requested_features.clone().any(|r| r == "+crt-static");

Expand All @@ -65,14 +62,6 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) {
found_positive
};

// If we switched from the default then that's only allowed on nightly, so
// gate that here.
if (found_positive || found_negative) && (!is_nightly || !unstable_options) {
sess.fatal("specifying the `crt-static` target feature is only allowed \
on the nightly channel with `-Z unstable-options` passed \
as well");
}

if crt_static {
cfg.insert((tf, Some(Symbol::intern("crt-static"))));
}
Expand Down
14 changes: 0 additions & 14 deletions src/test/compile-fail/crt-static-gated.rs

This file was deleted.