Make data-layout mandatory in target specs.
This commit is contained in:
parent
e8c0aeb88b
commit
0776399eac
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "arm64-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -15,6 +15,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "aarch64-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -17,6 +17,7 @@ pub fn target() -> Target {
|
|||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
data_layout: "e-m:e-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "arm-linux-androideabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnueabi".to_string(),
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnueabihf".to_string(),
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "armv7-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnueabihf".to_string(),
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "armv7s-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -31,6 +31,7 @@ pub fn target() -> Target {
|
|||
target_os: "emscripten".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(),
|
||||
arch: "asmjs".to_string(),
|
||||
options: opts,
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i386-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-apple-darwin".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "macos".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-pc-windows-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -27,6 +27,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-pc-windows-msvc".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
target_env: "msvc".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-unknown-dragonfly".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "dragonfly".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-unknown-freebsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "freebsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -37,6 +37,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "i686-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "musl".to_string(),
|
||||
|
|
|
@ -34,6 +34,7 @@ pub fn target() -> Target {
|
|||
target_os: "nacl".to_string(),
|
||||
target_env: "newlib".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
data_layout: "e-i64:64:64-p:32:32:32-v128:32:32".to_string(),
|
||||
arch: "le32".to_string(),
|
||||
options: opts,
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "mips-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -15,6 +15,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "mips-unknown-linux-musl".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "musl".to_string(),
|
||||
|
|
|
@ -15,6 +15,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "mipsel-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -15,6 +15,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "mipsel-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "musl".to_string(),
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
//! this module defines the format the JSON file should take, though each
|
||||
//! underscore in the field names should be replaced with a hyphen (`-`) in the
|
||||
//! JSON file. Some fields are required in every target specification, such as
|
||||
//! `llvm-target`, `target-endian`, `target-pointer-width`, `arch`, and
|
||||
//! `os`. In general, options passed to rustc with `-C` override the target's
|
||||
//! settings, though `target-feature` and `link-args` will *add* to the list
|
||||
//! specified by the target, rather than replace.
|
||||
//! `llvm-target`, `target-endian`, `target-pointer-width`, `data-layout`,
|
||||
//! `arch`, and `os`. In general, options passed to rustc with `-C` override
|
||||
//! the target's settings, though `target-feature` and `link-args` will *add*
|
||||
//! to the list specified by the target, rather than replace.
|
||||
|
||||
use serialize::json::Json;
|
||||
use std::default::Default;
|
||||
|
@ -75,7 +75,8 @@ macro_rules! supported_targets {
|
|||
if false { }
|
||||
$(
|
||||
else if target == stringify!($module) {
|
||||
let t = $module::target();
|
||||
let mut t = $module::target();
|
||||
t.options.is_builtin = true;
|
||||
debug!("Got builtin target: {:?}", t);
|
||||
return Some(t);
|
||||
}
|
||||
|
@ -161,6 +162,8 @@ pub struct Target {
|
|||
/// Architecture to use for ABI considerations. Valid options: "x86",
|
||||
/// "x86_64", "arm", "aarch64", "mips", "powerpc", and "powerpc64".
|
||||
pub arch: String,
|
||||
/// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
|
||||
pub data_layout: String,
|
||||
/// Optional settings with defaults.
|
||||
pub options: TargetOptions,
|
||||
}
|
||||
|
@ -171,8 +174,9 @@ pub struct Target {
|
|||
/// 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: Option<String>,
|
||||
/// Whether the target is built-in or loaded from a custom target specification.
|
||||
pub is_builtin: bool,
|
||||
|
||||
/// Linker to invoke. Defaults to "cc".
|
||||
pub linker: String,
|
||||
/// Archive utility to use when managing archives. Defaults to "ar".
|
||||
|
@ -293,7 +297,7 @@ impl Default for TargetOptions {
|
|||
/// incomplete, and if used for compilation, will certainly not work.
|
||||
fn default() -> TargetOptions {
|
||||
TargetOptions {
|
||||
data_layout: None,
|
||||
is_builtin: false,
|
||||
linker: option_env!("CFG_DEFAULT_LINKER").unwrap_or("cc").to_string(),
|
||||
ar: option_env!("CFG_DEFAULT_AR").unwrap_or("ar").to_string(),
|
||||
pre_link_args: Vec::new(),
|
||||
|
@ -378,6 +382,7 @@ impl Target {
|
|||
llvm_target: get_req_field("llvm-target"),
|
||||
target_endian: get_req_field("target-endian"),
|
||||
target_pointer_width: get_req_field("target-pointer-width"),
|
||||
data_layout: get_req_field("data-layout"),
|
||||
arch: get_req_field("arch"),
|
||||
target_os: get_req_field("os"),
|
||||
target_env: get_opt_field("env", ""),
|
||||
|
@ -426,7 +431,6 @@ impl Target {
|
|||
key!(staticlib_prefix);
|
||||
key!(staticlib_suffix);
|
||||
key!(features);
|
||||
key!(data_layout, optional);
|
||||
key!(dynamic_linking, bool);
|
||||
key!(executables, bool);
|
||||
key!(disable_redzone, bool);
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "E-m:e-i64:64-n32:64".to_string(),
|
||||
arch: "powerpc64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-n32:64".to_string(),
|
||||
arch: "powerpc64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "powerpc-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
|
||||
arch: "powerpc".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -20,6 +20,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-apple-darwin".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "macos".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-pc-windows-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
target_env: "msvc".to_string(),
|
||||
|
|
|
@ -27,6 +27,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-rumprun-netbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "netbsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-pc-solaris".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "solaris".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-bitrig".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "bitrig".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-dragonfly".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "dragonfly".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-freebsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "freebsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
|
|
@ -73,6 +73,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "musl".to_string(),
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-netbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "netbsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "x86_64-unknown-openbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "openbsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
|
|
|
@ -36,11 +36,12 @@ use session::Session;
|
|||
use util::sha2::Sha256;
|
||||
use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap, FnvHashSet};
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::marker::PhantomData;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
|
||||
|
@ -255,15 +256,28 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
|
|||
let mod_name = CString::new(mod_name).unwrap();
|
||||
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
|
||||
|
||||
if let Some(ref custom_data_layout) = sess.target.target.options.data_layout {
|
||||
let data_layout = CString::new(&custom_data_layout[..]).unwrap();
|
||||
llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
|
||||
} else {
|
||||
// Ensure the data-layout values hardcoded remain the defaults.
|
||||
if sess.target.target.options.is_builtin {
|
||||
let tm = ::back::write::create_target_machine(sess);
|
||||
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
|
||||
llvm::LLVMRustDisposeTargetMachine(tm);
|
||||
|
||||
let data_layout = llvm::LLVMGetDataLayout(llmod);
|
||||
let data_layout = str::from_utf8(CStr::from_ptr(data_layout).to_bytes())
|
||||
.ok().expect("got a non-UTF8 data-layout from LLVM");
|
||||
|
||||
if sess.target.target.data_layout != data_layout {
|
||||
bug!("data-layout for builtin `{}` target, `{}`, \
|
||||
differs from LLVM default, `{}`",
|
||||
sess.target.target.llvm_target,
|
||||
sess.target.target.data_layout,
|
||||
data_layout);
|
||||
}
|
||||
}
|
||||
|
||||
let data_layout = CString::new(&sess.target.target.data_layout[..]).unwrap();
|
||||
llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
|
||||
|
||||
let llvm_target = sess.target.target.llvm_target.as_bytes();
|
||||
let llvm_target = CString::new(llvm_target).unwrap();
|
||||
llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128",
|
||||
"llvm-target": "i686-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
|
|
Loading…
Reference in New Issue