From 14b6c6d153edec5731230f919eaafcb5c32959d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sun, 11 Jan 2015 12:11:44 +0100 Subject: [PATCH] Default to "x86-64" as the target cpu for x86_64 builds Using "generic" disables a number of features that are present on all x86_64 cpus, the "x86-64" target cpu is the common denominator for that arch. Refs #20777 --- src/librustc_back/target/apple_ios_base.rs | 9 +++++++++ src/librustc_back/target/x86_64_apple_darwin.rs | 1 + src/librustc_back/target/x86_64_pc_windows_gnu.rs | 1 + src/librustc_back/target/x86_64_unknown_dragonfly.rs | 1 + src/librustc_back/target/x86_64_unknown_freebsd.rs | 1 + src/librustc_back/target/x86_64_unknown_linux_gnu.rs | 1 + 6 files changed, 14 insertions(+) diff --git a/src/librustc_back/target/apple_ios_base.rs b/src/librustc_back/target/apple_ios_base.rs index f9dcb4fb812..ac133cabc3b 100644 --- a/src/librustc_back/target/apple_ios_base.rs +++ b/src/librustc_back/target/apple_ios_base.rs @@ -14,6 +14,7 @@ use self::Arch::*; #[allow(non_camel_case_types)] +#[derive(Copy)] pub enum Arch { Armv7, Armv7s, @@ -70,8 +71,16 @@ fn pre_link_args(arch: Arch) -> Vec { "-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name)] } +fn target_cpu(arch: Arch) -> String { + match arch { + X86_64 => "x86-64", + _ => "generic", + }.to_string() +} + pub fn opts(arch: Arch) -> TargetOptions { TargetOptions { + cpu: target_cpu(arch), dynamic_linking: false, executables: true, // Although there is an experimental implementation of LLVM which diff --git a/src/librustc_back/target/x86_64_apple_darwin.rs b/src/librustc_back/target/x86_64_apple_darwin.rs index 0ebd3bd3215..f2abfd4564c 100644 --- a/src/librustc_back/target/x86_64_apple_darwin.rs +++ b/src/librustc_back/target/x86_64_apple_darwin.rs @@ -12,6 +12,7 @@ pub fn target() -> Target { let mut base = super::apple_base::opts(); + base.cpu = "x86-64".to_string(); base.eliminate_frame_pointer = false; base.pre_link_args.push("-m64".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 9e1294a8962..6b3054656fe 100644 --- a/src/librustc_back/target/x86_64_pc_windows_gnu.rs +++ b/src/librustc_back/target/x86_64_pc_windows_gnu.rs @@ -12,6 +12,7 @@ pub fn target() -> Target { let mut base = super::windows_base::opts(); + base.cpu = "x86-64".to_string(); // On Win64 unwinding is handled by the OS, so we can link libgcc statically. base.pre_link_args.push("-static-libgcc".to_string()); base.pre_link_args.push("-m64".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 6635306b0e1..676aaecc2fc 100644 --- a/src/librustc_back/target/x86_64_unknown_dragonfly.rs +++ b/src/librustc_back/target/x86_64_unknown_dragonfly.rs @@ -12,6 +12,7 @@ pub fn target() -> Target { let mut base = super::dragonfly_base::opts(); + base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); Target { diff --git a/src/librustc_back/target/x86_64_unknown_freebsd.rs b/src/librustc_back/target/x86_64_unknown_freebsd.rs index 2aba2b8defb..3275cb07b5a 100644 --- a/src/librustc_back/target/x86_64_unknown_freebsd.rs +++ b/src/librustc_back/target/x86_64_unknown_freebsd.rs @@ -12,6 +12,7 @@ pub fn target() -> Target { let mut base = super::freebsd_base::opts(); + base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); Target { 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 d7a6df3a8b0..49c4ad4aea9 100644 --- a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs @@ -12,6 +12,7 @@ pub fn target() -> Target { let mut base = super::linux_base::opts(); + base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); Target {