Skip to content

Commit 0062f72

Browse files
committed
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.
1 parent 5367776 commit 0062f72

8 files changed

+33
-0
lines changed

src/librustc_back/target/i686_apple_darwin.rs

+5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::apple_base::opts();
15+
16+
// Use yonah as default CPU to enable SSE[2] instructions.
17+
// Clang defaults to i686 for this target, but defaulting to yonah
18+
// is consistent with what Clang does for i386-apple-darwin.
1519
base.cpu = "yonah".to_string();
20+
1621
base.pre_link_args.push("-m32".to_string());
1722

1823
Target {

src/librustc_back/target/i686_linux_android.rs

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::android_base::opts();
15+
16+
// Use pentium4 as default CPU to enable SSE[2] instructions.
17+
// Clang defaults to i686 and enables SSSE3 for this target, but
18+
// defaulting to pentium4 is consistent with linux and windows
19+
// targets.
1520
base.cpu = "pentium4".to_string();
1621

1722
Target {

src/librustc_back/target/i686_pc_windows_gnu.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::windows_base::opts();
15+
16+
// Use pentium4 as default CPU to enable SSE[2] instructions.
17+
// Clang uses the same default.
1518
base.cpu = "pentium4".to_string();
1619

1720
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address

src/librustc_back/target/i686_pc_windows_msvc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::windows_msvc_base::opts();
15+
16+
// Use pentium4 as default CPU to enable SSE[2] instructions.
17+
// Clang uses the same default.
1518
base.cpu = "pentium4".to_string();
1619

1720
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address

src/librustc_back/target/i686_unknown_dragonfly.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::dragonfly_base::opts();
15+
16+
// Use pentium4 as default CPU to enable SSE[2] instructions.
17+
// Clang uses the same default.
1518
base.cpu = "pentium4".to_string();
19+
1620
base.pre_link_args.push("-m32".to_string());
1721

1822
Target {

src/librustc_back/target/i686_unknown_freebsd.rs

+5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::freebsd_base::opts();
15+
16+
// Use pentium4 as default CPU to enable SSE[2] instructions.
17+
// Clang defaults to i486 for this target, but defaulting to
18+
// pentium4 is consistent with linux and windows targets.
1519
base.cpu = "pentium4".to_string();
20+
1621
base.pre_link_args.push("-m32".to_string());
1722

1823
Target {

src/librustc_back/target/i686_unknown_linux_gnu.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::linux_base::opts();
15+
16+
// Use pentium4 as default CPU to enable SSE[2] instructions.
17+
// Clang uses the same default.
1518
base.cpu = "pentium4".to_string();
19+
1620
base.pre_link_args.push("-m32".to_string());
1721

1822
Target {

src/librustc_back/target/i686_unknown_linux_musl.rs

+4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ use target::Target;
1414

1515
pub fn target() -> Target {
1616
let mut base = super::linux_base::opts();
17+
18+
// Use pentium4 as default CPU to enable SSE[2] instructions.
19+
// Clang uses the same default.
1720
base.cpu = "pentium4".to_string();
21+
1822
base.pre_link_args.push("-m32".to_string());
1923
base.pre_link_args.push("-Wl,-melf_i386".to_string());
2024

0 commit comments

Comments
 (0)