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

Rename rustc_back to rustc_target and move ABI code to it. #50228

Merged
merged 10 commits into from
Apr 26, 2018
Next Next commit
rustc_back: move LinkerFlavor, PanicStrategy, and RelroLevel to target.
  • Loading branch information
irinagpopa committed Apr 26, 2018
commit 6f03b80020907a2ac3d3559fcab5516ef870f46b
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@ impl_stable_hash_for!(enum ::session::search_paths::PathKind {
All
});

impl_stable_hash_for!(enum ::rustc_back::PanicStrategy {
impl_stable_hash_for!(enum ::rustc_back::target::PanicStrategy {
Abort,
Unwind
});
2 changes: 1 addition & 1 deletion src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 69,7 @@ use ty::TyCtxt;
use middle::cstore::{self, DepKind};
use middle::cstore::LinkagePreference::{self, RequireStatic, RequireDynamic};
use util::nodemap::FxHashMap;
use rustc_back::PanicStrategy;
use rustc_back::target::PanicStrategy;

/// A list of dependencies for a certain crate type.
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 13,7 @@
use session::config;
use middle::lang_items;

use rustc_back::PanicStrategy;
use rustc_back::target::PanicStrategy;
use syntax::ast;
use syntax::symbol::Symbol;
use syntax_pos::Span;
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 22,7 @@ use session::{early_error, early_warn, Session};
use session::search_paths::SearchPaths;

use ich::StableHashingContext;
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_back::target::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_back::target::{Target, TargetTriple};
use rustc_data_structures::stable_hasher::ToStableHashKey;
use lint;
Expand Down Expand Up @@ -770,7 770,7 @@ macro_rules! options {
pub const parse_sanitizer: Option<&'static str> =
Some("one of: `address`, `leak`, `memory` or `thread`");
pub const parse_linker_flavor: Option<&'static str> =
Some(::rustc_back::LinkerFlavor::one_of());
Some(::rustc_back::target::LinkerFlavor::one_of());
pub const parse_optimization_fuel: Option<&'static str> =
Some("crate=integer");
pub const parse_unpretty: Option<&'static str> =
Expand All @@ -782,7 782,7 @@ macro_rules! options {
#[allow(dead_code)]
mod $mod_set {
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto};
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_back::target::{LinkerFlavor, PanicStrategy, RelroLevel};
use std::path::PathBuf;

$(
Expand Down Expand Up @@ -2323,7 2323,7 @@ mod dep_tracking {
use super::{CrateType, DebugInfoLevel, ErrorOutputType, Lto, OptLevel, OutputTypes,
Passes, Sanitizer};
use syntax::feature_gate::UnstableFeatures;
use rustc_back::{PanicStrategy, RelroLevel};
use rustc_back::target::{PanicStrategy, RelroLevel};
use rustc_back::target::TargetTriple;
use syntax::edition::Edition;

Expand Down Expand Up @@ -2456,7 2456,7 @@ mod tests {
use std::iter::FromIterator;
use std::path::PathBuf;
use super::{Externs, OutputType, OutputTypes};
use rustc_back::{PanicStrategy, RelroLevel};
use rustc_back::target::{PanicStrategy, RelroLevel};
use syntax::symbol::Symbol;
use syntax::edition::{Edition, DEFAULT_EDITION};
use syntax;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 41,7 @@ use syntax::{ast, codemap};
use syntax::feature_gate::AttributeType;
use syntax_pos::{MultiSpan, Span};

use rustc_back::{LinkerFlavor, PanicStrategy};
use rustc_back::target::{LinkerFlavor, PanicStrategy};
use rustc_back::target::{Target, TargetTriple};
use rustc_data_structures::flock;
use jobserver::Client;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 45,7 @@ use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
use util::common::{profq_msg, ErrorReported, ProfileQueriesMsg};

use rustc_data_structures::indexed_set::IdxSetBuf;
use rustc_back::PanicStrategy;
use rustc_back::target::PanicStrategy;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stable_hasher::StableVec;
Expand Down
131 changes: 0 additions & 131 deletions src/librustc_back/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,134 37,3 @@ extern crate serialize;
extern crate serialize as rustc_serialize; // used by deriving

pub mod target;

use std::str::FromStr;

use serialize::json::{Json, ToJson};

#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
RustcEncodable, RustcDecodable)]
pub enum LinkerFlavor {
Em,
Gcc,
Ld,
Msvc,
Lld(LldFlavor),
}

#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
RustcEncodable, RustcDecodable)]
pub enum LldFlavor {
Wasm,
Ld64,
Ld,
Link,
}

impl ToJson for LinkerFlavor {
fn to_json(&self) -> Json {
self.desc().to_json()
}
}
macro_rules! flavor_mappings {
($((($($flavor:tt)*), $string:expr),)*) => (
impl LinkerFlavor {
pub const fn one_of() -> &'static str {
concat!("one of: ", $($string, " ",) )
}

pub fn from_str(s: &str) -> Option<Self> {
Some(match s {
$($string => $($flavor)*,)
_ => return None,
})
}

pub fn desc(&self) -> &str {
match *self {
$($($flavor)* => $string,)
}
}
}
)
}


flavor_mappings! {
((LinkerFlavor::Em), "em"),
((LinkerFlavor::Gcc), "gcc"),
((LinkerFlavor::Ld), "ld"),
((LinkerFlavor::Msvc), "msvc"),
((LinkerFlavor::Lld(LldFlavor::Wasm)), "wasm-ld"),
((LinkerFlavor::Lld(LldFlavor::Ld64)), "ld64.lld"),
((LinkerFlavor::Lld(LldFlavor::Ld)), "ld.lld"),
((LinkerFlavor::Lld(LldFlavor::Link)), "lld-link"),
}

#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
pub enum PanicStrategy {
Unwind,
Abort,
}

impl PanicStrategy {
pub fn desc(&self) -> &str {
match *self {
PanicStrategy::Unwind => "unwind",
PanicStrategy::Abort => "abort",
}
}
}

impl ToJson for PanicStrategy {
fn to_json(&self) -> Json {
match *self {
PanicStrategy::Abort => "abort".to_json(),
PanicStrategy::Unwind => "unwind".to_json(),
}
}
}

#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
pub enum RelroLevel {
Full,
Partial,
Off,
None,
}

impl RelroLevel {
pub fn desc(&self) -> &str {
match *self {
RelroLevel::Full => "full",
RelroLevel::Partial => "partial",
RelroLevel::Off => "off",
RelroLevel::None => "none",
}
}
}

impl FromStr for RelroLevel {
type Err = ();

fn from_str(s: &str) -> Result<RelroLevel, ()> {
match s {
"full" => Ok(RelroLevel::Full),
"partial" => Ok(RelroLevel::Partial),
"off" => Ok(RelroLevel::Off),
"none" => Ok(RelroLevel::None),
_ => Err(()),
}
}
}

impl ToJson for RelroLevel {
fn to_json(&self) -> Json {
match *self {
RelroLevel::Full => "full".to_json(),
RelroLevel::Partial => "partial".to_json(),
RelroLevel::Off => "off".to_json(),
RelroLevel::None => "None".to_json(),
}
}
}
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_apple_ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};

pub fn target() -> TargetResult {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
// for target ABI requirements.
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_unknown_cloudabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetResult};
use target::{LinkerFlavor, Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::cloudabi_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::freebsd_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_unknown_fuchsia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::fuchsia_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/aarch64_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/android_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::TargetOptions;
use target::{LinkerFlavor, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/apple_ios_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use std::io;
use std::process::Command;
use target::{LinkArgs, TargetOptions};
use target::{LinkArgs, LinkerFlavor, TargetOptions};

use self::Arch::*;

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/arm_linux_androideabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/arm_unknown_linux_gnueabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/arm_unknown_linux_gnueabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/arm_unknown_linux_musleabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/arm_unknown_linux_musleabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/armv4t_unknown_linux_gnueabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = super::linux_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/armv5te_unknown_linux_gnueabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let base = super::linux_base::opts();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_back/target/armv7_apple_ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetOptions, TargetResult};
use target::{LinkerFlavor, Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};

pub fn target() -> TargetResult {
Expand Down
Loading