Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document and update i686 triples #31632

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc_back/target/i686_apple_darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use target::Target;

pub fn target() -> Target {
let mut base = super::apple_base::opts();
base.cpu = "yonah".to_string();
// Use i686 as default CPU. Clang uses the same default.
base.cpu = "i686".to_string();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the commit message that made this a yonah

Use more specific target CPUs on Darwin

Macs don't come with anything older than a Yonah (32bit) or Core2 (64bit), so we can default to those targets. Clang does the same.

I’m not sure why clang would change their default, but macs not existing with pre-yonah hardware seems like a pretty good reason to just use a yonah.

cc @dotdash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above: Clang defaults to yonah on i386-apple-darwin, but not on i686-apple-darwin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranma42 but if there can’t possibly be such a combination of darwin+x86 which uses anything pre-yonah, why bother (EDIT: or, rather, restrict ourselves to) targeting a decade-older CPU?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranma42 Hm, where does clang do that distinction? Did you check the code or is there a command I could use to reproduce/check this (without owning a Mac that is ;-))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, found the command in the other PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I'm reading the code correctly, there's some special handling for Darwin that disables the automatic CPU selection for any x86 target except for the i386 one. I wonder whether that's actually intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nagisa I do not know why Clang restricts itself to a decade-older CPU; we are about to do it in order to be consistent with Clang. I agree with you that it is surprising to have a sub-optimal default on Mac and that is the reason why I was suggesting to provide an i386-apple-darwin triple as default target for 32-bit Mac.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang in this regard seems... somewhat inconsistent? At the very least it seems fine to leave this as-is and perhaps document the oddity (to allow this PR to land)


base.pre_link_args.push("-m32".to_string());

Target {
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_back/target/i686_linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ use target::Target;

pub fn target() -> Target {
let mut base = super::android_base::opts();
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(),
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_back/target/i686_pc_windows_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_back/target/i686_pc_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_back/target/i686_unknown_dragonfly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_back/target/i686_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use target::Target;

pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
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());

Target {
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_back/target/i686_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_back/target/i686_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down