Skip to content

Commit 6f03b80

Browse files
committed
rustc_back: move LinkerFlavor, PanicStrategy, and RelroLevel to target.
1 parent 88cd367 commit 6f03b80

File tree

110 files changed

+240
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+240
-340
lines changed

src/librustc/ich/impls_misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl_stable_hash_for!(enum ::session::search_paths::PathKind {
2020
All
2121
});
2222

23-
impl_stable_hash_for!(enum ::rustc_back::PanicStrategy {
23+
impl_stable_hash_for!(enum ::rustc_back::target::PanicStrategy {
2424
Abort,
2525
Unwind
2626
});

src/librustc/middle/dependency_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use ty::TyCtxt;
6969
use middle::cstore::{self, DepKind};
7070
use middle::cstore::LinkagePreference::{self, RequireStatic, RequireDynamic};
7171
use util::nodemap::FxHashMap;
72-
use rustc_back::PanicStrategy;
72+
use rustc_back::target::PanicStrategy;
7373

7474
/// A list of dependencies for a certain crate type.
7575
///

src/librustc/middle/weak_lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use session::config;
1414
use middle::lang_items;
1515

16-
use rustc_back::PanicStrategy;
16+
use rustc_back::target::PanicStrategy;
1717
use syntax::ast;
1818
use syntax::symbol::Symbol;
1919
use syntax_pos::Span;

src/librustc/session/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use session::{early_error, early_warn, Session};
2222
use session::search_paths::SearchPaths;
2323

2424
use ich::StableHashingContext;
25-
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
25+
use rustc_back::target::{LinkerFlavor, PanicStrategy, RelroLevel};
2626
use rustc_back::target::{Target, TargetTriple};
2727
use rustc_data_structures::stable_hasher::ToStableHashKey;
2828
use lint;
@@ -770,7 +770,7 @@ macro_rules! options {
770770
pub const parse_sanitizer: Option<&'static str> =
771771
Some("one of: `address`, `leak`, `memory` or `thread`");
772772
pub const parse_linker_flavor: Option<&'static str> =
773-
Some(::rustc_back::LinkerFlavor::one_of());
773+
Some(::rustc_back::target::LinkerFlavor::one_of());
774774
pub const parse_optimization_fuel: Option<&'static str> =
775775
Some("crate=integer");
776776
pub const parse_unpretty: Option<&'static str> =
@@ -782,7 +782,7 @@ macro_rules! options {
782782
#[allow(dead_code)]
783783
mod $mod_set {
784784
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto};
785-
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
785+
use rustc_back::target::{LinkerFlavor, PanicStrategy, RelroLevel};
786786
use std::path::PathBuf;
787787

788788
$(
@@ -2323,7 +2323,7 @@ mod dep_tracking {
23232323
use super::{CrateType, DebugInfoLevel, ErrorOutputType, Lto, OptLevel, OutputTypes,
23242324
Passes, Sanitizer};
23252325
use syntax::feature_gate::UnstableFeatures;
2326-
use rustc_back::{PanicStrategy, RelroLevel};
2326+
use rustc_back::target::{PanicStrategy, RelroLevel};
23272327
use rustc_back::target::TargetTriple;
23282328
use syntax::edition::Edition;
23292329

@@ -2456,7 +2456,7 @@ mod tests {
24562456
use std::iter::FromIterator;
24572457
use std::path::PathBuf;
24582458
use super::{Externs, OutputType, OutputTypes};
2459-
use rustc_back::{PanicStrategy, RelroLevel};
2459+
use rustc_back::target::{PanicStrategy, RelroLevel};
24602460
use syntax::symbol::Symbol;
24612461
use syntax::edition::{Edition, DEFAULT_EDITION};
24622462
use syntax;

src/librustc/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use syntax::{ast, codemap};
4141
use syntax::feature_gate::AttributeType;
4242
use syntax_pos::{MultiSpan, Span};
4343

44-
use rustc_back::{LinkerFlavor, PanicStrategy};
44+
use rustc_back::target::{LinkerFlavor, PanicStrategy};
4545
use rustc_back::target::{Target, TargetTriple};
4646
use rustc_data_structures::flock;
4747
use jobserver::Client;

src/librustc/ty/maps/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
4545
use util::common::{profq_msg, ErrorReported, ProfileQueriesMsg};
4646

4747
use rustc_data_structures::indexed_set::IdxSetBuf;
48-
use rustc_back::PanicStrategy;
48+
use rustc_back::target::PanicStrategy;
4949
use rustc_data_structures::indexed_vec::IndexVec;
5050
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5151
use rustc_data_structures::stable_hasher::StableVec;

src/librustc_back/lib.rs

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -37,134 +37,3 @@ extern crate serialize;
3737
extern crate serialize as rustc_serialize; // used by deriving
3838

3939
pub mod target;
40-
41-
use std::str::FromStr;
42-
43-
use serialize::json::{Json, ToJson};
44-
45-
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
46-
RustcEncodable, RustcDecodable)]
47-
pub enum LinkerFlavor {
48-
Em,
49-
Gcc,
50-
Ld,
51-
Msvc,
52-
Lld(LldFlavor),
53-
}
54-
55-
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
56-
RustcEncodable, RustcDecodable)]
57-
pub enum LldFlavor {
58-
Wasm,
59-
Ld64,
60-
Ld,
61-
Link,
62-
}
63-
64-
impl ToJson for LinkerFlavor {
65-
fn to_json(&self) -> Json {
66-
self.desc().to_json()
67-
}
68-
}
69-
macro_rules! flavor_mappings {
70-
($((($($flavor:tt)*), $string:expr),)*) => (
71-
impl LinkerFlavor {
72-
pub const fn one_of() -> &'static str {
73-
concat!("one of: ", $($string, " ",)+)
74-
}
75-
76-
pub fn from_str(s: &str) -> Option<Self> {
77-
Some(match s {
78-
$($string => $($flavor)*,)+
79-
_ => return None,
80-
})
81-
}
82-
83-
pub fn desc(&self) -> &str {
84-
match *self {
85-
$($($flavor)* => $string,)+
86-
}
87-
}
88-
}
89-
)
90-
}
91-
92-
93-
flavor_mappings! {
94-
((LinkerFlavor::Em), "em"),
95-
((LinkerFlavor::Gcc), "gcc"),
96-
((LinkerFlavor::Ld), "ld"),
97-
((LinkerFlavor::Msvc), "msvc"),
98-
((LinkerFlavor::Lld(LldFlavor::Wasm)), "wasm-ld"),
99-
((LinkerFlavor::Lld(LldFlavor::Ld64)), "ld64.lld"),
100-
((LinkerFlavor::Lld(LldFlavor::Ld)), "ld.lld"),
101-
((LinkerFlavor::Lld(LldFlavor::Link)), "lld-link"),
102-
}
103-
104-
#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
105-
pub enum PanicStrategy {
106-
Unwind,
107-
Abort,
108-
}
109-
110-
impl PanicStrategy {
111-
pub fn desc(&self) -> &str {
112-
match *self {
113-
PanicStrategy::Unwind => "unwind",
114-
PanicStrategy::Abort => "abort",
115-
}
116-
}
117-
}
118-
119-
impl ToJson for PanicStrategy {
120-
fn to_json(&self) -> Json {
121-
match *self {
122-
PanicStrategy::Abort => "abort".to_json(),
123-
PanicStrategy::Unwind => "unwind".to_json(),
124-
}
125-
}
126-
}
127-
128-
#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
129-
pub enum RelroLevel {
130-
Full,
131-
Partial,
132-
Off,
133-
None,
134-
}
135-
136-
impl RelroLevel {
137-
pub fn desc(&self) -> &str {
138-
match *self {
139-
RelroLevel::Full => "full",
140-
RelroLevel::Partial => "partial",
141-
RelroLevel::Off => "off",
142-
RelroLevel::None => "none",
143-
}
144-
}
145-
}
146-
147-
impl FromStr for RelroLevel {
148-
type Err = ();
149-
150-
fn from_str(s: &str) -> Result<RelroLevel, ()> {
151-
match s {
152-
"full" => Ok(RelroLevel::Full),
153-
"partial" => Ok(RelroLevel::Partial),
154-
"off" => Ok(RelroLevel::Off),
155-
"none" => Ok(RelroLevel::None),
156-
_ => Err(()),
157-
}
158-
}
159-
}
160-
161-
impl ToJson for RelroLevel {
162-
fn to_json(&self) -> Json {
163-
match *self {
164-
RelroLevel::Full => "full".to_json(),
165-
RelroLevel::Partial => "partial".to_json(),
166-
RelroLevel::Off => "off".to_json(),
167-
RelroLevel::None => "None".to_json(),
168-
}
169-
}
170-
}

src/librustc_back/target/aarch64_apple_ios.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312
use super::apple_ios_base::{opts, Arch};
1413

1514
pub fn target() -> TargetResult {

src/librustc_back/target/aarch64_linux_android.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
1514
// for target ABI requirements.

src/librustc_back/target/aarch64_unknown_cloudabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::cloudabi_base::opts();

src/librustc_back/target/aarch64_unknown_freebsd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::freebsd_base::opts();

src/librustc_back/target/aarch64_unknown_fuchsia.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::fuchsia_base::opts();

src/librustc_back/target/aarch64_unknown_linux_gnu.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::linux_base::opts();

src/librustc_back/target/aarch64_unknown_linux_musl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::linux_musl_base::opts();

src/librustc_back/target/android_base.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::TargetOptions;
11+
use target::{LinkerFlavor, TargetOptions};
1312

1413
pub fn opts() -> TargetOptions {
1514
let mut base = super::linux_base::opts();

src/librustc_back/target/apple_ios_base.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
1211
use std::io;
1312
use std::process::Command;
14-
use target::{LinkArgs, TargetOptions};
13+
use target::{LinkArgs, LinkerFlavor, TargetOptions};
1514

1615
use self::Arch::*;
1716

src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::android_base::opts();

src/librustc_back/target/arm_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::linux_base::opts();

src/librustc_back/target/arm_unknown_linux_gnueabihf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::linux_base::opts();

src/librustc_back/target/arm_unknown_linux_musleabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::linux_musl_base::opts();

src/librustc_back/target/arm_unknown_linux_musleabihf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let mut base = super::linux_musl_base::opts();

src/librustc_back/target/armv4t_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let base = super::linux_base::opts();

src/librustc_back/target/armv5te_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312

1413
pub fn target() -> TargetResult {
1514
let base = super::linux_base::opts();

src/librustc_back/target/armv7_apple_ios.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
11+
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
1312
use super::apple_ios_base::{opts, Arch};
1413

1514
pub fn target() -> TargetResult {

0 commit comments

Comments
 (0)