]>
git.proxmox.com Git - rustc.git/blob - src/librustc_driver/target_features.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use rustc
::session
::Session
;
13 use syntax
::symbol
::Symbol
;
16 /// Add `target_feature = "..."` cfgs for a variety of platform
17 /// specific features (SSE, NEON etc.).
19 /// This is performed by checking whether a whitelisted set of
20 /// features is available on the target machine, by querying LLVM.
21 pub fn add_configuration(cfg
: &mut ast
::CrateConfig
, sess
: &Session
) {
22 let tf
= Symbol
::intern("target_feature");
24 for feat
in rustc_trans
::target_features(sess
) {
25 cfg
.insert((tf
, Some(feat
)));
28 let requested_features
= sess
.opts
.cg
.target_feature
.split('
,'
);
29 let found_negative
= requested_features
.clone().any(|r
| r
== "-crt-static");
30 let found_positive
= requested_features
.clone().any(|r
| r
== "+crt-static");
32 // If the target we're compiling for requests a static crt by default,
33 // then see if the `-crt-static` feature was passed to disable that.
34 // Otherwise if we don't have a static crt by default then see if the
35 // `+crt-static` feature was passed.
36 let crt_static
= if sess
.target
.target
.options
.crt_static_default
{
43 cfg
.insert((tf
, Some(Symbol
::intern("crt-static"))));