Factor out a helper for the getting C runtime linkage

This commit makes no functional changes.
This commit is contained in:
Samuel Holland 2017-08-22 16:24:29 -05:00
parent 52832439ad
commit 3cb987862f
2 changed files with 17 additions and 15 deletions

View File

@ -429,6 +429,22 @@ impl Session {
.unwrap_or(self.opts.debug_assertions)
}
pub fn crt_static(&self) -> bool {
let requested_features = self.opts.cg.target_feature.split(',');
let found_negative = requested_features.clone().any(|r| r == "-crt-static");
let found_positive = requested_features.clone().any(|r| r == "+crt-static");
// If the target we're compiling for requests a static crt by default,
// then see if the `-crt-static` feature was passed to disable that.
// Otherwise if we don't have a static crt by default then see if the
// `+crt-static` feature was passed.
if self.target.target.options.crt_static_default {
!found_negative
} else {
found_positive
}
}
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
self.opts.debuginfo != DebugInfoLevel::NoDebugInfo ||
!self.target.target.options.eliminate_frame_pointer

View File

@ -25,21 +25,7 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) {
cfg.insert((tf, Some(feat)));
}
let requested_features = sess.opts.cg.target_feature.split(',');
let found_negative = requested_features.clone().any(|r| r == "-crt-static");
let found_positive = requested_features.clone().any(|r| r == "+crt-static");
// If the target we're compiling for requests a static crt by default,
// then see if the `-crt-static` feature was passed to disable that.
// Otherwise if we don't have a static crt by default then see if the
// `+crt-static` feature was passed.
let crt_static = if sess.target.target.options.crt_static_default {
!found_negative
} else {
found_positive
};
if crt_static {
if sess.crt_static() {
cfg.insert((tf, Some(Symbol::intern("crt-static"))));
}
}