Turns out for OSX our data layout was subtly wrong and the LLVM update must have
exposed this. Instead of fixing this I've removed all data layouts from the
compiler to just use the defaults that LLVM provides for all targets. All data
layouts (and a number of dead modules) are removed from the compiler here.
Custom target specifications can still provide a custom data layout, but it is
now an optional key as the default will be used if one isn't specified.
pub mod back {
pub use rustc_back::abi;
- pub use rustc_back::arm;
- pub use rustc_back::mips;
- pub use rustc_back::mipsel;
pub use rustc_back::rpath;
pub use rustc_back::svh;
- pub use rustc_back::target_strs;
- pub use rustc_back::x86;
- pub use rustc_back::x86_64;
}
pub mod ast_map;
+++ /dev/null
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
- let cc_args = if target_triple.contains("thumb") {
- vec!("-mthumb".to_string())
- } else {
- vec!("-marm".to_string())
- };
- return target_strs::t {
- module_asm: "".to_string(),
-
- data_layout: match target_os {
- abi::OsMacos => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsiOS => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsWindows => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsLinux => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsAndroid => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
- },
-
- target_triple: target_triple,
-
- cc_args: cc_args,
- };
-}
pub mod abi;
pub mod tempdir;
-pub mod arm;
-pub mod mips;
-pub mod mipsel;
pub mod rpath;
pub mod sha2;
pub mod svh;
-pub mod target_strs;
-pub mod x86;
-pub mod x86_64;
pub mod target;
+++ /dev/null
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
- return target_strs::t {
- module_asm: "".to_string(),
-
- data_layout: match target_os {
- abi::OsMacos => {
- "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsiOS => {
- "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsWindows => {
- "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsLinux => {
- "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsAndroid => {
- "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsBitrig | abi::OsDragonfly | abi::OsFreebsd | abi::OsNetbsd | abi::OsOpenbsd => {
- "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
- },
-
- target_triple: target_triple,
-
- cc_args: Vec::new(),
- };
-}
+++ /dev/null
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
- return target_strs::t {
- module_asm: "".to_string(),
-
- data_layout: match target_os {
- abi::OsMacos => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsiOS => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsWindows => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsLinux => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsAndroid => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
-
- abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
- "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string()
- }
- },
-
- target_triple: target_triple,
-
- cc_args: Vec::new(),
- };
-}
pub fn target() -> Target {
Target {
- // reference layout: e-m:o-i64:64-i128:128-n32:64-S128
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- i128:128-f32:32:32-f64:64:64-v64:64:64-v128:128:128-\
- a:0:64-n32:64-S128".to_string(),
llvm_target: "arm64-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- n32:64-S128".to_string(),
llvm_target: "aarch64-linux-android".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
pub fn target() -> Target {
let base = super::linux_base::opts();
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- n32:64-S128".to_string(),
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.features = "+v7".to_string();
Target {
- data_layout: "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:64:128-a:0:64-\
- n32".to_string(),
llvm_target: "arm-linux-androideabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
let base = super::linux_base::opts();
Target {
- data_layout: "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string(),
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
let base = super::linux_base::opts();
Target {
- data_layout: "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string(),
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
llvm_target: "armv7-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
llvm_target: "armv7s-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
- -i32:32:32-i64:32:64\
- -f32:32:32-f64:32:64-v64:64:64\
- -v128:128:128-a:0:64-f80:128:128\
- -n8:16:32".to_string(),
llvm_target: "i386-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
base.pre_link_args.push("-m32".to_string());
Target {
- data_layout: "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
- -i32:32:32-i64:32:64\
- -f32:32:32-f64:32:64-v64:64:64\
- -v128:128:128-a:0:64-f80:128:128\
- -n8:16:32".to_string(),
llvm_target: "i686-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
options.pre_link_args.push("-shared-libgcc".to_string());
Target {
- data_layout: "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
base.cpu = "i686".to_string();
Target {
- data_layout: "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
base.pre_link_args.push("-m32".to_string());
Target {
- data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
base.morestack = false;
Target {
- data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
base.pre_link_args.push("-m32".to_string());
Target {
- data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "E-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string(),
llvm_target: "mips-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "e-p:32:32:32\
- -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
- -f32:32:32-f64:64:64\
- -v64:64:64-v128:64:128\
- -a:0:64-n32".to_string(),
llvm_target: "mipsel-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
/// Every field here must be specified, and has no default value.
#[derive(Clone, Debug)]
pub struct Target {
- /// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
- pub data_layout: String,
/// Target triple to pass to LLVM.
pub llvm_target: String,
/// String to use as the `target_endian` `cfg` variable.
/// these try to take "minimal defaults" that don't assume anything about the runtime they run in.
#[derive(Clone, Debug)]
pub struct TargetOptions {
+ /// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
+ pub data_layout: String,
/// Linker to invoke. Defaults to "cc".
pub linker: String,
/// Archive utility to use when managing archives. Defaults to "ar".
/// incomplete, and if used for compilation, will certainly not work.
fn default() -> TargetOptions {
TargetOptions {
+ data_layout: String::new(),
linker: "cc".to_string(),
ar: "ar".to_string(),
pre_link_args: Vec::new(),
};
let mut base = Target {
- data_layout: get_req_field("data-layout"),
llvm_target: get_req_field("llvm-target"),
target_endian: get_req_field("target-endian"),
target_pointer_width: get_req_field("target-pointer-width"),
key!(staticlib_prefix);
key!(staticlib_suffix);
key!(features);
+ key!(data_layout);
key!(dynamic_linking, bool);
key!(executables, bool);
key!(morestack, bool);
base.pre_link_args.push("-m32".to_string());
Target {
- data_layout: "E-S8-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "powerpc-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64".to_string(),
llvm_target: "x86_64-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
pub fn target() -> Target {
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64".to_string(),
llvm_target: "x86_64-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- // FIXME: Test this. Copied from linux (#2398)
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.cpu = "x86-64".to_string();
Target {
- // This is currently in sync with the specification for
- // x86_64-pc-windows-gnu but there's a comment in that file questioning
- // whether this is valid or not. Sounds like the two should stay in sync
- // at least for now.
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-bitrig".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.position_independent_executables = false;
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-linux-musl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
base.pre_link_args.push("-m64".to_string());
Target {
- data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-openbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
+++ /dev/null
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(non_camel_case_types)]
-
-pub struct t {
- pub module_asm: String,
- pub data_layout: String,
- pub target_triple: String,
- pub cc_args: Vec<String> ,
-}
+++ /dev/null
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-use target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os)
- -> target_strs::t {
- return target_strs::t {
- module_asm: "".to_string(),
-
- data_layout: match target_os {
- abi::OsMacos => {
- "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
- -i32:32:32-i64:32:64\
- -f32:32:32-f64:32:64-v64:64:64\
- -v128:128:128-a:0:64-f80:128:128\
- -n8:16:32".to_string()
- }
-
- abi::OsiOS => {
- "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
- -i32:32:32-i64:32:64\
- -f32:32:32-f64:32:64-v64:64:64\
- -v128:128:128-a:0:64-f80:128:128\
- -n8:16:32".to_string()
- }
-
- abi::OsWindows => {
- "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string()
- }
-
- abi::OsLinux => {
- "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
- }
- abi::OsAndroid => {
- "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
- }
-
- abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
- "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
- }
-
- },
-
- target_triple: target_triple,
-
- cc_args: vec!("-m32".to_string()),
- };
-}
+++ /dev/null
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-use target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
- return target_strs::t {
- module_asm: "".to_string(),
-
- data_layout: match target_os {
- abi::OsMacos => {
- "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64".to_string()
- }
-
- abi::OsiOS => {
- "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64".to_string()
- }
-
- abi::OsWindows => {
- // FIXME: Test this. Copied from Linux (#2398)
- "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
- }
-
- abi::OsLinux => {
- "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
- }
- abi::OsAndroid => {
- "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
- }
-
- abi::OsBitrig | abi::OsDragonfly | abi::OsFreebsd | abi::OsNetbsd | abi::OsOpenbsd => {
- "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
- f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
- s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
- }
-
- },
-
- target_triple: target_triple,
-
- cc_args: vec!("-m64".to_string()),
- };
-}
Name: *const c_char,
Child: ArchiveChildRef) -> RustArchiveMemberRef;
pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
+
+ pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
+ TM: TargetMachineRef);
+ pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
}
// LLVM requires symbols from this library, but apparently they're not printed
}
}
-fn create_target_machine(sess: &Session) -> TargetMachineRef {
+pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
let reloc_model_arg = match sess.opts.cg.relocation_model {
Some(ref s) => &s[..],
None => &sess.target.target.options.relocation_model[..],
// Sanity check
assert!(trans.modules.len() == sess.opts.cg.codegen_units);
- unsafe {
- configure_llvm(sess);
- }
-
let tm = create_target_machine(sess);
// Figure out what we actually need to build.
}
}
-unsafe fn configure_llvm(sess: &Session) {
- use std::sync::Once;
- static INIT: Once = Once::new();
-
+pub unsafe fn configure_llvm(sess: &Session) {
let mut llvm_c_strs = Vec::new();
let mut llvm_args = Vec::new();
}
}
- INIT.call_once(|| {
- llvm::LLVMInitializePasses();
-
- // Only initialize the platforms supported by Rust here, because
- // using --llvm-root will have multiple platforms that rustllvm
- // doesn't actually link to and it's pointless to put target info
- // into the registry that Rust cannot generate machine code for.
- llvm::LLVMInitializeX86TargetInfo();
- llvm::LLVMInitializeX86Target();
- llvm::LLVMInitializeX86TargetMC();
- llvm::LLVMInitializeX86AsmPrinter();
- llvm::LLVMInitializeX86AsmParser();
-
- llvm::LLVMInitializeARMTargetInfo();
- llvm::LLVMInitializeARMTarget();
- llvm::LLVMInitializeARMTargetMC();
- llvm::LLVMInitializeARMAsmPrinter();
- llvm::LLVMInitializeARMAsmParser();
-
- llvm::LLVMInitializeAArch64TargetInfo();
- llvm::LLVMInitializeAArch64Target();
- llvm::LLVMInitializeAArch64TargetMC();
- llvm::LLVMInitializeAArch64AsmPrinter();
- llvm::LLVMInitializeAArch64AsmParser();
-
- llvm::LLVMInitializeMipsTargetInfo();
- llvm::LLVMInitializeMipsTarget();
- llvm::LLVMInitializeMipsTargetMC();
- llvm::LLVMInitializeMipsAsmPrinter();
- llvm::LLVMInitializeMipsAsmParser();
-
- llvm::LLVMInitializePowerPCTargetInfo();
- llvm::LLVMInitializePowerPCTarget();
- llvm::LLVMInitializePowerPCTargetMC();
- llvm::LLVMInitializePowerPCAsmPrinter();
- llvm::LLVMInitializePowerPCAsmParser();
-
- llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
- llvm_args.as_ptr());
- });
+ llvm::LLVMInitializePasses();
+
+ // Only initialize the platforms supported by Rust here, because
+ // using --llvm-root will have multiple platforms that rustllvm
+ // doesn't actually link to and it's pointless to put target info
+ // into the registry that Rust cannot generate machine code for.
+ llvm::LLVMInitializeX86TargetInfo();
+ llvm::LLVMInitializeX86Target();
+ llvm::LLVMInitializeX86TargetMC();
+ llvm::LLVMInitializeX86AsmPrinter();
+ llvm::LLVMInitializeX86AsmParser();
+
+ llvm::LLVMInitializeARMTargetInfo();
+ llvm::LLVMInitializeARMTarget();
+ llvm::LLVMInitializeARMTargetMC();
+ llvm::LLVMInitializeARMAsmPrinter();
+ llvm::LLVMInitializeARMAsmParser();
+
+ llvm::LLVMInitializeAArch64TargetInfo();
+ llvm::LLVMInitializeAArch64Target();
+ llvm::LLVMInitializeAArch64TargetMC();
+ llvm::LLVMInitializeAArch64AsmPrinter();
+ llvm::LLVMInitializeAArch64AsmParser();
+
+ llvm::LLVMInitializeMipsTargetInfo();
+ llvm::LLVMInitializeMipsTarget();
+ llvm::LLVMInitializeMipsTargetMC();
+ llvm::LLVMInitializeMipsAsmPrinter();
+ llvm::LLVMInitializeMipsAsmParser();
+
+ llvm::LLVMInitializePowerPCTargetInfo();
+ llvm::LLVMInitializePowerPCTarget();
+ llvm::LLVMInitializePowerPCTargetMC();
+ llvm::LLVMInitializePowerPCAsmPrinter();
+ llvm::LLVMInitializePowerPCAsmParser();
+
+ llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
+ llvm_args.as_ptr());
}
unsafe fn populate_llvm_passes(fpm: llvm::PassManagerRef,
pub mod back {
pub use rustc_back::abi;
- pub use rustc_back::arm;
- pub use rustc_back::mips;
- pub use rustc_back::mipsel;
pub use rustc_back::rpath;
pub use rustc_back::svh;
- pub use rustc_back::target_strs;
- pub use rustc_back::x86;
- pub use rustc_back::x86_64;
pub mod archive;
pub mod linker;
// cannot proceed despite the Once not running more than once.
POISONED = true;
}
+
+ ::back::write::configure_llvm(&tcx.sess);
});
if POISONED {
use llvm;
use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef};
-use llvm::TargetData;
-use llvm::mk_target_data;
use metadata::common::LinkMeta;
use middle::def::ExportMap;
use middle::traits;
pub struct LocalCrateContext<'tcx> {
llmod: ModuleRef,
llcx: ContextRef,
- td: TargetData,
tn: TypeNames,
externs: RefCell<ExternMap>,
item_vals: RefCell<NodeMap<ValueRef>>,
let mod_name = CString::new(mod_name).unwrap();
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
- let data_layout = sess.target.target.data_layout.as_bytes();
- let data_layout = CString::new(data_layout).unwrap();
- llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
+ let custom_data_layout = &sess.target.target.options.data_layout[..];
+ if custom_data_layout.len() > 0 {
+ let data_layout = CString::new(custom_data_layout).unwrap();
+ llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
+ } else {
+ let tm = ::back::write::create_target_machine(sess);
+ llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
+ llvm::LLVMRustDisposeTargetMachine(tm);
+ }
let llvm_target = sess.target.target.llvm_target.as_bytes();
let llvm_target = CString::new(llvm_target).unwrap();
unsafe {
let (llcx, llmod) = create_context_and_module(&shared.tcx.sess, name);
- let td = mk_target_data(&shared.tcx
- .sess
- .target
- .target
- .data_layout
- );
-
let dbg_cx = if shared.tcx.sess.opts.debuginfo != NoDebugInfo {
Some(debuginfo::CrateDebugContext::new(llmod))
} else {
let mut local_ccx = LocalCrateContext {
llmod: llmod,
llcx: llcx,
- td: td,
tn: TypeNames::new(),
externs: RefCell::new(FnvHashMap()),
item_vals: RefCell::new(NodeMap()),
self.local.llcx
}
- pub fn td<'a>(&'a self) -> &'a TargetData {
- &self.local.td
+ pub fn td(&self) -> llvm::TargetDataRef {
+ unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) }
}
pub fn tn<'a>(&'a self) -> &'a TypeNames {
// Returns the number of bytes clobbered by a Store to this type.
pub fn llsize_of_store(cx: &CrateContext, ty: Type) -> llsize {
unsafe {
- return llvm::LLVMStoreSizeOfType(cx.td().lltd, ty.to_ref());
+ return llvm::LLVMStoreSizeOfType(cx.td(), ty.to_ref());
}
}
// array of T. This is the "ABI" size. It includes any ABI-mandated padding.
pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> llsize {
unsafe {
- return llvm::LLVMABISizeOfType(cx.td().lltd, ty.to_ref());
+ return llvm::LLVMABISizeOfType(cx.td(), ty.to_ref());
}
}
// below.
pub fn llsize_of_real(cx: &CrateContext, ty: Type) -> llsize {
unsafe {
- let nbits = llvm::LLVMSizeOfTypeInBits(cx.td().lltd, ty.to_ref());
+ let nbits = llvm::LLVMSizeOfTypeInBits(cx.td(), ty.to_ref());
if nbits & 7 != 0 {
// Not an even number of bytes, spills into "next" byte.
1 + (nbits >> 3)
/// Returns the "real" size of the type in bits.
pub fn llbitsize_of_real(cx: &CrateContext, ty: Type) -> llbits {
unsafe {
- llvm::LLVMSizeOfTypeInBits(cx.td().lltd, ty.to_ref())
+ llvm::LLVMSizeOfTypeInBits(cx.td(), ty.to_ref())
}
}
// allocations inside a stack frame, which LLVM has a free hand in.
pub fn llalign_of_pref(cx: &CrateContext, ty: Type) -> llalign {
unsafe {
- return llvm::LLVMPreferredAlignmentOfType(cx.td().lltd, ty.to_ref());
+ return llvm::LLVMPreferredAlignmentOfType(cx.td(), ty.to_ref());
}
}
// and similar ABI-mandated things.
pub fn llalign_of_min(cx: &CrateContext, ty: Type) -> llalign {
unsafe {
- return llvm::LLVMABIAlignmentOfType(cx.td().lltd, ty.to_ref());
+ return llvm::LLVMABIAlignmentOfType(cx.td(), ty.to_ref());
}
}
pub fn llelement_offset(cx: &CrateContext, struct_ty: Type, element: usize) -> u64 {
unsafe {
- return llvm::LLVMOffsetOfElement(cx.td().lltd,
+ return llvm::LLVMOffsetOfElement(cx.td(),
struct_ty.to_ref(),
element as u32);
}
#else
#include "llvm/Target/TargetLibraryInfo.h"
#endif
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetSubtargetInfo.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
}
}
}
+
+extern "C" void
+LLVMRustSetDataLayoutFromTargetMachine(LLVMModuleRef Module,
+ LLVMTargetMachineRef TMR) {
+ TargetMachine *Target = unwrap(TMR);
+#if LLVM_VERSION_MINOR >= 7
+ if (const DataLayout *DL = Target->getDataLayout())
+ unwrap(Module)->setDataLayout(*DL);
+#elif LLVM_VERSION_MINOR >= 6
+ if (const DataLayout *DL = Target->getSubtargetImpl()->getDataLayout())
+ unwrap(Module)->setDataLayout(DL);
+#else
+ if (const DataLayout *DL = Target->getDataLayout())
+ unwrap(Module)->setDataLayout(DL);
+#endif
+}
+
+extern "C" LLVMTargetDataRef
+LLVMRustGetModuleDataLayout(LLVMModuleRef M) {
+#if LLVM_VERSION_MINOR >= 7
+ return wrap(&unwrap(M)->getDataLayout());
+#else
+ return wrap(unwrap(M)->getDataLayout());
+#endif
+}