From 0062f72f88b28557325ead2050a015015b20e713 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Sat, 13 Feb 2016 17:16:26 +0100 Subject: [PATCH 1/2] Add comments about the differences between Clang and rustc target CPUs Keep track of differences between Clang and rust choices about default CPUs for 32-bit x86 targets. --- src/librustc_back/target/i686_apple_darwin.rs | 5 +++++ src/librustc_back/target/i686_linux_android.rs | 5 +++++ src/librustc_back/target/i686_pc_windows_gnu.rs | 3 +++ src/librustc_back/target/i686_pc_windows_msvc.rs | 3 +++ src/librustc_back/target/i686_unknown_dragonfly.rs | 4 ++++ src/librustc_back/target/i686_unknown_freebsd.rs | 5 +++++ src/librustc_back/target/i686_unknown_linux_gnu.rs | 4 ++++ src/librustc_back/target/i686_unknown_linux_musl.rs | 4 ++++ 8 files changed, 33 insertions(+) diff --git a/src/librustc_back/target/i686_apple_darwin.rs b/src/librustc_back/target/i686_apple_darwin.rs index 98f4654ecab41..0612c98ae5c8e 100644 --- a/src/librustc_back/target/i686_apple_darwin.rs +++ b/src/librustc_back/target/i686_apple_darwin.rs @@ -12,7 +12,12 @@ use target::Target; pub fn target() -> Target { let mut base = super::apple_base::opts(); + + // Use yonah as default CPU to enable SSE[2] instructions. + // Clang defaults to i686 for this target, but defaulting to yonah + // is consistent with what Clang does for i386-apple-darwin. base.cpu = "yonah".to_string(); + base.pre_link_args.push("-m32".to_string()); Target { diff --git a/src/librustc_back/target/i686_linux_android.rs b/src/librustc_back/target/i686_linux_android.rs index f548fdad3cbed..5546146c4eed3 100644 --- a/src/librustc_back/target/i686_linux_android.rs +++ b/src/librustc_back/target/i686_linux_android.rs @@ -12,6 +12,11 @@ use target::Target; pub fn target() -> Target { let mut base = super::android_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang defaults to i686 and enables SSSE3 for this target, but + // defaulting to pentium4 is consistent with linux and windows + // targets. base.cpu = "pentium4".to_string(); Target { diff --git a/src/librustc_back/target/i686_pc_windows_gnu.rs b/src/librustc_back/target/i686_pc_windows_gnu.rs index fa12bbd89323c..37999f9ce4b3f 100644 --- a/src/librustc_back/target/i686_pc_windows_gnu.rs +++ b/src/librustc_back/target/i686_pc_windows_gnu.rs @@ -12,6 +12,9 @@ use target::Target; pub fn target() -> Target { let mut base = super::windows_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang uses the same default. base.cpu = "pentium4".to_string(); // Mark all dynamic libraries and executables as compatible with the larger 4GiB address diff --git a/src/librustc_back/target/i686_pc_windows_msvc.rs b/src/librustc_back/target/i686_pc_windows_msvc.rs index 7fe6590618941..e116d43eab712 100644 --- a/src/librustc_back/target/i686_pc_windows_msvc.rs +++ b/src/librustc_back/target/i686_pc_windows_msvc.rs @@ -12,6 +12,9 @@ use target::Target; pub fn target() -> Target { let mut base = super::windows_msvc_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang uses the same default. base.cpu = "pentium4".to_string(); // Mark all dynamic libraries and executables as compatible with the larger 4GiB address diff --git a/src/librustc_back/target/i686_unknown_dragonfly.rs b/src/librustc_back/target/i686_unknown_dragonfly.rs index 32a15b9f2d4d1..95a3ee9fd17c7 100644 --- a/src/librustc_back/target/i686_unknown_dragonfly.rs +++ b/src/librustc_back/target/i686_unknown_dragonfly.rs @@ -12,7 +12,11 @@ use target::Target; pub fn target() -> Target { let mut base = super::dragonfly_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang uses the same default. base.cpu = "pentium4".to_string(); + base.pre_link_args.push("-m32".to_string()); Target { diff --git a/src/librustc_back/target/i686_unknown_freebsd.rs b/src/librustc_back/target/i686_unknown_freebsd.rs index 812ba11cd796b..74167705ccd95 100644 --- a/src/librustc_back/target/i686_unknown_freebsd.rs +++ b/src/librustc_back/target/i686_unknown_freebsd.rs @@ -12,7 +12,12 @@ use target::Target; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang defaults to i486 for this target, but defaulting to + // pentium4 is consistent with linux and windows targets. base.cpu = "pentium4".to_string(); + base.pre_link_args.push("-m32".to_string()); Target { diff --git a/src/librustc_back/target/i686_unknown_linux_gnu.rs b/src/librustc_back/target/i686_unknown_linux_gnu.rs index ac2af0c64fd6a..3a0ee748da5e5 100644 --- a/src/librustc_back/target/i686_unknown_linux_gnu.rs +++ b/src/librustc_back/target/i686_unknown_linux_gnu.rs @@ -12,7 +12,11 @@ use target::Target; pub fn target() -> Target { let mut base = super::linux_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang uses the same default. base.cpu = "pentium4".to_string(); + base.pre_link_args.push("-m32".to_string()); Target { diff --git a/src/librustc_back/target/i686_unknown_linux_musl.rs b/src/librustc_back/target/i686_unknown_linux_musl.rs index 77bc7bb51755d..f987ad2a313b2 100644 --- a/src/librustc_back/target/i686_unknown_linux_musl.rs +++ b/src/librustc_back/target/i686_unknown_linux_musl.rs @@ -14,7 +14,11 @@ use target::Target; pub fn target() -> Target { let mut base = super::linux_base::opts(); + + // Use pentium4 as default CPU to enable SSE[2] instructions. + // Clang uses the same default. base.cpu = "pentium4".to_string(); + base.pre_link_args.push("-m32".to_string()); base.pre_link_args.push("-Wl,-melf_i386".to_string()); From 8c840ee91d972523ca8a3e874b463130e8535615 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Sat, 13 Feb 2016 17:45:46 +0100 Subject: [PATCH 2/2] Synchronize i686 rustc triples with Clang Try to be consistently replicate Clang default CPU for i686 triples. --- src/librustc_back/target/i686_apple_darwin.rs | 7 ++----- src/librustc_back/target/i686_linux_android.rs | 9 ++++----- src/librustc_back/target/i686_unknown_freebsd.rs | 6 ++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/librustc_back/target/i686_apple_darwin.rs b/src/librustc_back/target/i686_apple_darwin.rs index 0612c98ae5c8e..c05ff1fe91590 100644 --- a/src/librustc_back/target/i686_apple_darwin.rs +++ b/src/librustc_back/target/i686_apple_darwin.rs @@ -12,11 +12,8 @@ use target::Target; pub fn target() -> Target { let mut base = super::apple_base::opts(); - - // Use yonah as default CPU to enable SSE[2] instructions. - // Clang defaults to i686 for this target, but defaulting to yonah - // is consistent with what Clang does for i386-apple-darwin. - base.cpu = "yonah".to_string(); + // Use i686 as default CPU. Clang uses the same default. + base.cpu = "i686".to_string(); base.pre_link_args.push("-m32".to_string()); diff --git a/src/librustc_back/target/i686_linux_android.rs b/src/librustc_back/target/i686_linux_android.rs index 5546146c4eed3..77e481781968c 100644 --- a/src/librustc_back/target/i686_linux_android.rs +++ b/src/librustc_back/target/i686_linux_android.rs @@ -13,11 +13,10 @@ use target::Target; pub fn target() -> Target { let mut base = super::android_base::opts(); - // Use pentium4 as default CPU to enable SSE[2] instructions. - // Clang defaults to i686 and enables SSSE3 for this target, but - // defaulting to pentium4 is consistent with linux and windows - // targets. - base.cpu = "pentium4".to_string(); + // Use i686 as default CPU and enable SSSE3. + // Clang and GCC do the same. + base.cpu = "i686".to_string(); + base.features = "+ssse3".to_string(); Target { llvm_target: "i686-linux-android".to_string(), diff --git a/src/librustc_back/target/i686_unknown_freebsd.rs b/src/librustc_back/target/i686_unknown_freebsd.rs index 74167705ccd95..d24f93860ef08 100644 --- a/src/librustc_back/target/i686_unknown_freebsd.rs +++ b/src/librustc_back/target/i686_unknown_freebsd.rs @@ -13,10 +13,8 @@ use target::Target; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); - // Use pentium4 as default CPU to enable SSE[2] instructions. - // Clang defaults to i486 for this target, but defaulting to - // pentium4 is consistent with linux and windows targets. - base.cpu = "pentium4".to_string(); + // Use i486 as default CPU. Clang uses the same default. + base.cpu = "i486".to_string(); base.pre_link_args.push("-m32".to_string());