mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Factor out a helper for the getting C runtime linkage
This commit makes no functional changes.
This commit is contained in:
parent
52832439ad
commit
3cb987862f
@ -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
|
||||
|
@ -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"))));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user