diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index f1984708b663a..7d50e6f6917cc 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -99,14 +99,8 @@ pub mod diagnostics; 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; diff --git a/src/librustc_back/arm.rs b/src/librustc_back/arm.rs deleted file mode 100644 index 9e288f6ddb2bf..0000000000000 --- a/src/librustc_back/arm.rs +++ /dev/null @@ -1,77 +0,0 @@ -// 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 or the MIT license -// , 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, - }; -} diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index ef5ba625e114b..ecba37c23153d 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -52,13 +52,7 @@ extern crate rustc_llvm; 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; diff --git a/src/librustc_back/mips.rs b/src/librustc_back/mips.rs deleted file mode 100644 index e1edff817d6c1..0000000000000 --- a/src/librustc_back/mips.rs +++ /dev/null @@ -1,72 +0,0 @@ -// 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 or the MIT license -// , 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(), - }; -} diff --git a/src/librustc_back/mipsel.rs b/src/librustc_back/mipsel.rs deleted file mode 100644 index ca52a9e56ff52..0000000000000 --- a/src/librustc_back/mipsel.rs +++ /dev/null @@ -1,72 +0,0 @@ -// 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 or the MIT license -// , 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(), - }; -} diff --git a/src/librustc_back/target/aarch64_apple_ios.rs b/src/librustc_back/target/aarch64_apple_ios.rs index dd6bc672a03d9..e87cb43128d24 100644 --- a/src/librustc_back/target/aarch64_apple_ios.rs +++ b/src/librustc_back/target/aarch64_apple_ios.rs @@ -13,10 +13,6 @@ use super::apple_ios_base::{opts, Arch}; 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(), diff --git a/src/librustc_back/target/aarch64_linux_android.rs b/src/librustc_back/target/aarch64_linux_android.rs index 67194e7ac5c7c..8c350e8b28750 100644 --- a/src/librustc_back/target/aarch64_linux_android.rs +++ b/src/librustc_back/target/aarch64_linux_android.rs @@ -12,9 +12,6 @@ use target::Target; 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(), diff --git a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs index 18e67d066d036..ed79caf486942 100644 --- a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs @@ -13,9 +13,6 @@ use target::Target; 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(), diff --git a/src/librustc_back/target/apple_base.rs b/src/librustc_back/target/apple_base.rs index 795a2c18bc6e6..f34ba40a8b2fe 100644 --- a/src/librustc_back/target/apple_base.rs +++ b/src/librustc_back/target/apple_base.rs @@ -23,6 +23,7 @@ pub fn opts() -> TargetOptions { has_rpath: true, dll_prefix: "lib".to_string(), dll_suffix: ".dylib".to_string(), + archive_format: "bsd".to_string(), pre_link_args: Vec::new(), .. Default::default() } diff --git a/src/librustc_back/target/arm_linux_androideabi.rs b/src/librustc_back/target/arm_linux_androideabi.rs index cbaa2b205b055..0770fe70e8a57 100644 --- a/src/librustc_back/target/arm_linux_androideabi.rs +++ b/src/librustc_back/target/arm_linux_androideabi.rs @@ -15,9 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/arm_unknown_linux_gnueabi.rs b/src/librustc_back/target/arm_unknown_linux_gnueabi.rs index 30015c4a7e6ff..084f989277f31 100644 --- a/src/librustc_back/target/arm_unknown_linux_gnueabi.rs +++ b/src/librustc_back/target/arm_unknown_linux_gnueabi.rs @@ -13,11 +13,6 @@ use target::{Target, TargetOptions}; 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(), diff --git a/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs b/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs index 8f8c7114e6eff..08f1aa5ade848 100644 --- a/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs +++ b/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs @@ -13,11 +13,6 @@ use target::{Target, TargetOptions}; 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(), diff --git a/src/librustc_back/target/armv7_apple_ios.rs b/src/librustc_back/target/armv7_apple_ios.rs index 3b55993659de2..a6d649ea162f9 100644 --- a/src/librustc_back/target/armv7_apple_ios.rs +++ b/src/librustc_back/target/armv7_apple_ios.rs @@ -13,7 +13,6 @@ use super::apple_ios_base::{opts, Arch}; 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(), diff --git a/src/librustc_back/target/armv7s_apple_ios.rs b/src/librustc_back/target/armv7s_apple_ios.rs index 5a67e3fe127d6..264385512adde 100644 --- a/src/librustc_back/target/armv7s_apple_ios.rs +++ b/src/librustc_back/target/armv7s_apple_ios.rs @@ -13,7 +13,6 @@ use super::apple_ios_base::{opts, Arch}; 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(), diff --git a/src/librustc_back/target/bitrig_base.rs b/src/librustc_back/target/bitrig_base.rs index 6e5a48c0ea16c..9f6a1f1e53007 100644 --- a/src/librustc_back/target/bitrig_base.rs +++ b/src/librustc_back/target/bitrig_base.rs @@ -22,6 +22,7 @@ pub fn opts() -> TargetOptions { position_independent_executables: true, pre_link_args: vec!( ), + archive_format: "bsd".to_string(), .. Default::default() } diff --git a/src/librustc_back/target/dragonfly_base.rs b/src/librustc_back/target/dragonfly_base.rs index a56621ff97ea5..51a371db72446 100644 --- a/src/librustc_back/target/dragonfly_base.rs +++ b/src/librustc_back/target/dragonfly_base.rs @@ -29,6 +29,7 @@ pub fn opts() -> TargetOptions { "-Wl,--as-needed".to_string(), ), position_independent_executables: true, + archive_format: "bsd".to_string(), .. Default::default() } } diff --git a/src/librustc_back/target/freebsd_base.rs b/src/librustc_back/target/freebsd_base.rs index 3ec6307c72f86..2c3d240dbf3d5 100644 --- a/src/librustc_back/target/freebsd_base.rs +++ b/src/librustc_back/target/freebsd_base.rs @@ -18,6 +18,7 @@ pub fn opts() -> TargetOptions { executables: true, morestack: true, has_rpath: true, + archive_format: "bsd".to_string(), .. Default::default() } diff --git a/src/librustc_back/target/i386_apple_ios.rs b/src/librustc_back/target/i386_apple_ios.rs index a9a073e2a8c64..d17aa915461df 100644 --- a/src/librustc_back/target/i386_apple_ios.rs +++ b/src/librustc_back/target/i386_apple_ios.rs @@ -13,11 +13,6 @@ use super::apple_ios_base::{opts, Arch}; 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(), diff --git a/src/librustc_back/target/i686_apple_darwin.rs b/src/librustc_back/target/i686_apple_darwin.rs index 47b329982d43e..9fe15e7694286 100644 --- a/src/librustc_back/target/i686_apple_darwin.rs +++ b/src/librustc_back/target/i686_apple_darwin.rs @@ -16,11 +16,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/i686_pc_windows_gnu.rs b/src/librustc_back/target/i686_pc_windows_gnu.rs index 9e2aa20085c36..ae1b4d450a58e 100644 --- a/src/librustc_back/target/i686_pc_windows_gnu.rs +++ b/src/librustc_back/target/i686_pc_windows_gnu.rs @@ -24,7 +24,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/i686_pc_windows_msvc.rs b/src/librustc_back/target/i686_pc_windows_msvc.rs index d71aa1526660e..f2ae799bd2438 100644 --- a/src/librustc_back/target/i686_pc_windows_msvc.rs +++ b/src/librustc_back/target/i686_pc_windows_msvc.rs @@ -15,7 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/i686_unknown_dragonfly.rs b/src/librustc_back/target/i686_unknown_dragonfly.rs index ecabe71ad4c6c..f2478e6d0dbfe 100644 --- a/src/librustc_back/target/i686_unknown_dragonfly.rs +++ b/src/librustc_back/target/i686_unknown_dragonfly.rs @@ -16,7 +16,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/i686_unknown_freebsd.rs b/src/librustc_back/target/i686_unknown_freebsd.rs index d3477402cefb7..68fee41e2cfa5 100644 --- a/src/librustc_back/target/i686_unknown_freebsd.rs +++ b/src/librustc_back/target/i686_unknown_freebsd.rs @@ -17,7 +17,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/i686_unknown_linux_gnu.rs b/src/librustc_back/target/i686_unknown_linux_gnu.rs index 21094ad905e90..074d5b2b9ed22 100644 --- a/src/librustc_back/target/i686_unknown_linux_gnu.rs +++ b/src/librustc_back/target/i686_unknown_linux_gnu.rs @@ -16,7 +16,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/mips_unknown_linux_gnu.rs b/src/librustc_back/target/mips_unknown_linux_gnu.rs index 4662ff1958ba8..3f3da6d6c9136 100644 --- a/src/librustc_back/target/mips_unknown_linux_gnu.rs +++ b/src/librustc_back/target/mips_unknown_linux_gnu.rs @@ -12,11 +12,6 @@ use target::Target; 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(), diff --git a/src/librustc_back/target/mipsel_unknown_linux_gnu.rs b/src/librustc_back/target/mipsel_unknown_linux_gnu.rs index 80e38c5ddea98..d7f286c8aa408 100644 --- a/src/librustc_back/target/mipsel_unknown_linux_gnu.rs +++ b/src/librustc_back/target/mipsel_unknown_linux_gnu.rs @@ -12,11 +12,6 @@ use target::Target; 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(), diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 185d1c9428e86..39e42913ff674 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -67,8 +67,6 @@ mod windows_msvc_base; /// 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. @@ -92,6 +90,8 @@ 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: String, /// Linker to invoke. Defaults to "cc". pub linker: String, /// Archive utility to use when managing archives. Defaults to "ar". @@ -178,6 +178,7 @@ impl Default for TargetOptions { /// 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(), @@ -245,7 +246,6 @@ impl Target { }; 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"), @@ -289,6 +289,7 @@ impl Target { key!(staticlib_prefix); key!(staticlib_suffix); key!(features); + key!(data_layout); key!(dynamic_linking, bool); key!(executables, bool); key!(morestack, bool); diff --git a/src/librustc_back/target/netbsd_base.rs b/src/librustc_back/target/netbsd_base.rs index 0f2ab32be2431..9b20bd927cb7a 100644 --- a/src/librustc_back/target/netbsd_base.rs +++ b/src/librustc_back/target/netbsd_base.rs @@ -27,6 +27,7 @@ pub fn opts() -> TargetOptions { "-Wl,--as-needed".to_string(), ), position_independent_executables: true, + archive_format: "bsd".to_string(), .. Default::default() } } diff --git a/src/librustc_back/target/openbsd_base.rs b/src/librustc_back/target/openbsd_base.rs index 0f2ab32be2431..9b20bd927cb7a 100644 --- a/src/librustc_back/target/openbsd_base.rs +++ b/src/librustc_back/target/openbsd_base.rs @@ -27,6 +27,7 @@ pub fn opts() -> TargetOptions { "-Wl,--as-needed".to_string(), ), position_independent_executables: true, + archive_format: "bsd".to_string(), .. Default::default() } } diff --git a/src/librustc_back/target/powerpc_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc_unknown_linux_gnu.rs index 3a2b4bd16065e..896824eba0e56 100644 --- a/src/librustc_back/target/powerpc_unknown_linux_gnu.rs +++ b/src/librustc_back/target/powerpc_unknown_linux_gnu.rs @@ -15,7 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_apple_darwin.rs b/src/librustc_back/target/x86_64_apple_darwin.rs index 89a67da2d8bbc..ef40c2f2006e1 100644 --- a/src/librustc_back/target/x86_64_apple_darwin.rs +++ b/src/librustc_back/target/x86_64_apple_darwin.rs @@ -17,9 +17,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_apple_ios.rs b/src/librustc_back/target/x86_64_apple_ios.rs index 74491629ed859..7aca8c554dab6 100644 --- a/src/librustc_back/target/x86_64_apple_ios.rs +++ b/src/librustc_back/target/x86_64_apple_ios.rs @@ -13,9 +13,6 @@ use super::apple_ios_base::{opts, Arch}; 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(), diff --git a/src/librustc_back/target/x86_64_pc_windows_gnu.rs b/src/librustc_back/target/x86_64_pc_windows_gnu.rs index bea7d16e9dfad..e4d7b4bc9b024 100644 --- a/src/librustc_back/target/x86_64_pc_windows_gnu.rs +++ b/src/librustc_back/target/x86_64_pc_windows_gnu.rs @@ -18,10 +18,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_pc_windows_msvc.rs b/src/librustc_back/target/x86_64_pc_windows_msvc.rs index f7c3ca4b3f6ed..addaaeb1b636d 100644 --- a/src/librustc_back/target/x86_64_pc_windows_msvc.rs +++ b/src/librustc_back/target/x86_64_pc_windows_msvc.rs @@ -15,13 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_bitrig.rs b/src/librustc_back/target/x86_64_unknown_bitrig.rs index 201c56b2e15c6..6ecf885aba38e 100644 --- a/src/librustc_back/target/x86_64_unknown_bitrig.rs +++ b/src/librustc_back/target/x86_64_unknown_bitrig.rs @@ -15,9 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_dragonfly.rs b/src/librustc_back/target/x86_64_unknown_dragonfly.rs index c590f0297b948..f0e665967ec6f 100644 --- a/src/librustc_back/target/x86_64_unknown_dragonfly.rs +++ b/src/librustc_back/target/x86_64_unknown_dragonfly.rs @@ -16,9 +16,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_freebsd.rs b/src/librustc_back/target/x86_64_unknown_freebsd.rs index 0d8ea90a2ab04..f742ebfde1d2c 100644 --- a/src/librustc_back/target/x86_64_unknown_freebsd.rs +++ b/src/librustc_back/target/x86_64_unknown_freebsd.rs @@ -16,9 +16,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs index ba945afc5649b..4749e481fd855 100644 --- a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs @@ -16,9 +16,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_linux_musl.rs b/src/librustc_back/target/x86_64_unknown_linux_musl.rs index 3debad2e8f201..c66192c28b13d 100644 --- a/src/librustc_back/target/x86_64_unknown_linux_musl.rs +++ b/src/librustc_back/target/x86_64_unknown_linux_musl.rs @@ -70,9 +70,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_netbsd.rs b/src/librustc_back/target/x86_64_unknown_netbsd.rs index 3f5bd39949ab6..e13e58e3a186d 100644 --- a/src/librustc_back/target/x86_64_unknown_netbsd.rs +++ b/src/librustc_back/target/x86_64_unknown_netbsd.rs @@ -15,9 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target/x86_64_unknown_openbsd.rs b/src/librustc_back/target/x86_64_unknown_openbsd.rs index 7f64259adf9f8..a404db48b22bb 100644 --- a/src/librustc_back/target/x86_64_unknown_openbsd.rs +++ b/src/librustc_back/target/x86_64_unknown_openbsd.rs @@ -15,9 +15,6 @@ pub fn target() -> Target { 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(), diff --git a/src/librustc_back/target_strs.rs b/src/librustc_back/target_strs.rs deleted file mode 100644 index 7928f3d8db098..0000000000000 --- a/src/librustc_back/target_strs.rs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , 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 , -} diff --git a/src/librustc_back/x86.rs b/src/librustc_back/x86.rs deleted file mode 100644 index 46e0a83ac033b..0000000000000 --- a/src/librustc_back/x86.rs +++ /dev/null @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , 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()), - }; -} diff --git a/src/librustc_back/x86_64.rs b/src/librustc_back/x86_64.rs deleted file mode 100644 index abdcd56444213..0000000000000 --- a/src/librustc_back/x86_64.rs +++ /dev/null @@ -1,62 +0,0 @@ -// 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 or the MIT license -// , 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()), - }; -} diff --git a/src/librustc_llvm/archive_ro.rs b/src/librustc_llvm/archive_ro.rs index 2c6022bc61495..85c0c721114f5 100644 --- a/src/librustc_llvm/archive_ro.rs +++ b/src/librustc_llvm/archive_ro.rs @@ -118,6 +118,9 @@ impl<'a> Child<'a> { unsafe { let mut data_len = 0; let data_ptr = ::LLVMRustArchiveChildData(self.ptr, &mut data_len); + if data_ptr.is_null() { + panic!("failed to read data from archive child"); + } slice::from_raw_parts(data_ptr as *const u8, data_len as usize) } } diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 7afcb54cce436..7734704b021a8 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -452,6 +452,15 @@ pub enum DiagnosticKind { DK_OptimizationFailure, } +#[repr(C)] +#[derive(Copy, Clone)] +pub enum ArchiveKind { + K_GNU, + K_MIPS64, + K_BSD, + K_COFF, +} + // Opaque pointer types #[allow(missing_copy_implementations)] pub enum Module_opaque {} @@ -1136,12 +1145,13 @@ extern { Catch: BasicBlockRef, Name: *const c_char) -> ValueRef; - pub fn LLVMBuildLandingPad(B: BuilderRef, - Ty: TypeRef, - PersFn: ValueRef, - NumClauses: c_uint, - Name: *const c_char) - -> ValueRef; + pub fn LLVMRustBuildLandingPad(B: BuilderRef, + Ty: TypeRef, + PersFn: ValueRef, + NumClauses: c_uint, + Name: *const c_char, + F: ValueRef) + -> ValueRef; pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef; pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef; @@ -2118,11 +2128,16 @@ extern { pub fn LLVMRustWriteArchive(Dst: *const c_char, NumMembers: size_t, Members: *const RustArchiveMemberRef, - WriteSymbtab: bool) -> c_int; + WriteSymbtab: bool, + Kind: ArchiveKind) -> c_int; pub fn LLVMRustArchiveMemberNew(Filename: *const c_char, 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 diff --git a/src/librustc_trans/back/archive.rs b/src/librustc_trans/back/archive.rs index cc3d1d842fad0..02f4bc83b7524 100644 --- a/src/librustc_trans/back/archive.rs +++ b/src/librustc_trans/back/archive.rs @@ -22,7 +22,7 @@ use std::str; use libc; use llvm::archive_ro::{ArchiveRO, Child}; -use llvm; +use llvm::{self, ArchiveKind}; use rustc::metadata::loader::METADATA_FILENAME; use rustc::session::Session; use rustc_back::tempdir::TempDir; @@ -208,28 +208,34 @@ impl<'a> ArchiveBuilder<'a> { /// Combine the provided files, rlibs, and native libraries into a single /// `Archive`. pub fn build(&mut self) { - let res = if self.using_llvm() { - self.build_with_llvm() - } else { - self.build_with_ar_cmd() + let res = match self.llvm_archive_kind() { + Some(kind) => self.build_with_llvm(kind), + None => self.build_with_ar_cmd(), }; if let Err(e) = res { self.config.sess.fatal(&format!("failed to build archive: {}", e)); } } - pub fn using_llvm(&self) -> bool { + pub fn llvm_archive_kind(&self) -> Option { if unsafe { llvm::LLVMVersionMinor() < 7 } { - return false + return None } // Currently LLVM only supports writing archives in the 'gnu' format. match &self.config.sess.target.target.options.archive_format[..] { - "gnu" => true, - _ => false, + "gnu" => Some(ArchiveKind::K_GNU), + "mips64" => Some(ArchiveKind::K_MIPS64), + "bsd" => Some(ArchiveKind::K_BSD), + "coff" => Some(ArchiveKind::K_COFF), + _ => None, } } + pub fn using_llvm(&self) -> bool { + self.llvm_archive_kind().is_some() + } + fn build_with_ar_cmd(&mut self) -> io::Result<()> { let removals = mem::replace(&mut self.removals, Vec::new()); let additions = mem::replace(&mut self.additions, Vec::new()); @@ -425,7 +431,7 @@ impl<'a> ArchiveBuilder<'a> { } } - fn build_with_llvm(&mut self) -> io::Result<()> { + fn build_with_llvm(&mut self, kind: ArchiveKind) -> io::Result<()> { let mut archives = Vec::new(); let mut strings = Vec::new(); let mut members = Vec::new(); @@ -482,7 +488,8 @@ impl<'a> ArchiveBuilder<'a> { let r = llvm::LLVMRustWriteArchive(dst.as_ptr(), members.len() as libc::size_t, members.as_ptr(), - self.should_update_symbols); + self.should_update_symbols, + kind); let ret = if r != 0 { let err = llvm::LLVMRustGetLastError(); let msg = if err.is_null() { diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 0a9db8a651e65..1f97a9b93edf5 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -163,7 +163,7 @@ fn get_llvm_opt_level(optimize: config::OptLevel) -> llvm::CodeGenOptLevel { } } -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[..], @@ -591,10 +591,6 @@ pub fn run_passes(sess: &Session, // 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. @@ -943,10 +939,7 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) { } } -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(); @@ -968,46 +961,44 @@ unsafe fn configure_llvm(sess: &Session) { } } - 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, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 0e425e1fd9910..af894b218eff8 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -68,14 +68,8 @@ pub use rustc::util; 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; diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index edb61b0d3cf38..4aeba2fe06287 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2666,6 +2666,8 @@ pub fn trans_crate(tcx: &ty::ctxt, analysis: ty::CrateAnalysis) -> CrateTranslat // cannot proceed despite the Once not running more than once. POISONED = true; } + + ::back::write::configure_llvm(&tcx.sess); }); if POISONED { diff --git a/src/librustc_trans/trans/build.rs b/src/librustc_trans/trans/build.rs index 7d68250404423..3e4452a23b9f7 100644 --- a/src/librustc_trans/trans/build.rs +++ b/src/librustc_trans/trans/build.rs @@ -1039,7 +1039,7 @@ pub fn LandingPad(cx: Block, ty: Type, pers_fn: ValueRef, num_clauses: usize) -> ValueRef { check_not_terminated(cx); assert!(!cx.unreachable.get()); - B(cx).landing_pad(ty, pers_fn, num_clauses) + B(cx).landing_pad(ty, pers_fn, num_clauses, cx.fcx.llfn) } pub fn SetCleanup(cx: Block, landing_pad: ValueRef) { diff --git a/src/librustc_trans/trans/builder.rs b/src/librustc_trans/trans/builder.rs index 32d9ee7a508b1..e39fc18dc7bf1 100644 --- a/src/librustc_trans/trans/builder.rs +++ b/src/librustc_trans/trans/builder.rs @@ -927,11 +927,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - pub fn landing_pad(&self, ty: Type, pers_fn: ValueRef, num_clauses: usize) -> ValueRef { + pub fn landing_pad(&self, ty: Type, pers_fn: ValueRef, + num_clauses: usize, + llfn: ValueRef) -> ValueRef { self.count_insn("landingpad"); unsafe { - llvm::LLVMBuildLandingPad( - self.llbuilder, ty.to_ref(), pers_fn, num_clauses as c_uint, noname()) + llvm::LLVMRustBuildLandingPad(self.llbuilder, ty.to_ref(), pers_fn, + num_clauses as c_uint, noname(), llfn) } } diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index cf9d70cc65727..5a4bd7ff3a184 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -10,8 +10,6 @@ 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; @@ -83,7 +81,6 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> { pub struct LocalCrateContext<'tcx> { llmod: ModuleRef, llcx: ContextRef, - td: TargetData, tn: TypeNames, externs: RefCell, item_vals: RefCell>, @@ -226,9 +223,15 @@ 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); - 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(); @@ -419,13 +422,6 @@ impl<'tcx> LocalCrateContext<'tcx> { 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 { @@ -435,7 +431,6 @@ impl<'tcx> LocalCrateContext<'tcx> { let mut local_ccx = LocalCrateContext { llmod: llmod, llcx: llcx, - td: td, tn: TypeNames::new(), externs: RefCell::new(FnvHashMap()), item_vals: RefCell::new(NodeMap()), @@ -581,8 +576,8 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { 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 { diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index ed494d0765bb0..599a255ef8b6c 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -1606,13 +1606,10 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, .collect(); let discriminant_type_metadata = |inttype| { - // We can reuse the type of the discriminant for all monomorphized - // instances of an enum because it doesn't depend on any type - // parameters. The def_id, uniquely identifying the enum's polytype acts - // as key in this cache. + let disr_type_key = (enum_def_id, inttype); let cached_discriminant_type_metadata = debug_context(cx).created_enum_disr_types .borrow() - .get(&enum_def_id).cloned(); + .get(&disr_type_key).cloned(); match cached_discriminant_type_metadata { Some(discriminant_type_metadata) => discriminant_type_metadata, None => { @@ -1641,7 +1638,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, debug_context(cx).created_enum_disr_types .borrow_mut() - .insert(enum_def_id, discriminant_type_metadata); + .insert(disr_type_key, discriminant_type_metadata); discriminant_type_metadata } diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/trans/debuginfo/mod.rs index 3d1b384c2d915..a873529891731 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -32,7 +32,7 @@ use trans; use trans::monomorphize; use middle::ty::Ty; use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; -use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet}; +use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet}; use libc::c_uint; use std::cell::{Cell, RefCell}; @@ -41,6 +41,7 @@ use std::ptr; use std::rc::Rc; use syntax::codemap::{Span, Pos}; use syntax::{ast, codemap, ast_util}; +use syntax::attr::IntType; use syntax::parse::token::{self, special_idents}; pub mod gdb; @@ -73,7 +74,7 @@ pub struct CrateDebugContext<'tcx> { builder: DIBuilderRef, current_debug_location: Cell, created_files: RefCell>, - created_enum_disr_types: RefCell>, + created_enum_disr_types: RefCell>, type_map: RefCell>, namespace_map: RefCell, Rc>>, @@ -94,7 +95,7 @@ impl<'tcx> CrateDebugContext<'tcx> { builder: builder, current_debug_location: Cell::new(InternalDebugLocation::UnknownLocation), created_files: RefCell::new(FnvHashMap()), - created_enum_disr_types: RefCell::new(DefIdMap()), + created_enum_disr_types: RefCell::new(FnvHashMap()), type_map: RefCell::new(TypeMap::new()), namespace_map: RefCell::new(FnvHashMap()), composite_types_completed: RefCell::new(FnvHashSet()), diff --git a/src/librustc_trans/trans/machine.rs b/src/librustc_trans/trans/machine.rs index 39bc547a1a764..691fba42d5705 100644 --- a/src/librustc_trans/trans/machine.rs +++ b/src/librustc_trans/trans/machine.rs @@ -27,7 +27,7 @@ pub type llalign = u32; // 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()); } } @@ -35,7 +35,7 @@ pub fn llsize_of_store(cx: &CrateContext, ty: Type) -> llsize { // 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()); } } @@ -51,7 +51,7 @@ pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> llsize { // 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) @@ -64,7 +64,7 @@ pub fn llsize_of_real(cx: &CrateContext, ty: Type) -> llsize { /// 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()) } } @@ -86,7 +86,7 @@ pub fn llsize_of(cx: &CrateContext, ty: Type) -> ValueRef { // 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()); } } @@ -95,13 +95,13 @@ pub fn llalign_of_pref(cx: &CrateContext, ty: Type) -> llalign { // 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); } diff --git a/src/llvm b/src/llvm index 8cbcdf1b72e1b..874dc4ee4cb78 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 8cbcdf1b72e1b23679646f6faca265f76b20d379 +Subproject commit 874dc4ee4cb782056469f003831bcda3e4cdf0df diff --git a/src/rt/rust_try.ll b/src/rt/rust_try.ll index 845fc097cdc78..8643131d0fb74 100644 --- a/src/rt/rust_try.ll +++ b/src/rt/rust_try.ll @@ -14,7 +14,9 @@ ; See also: libstd/rt/unwind/mod.rs -define i8* @rust_try(void (i8*)* %f, i8* %env) { +define i8* @rust_try(void (i8*)* %f, i8* %env) + personality i8* bitcast (i32 (...)* @rust_eh_personality_catch to i8*) +{ %1 = invoke i8* @rust_try_inner(void (i8*)* %f, i8* %env) to label %normal @@ -24,13 +26,15 @@ normal: ret i8* %1 catch: - landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @rust_eh_personality_catch to i8*) - catch i8* null - ; rust_try_inner's landing pad does not resume unwinds, so execution will never reach here + landingpad { i8*, i32 } catch i8* null + ; rust_try_inner's landing pad does not resume unwinds, so execution will + ; never reach here ret i8* null } -define internal i8* @rust_try_inner(void (i8*)* %f, i8* %env) { +define internal i8* @rust_try_inner(void (i8*)* %f, i8* %env) + personality i8* bitcast (i32 (...)* @rust_eh_personality to i8*) +{ invoke void %f(i8* %env) to label %normal @@ -40,8 +44,7 @@ normal: ret i8* null catch: - %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @rust_eh_personality to i8*) - catch i8* null + %1 = landingpad { i8*, i32 } catch i8* null ; extract and return pointer to the exception object %2 = extractvalue { i8*, i32 } %1, 0 ret i8* %2 diff --git a/src/rt/rust_try_msvc_64.ll b/src/rt/rust_try_msvc_64.ll index bda136d84780b..c38e6081bf2d3 100644 --- a/src/rt/rust_try_msvc_64.ll +++ b/src/rt/rust_try_msvc_64.ll @@ -21,7 +21,9 @@ ; ; See also: src/libstd/rt/unwind/seh.rs -define i8* @rust_try(void (i8*)* %f, i8* %env) { +define i8* @rust_try(void (i8*)* %f, i8* %env) + personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +{ invoke void %f(i8* %env) to label %normal unwind label %catch @@ -58,8 +60,8 @@ normal: ; but apparently LLVM chokes on this, so we do the more complicated thing to ; placate it. catch: - %vals = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) - catch i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*) + %vals = landingpad { i8*, i32 } + catch i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*) %ehptr = extractvalue { i8*, i32 } %vals, 0 %sel = extractvalue { i8*, i32 } %vals, 1 %filter_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*)) diff --git a/src/rustllvm/ArchiveWrapper.cpp b/src/rustllvm/ArchiveWrapper.cpp index 2e94c1969354a..86225874df77d 100644 --- a/src/rustllvm/ArchiveWrapper.cpp +++ b/src/rustllvm/ArchiveWrapper.cpp @@ -120,7 +120,17 @@ LLVMRustArchiveChildName(const Archive::Child *child, size_t *size) { extern "C" const char* LLVMRustArchiveChildData(Archive::Child *child, size_t *size) { - StringRef buf = child->getBuffer(); + StringRef buf; +#if LLVM_VERSION_MINOR >= 7 + ErrorOr buf_or_err = child->getBuffer(); + if (buf_or_err.getError()) { + LLVMRustSetLastError(buf_or_err.getError().message().c_str()); + return NULL; + } + buf = buf_or_err.get(); +#else + buf = child->getBuffer(); +#endif *size = buf.size(); return buf.data(); } @@ -144,7 +154,8 @@ extern "C" int LLVMRustWriteArchive(char *Dst, size_t NumMembers, const LLVMRustArchiveMember **NewMembers, - bool WriteSymbtab) { + bool WriteSymbtab, + Archive::Kind Kind) { #if LLVM_VERSION_MINOR >= 7 std::vector Members; @@ -157,7 +168,7 @@ LLVMRustWriteArchive(char *Dst, Members.push_back(NewArchiveIterator(Member->child, Member->name)); } } - auto pair = writeArchive(Dst, Members, WriteSymbtab); + auto pair = writeArchive(Dst, Members, WriteSymbtab, Kind, false); if (!pair.second) return 0; LLVMRustSetLastError(pair.second.message().c_str()); diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 2c0240eb8f92b..6513fdfd2f2c1 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -21,6 +21,8 @@ #else #include "llvm/Target/TargetLibraryInfo.h" #endif +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" @@ -327,3 +329,28 @@ LLVMRustMarkAllFunctionsNounwind(LLVMModuleRef M) { } } } + +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 +} diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 6861ad43a3cfa..163e95b890f4b 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -942,3 +942,18 @@ extern "C" void LLVMWriteSMDiagnosticToString(LLVMSMDiagnosticRef d, RustStringR raw_rust_string_ostream os(str); unwrap(d)->print("", os); } + +extern "C" LLVMValueRef +LLVMRustBuildLandingPad(LLVMBuilderRef Builder, + LLVMTypeRef Ty, + LLVMValueRef PersFn, + unsigned NumClauses, + const char* Name, + LLVMValueRef F) { +#if LLVM_VERSION_MINOR >= 7 + unwrap(F)->setPersonalityFn(unwrap(PersFn)); + return LLVMBuildLandingPad(Builder, Ty, NumClauses, Name); +#else + return LLVMBuildLandingPad(Builder, Ty, PersFn, NumClauses, Name); +#endif +} diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index 38b7b49a3443e..dc0fbf6bf94ea 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2015-06-16 +2015-06-30 diff --git a/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs b/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs new file mode 100644 index 0000000000000..ae290e228cc4a --- /dev/null +++ b/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs @@ -0,0 +1,92 @@ +// Copyright 2013-2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// ignore-lldb: FIXME(#27089) +// min-lldb-version: 310 + +// compile-flags:-g + +// === GDB TESTS =================================================================================== +// gdb-command:run + +// gdb-command:print eight_bytes1 +// gdb-check:$1 = {{RUST$ENUM$DISR = Variant1, __0 = 100}, {RUST$ENUM$DISR = Variant1, __0 = 100}} +// gdb-command:print four_bytes1 +// gdb-check:$2 = {{RUST$ENUM$DISR = Variant1, __0 = 101}, {RUST$ENUM$DISR = Variant1, __0 = 101}} +// gdb-command:print two_bytes1 +// gdb-check:$3 = {{RUST$ENUM$DISR = Variant1, __0 = 102}, {RUST$ENUM$DISR = Variant1, __0 = 102}} +// gdb-command:print one_byte1 +// gdb-check:$4 = {{RUST$ENUM$DISR = Variant1, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant1, __0 = 65 'A'}} + +// gdb-command:print eight_bytes2 +// gdb-check:$5 = {{RUST$ENUM$DISR = Variant2, __0 = 100}, {RUST$ENUM$DISR = Variant2, __0 = 100}} +// gdb-command:print four_bytes2 +// gdb-check:$6 = {{RUST$ENUM$DISR = Variant2, __0 = 101}, {RUST$ENUM$DISR = Variant2, __0 = 101}} +// gdb-command:print two_bytes2 +// gdb-check:$7 = {{RUST$ENUM$DISR = Variant2, __0 = 102}, {RUST$ENUM$DISR = Variant2, __0 = 102}} +// gdb-command:print one_byte2 +// gdb-check:$8 = {{RUST$ENUM$DISR = Variant2, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant2, __0 = 65 'A'}} + +// gdb-command:continue + +// === LLDB TESTS ================================================================================== +// lldb-command:run + +// lldb-command:print eight_bytes1 +// lldb-check:[...]$0 = Variant1(100) +// lldb-command:print four_bytes1 +// lldb-check:[...]$1 = Variant1(101) +// lldb-command:print two_bytes1 +// lldb-check:[...]$2 = Variant1(102) +// lldb-command:print one_byte1 +// lldb-check:[...]$3 = Variant1('A') + +// lldb-command:print eight_bytes2 +// lldb-check:[...]$4 = Variant2(100) +// lldb-command:print four_bytes2 +// lldb-check:[...]$5 = Variant2(101) +// lldb-command:print two_bytes2 +// lldb-check:[...]$6 = Variant2(102) +// lldb-command:print one_byte2 +// lldb-check:[...]$7 = Variant2('A') + +// lldb-command:continue + +#![allow(unused_variables)] +#![allow(dead_code)] +#![omit_gdb_pretty_printer_section] + +// This test case makes sure that we get correct type descriptions for the enum +// discriminant of different instantiations of the same generic enum type where, +// dependending on the generic type parameter(s), the discriminant has a +// different size in memory. + +enum Enum { + Variant1(T), + Variant2(T) +} + +fn main() { + // These are ordered for descending size on purpose + let eight_bytes1 = Enum::Variant1(100.0f64); + let four_bytes1 = Enum::Variant1(101i32); + let two_bytes1 = Enum::Variant1(102i16); + let one_byte1 = Enum::Variant1(65u8); + + let eight_bytes2 = Enum::Variant2(100.0f64); + let four_bytes2 = Enum::Variant2(101i32); + let two_bytes2 = Enum::Variant2(102i16); + let one_byte2 = Enum::Variant2(65u8); + + zzz(); // #break +} + +fn zzz() { () }