Skip to content

Commit

Permalink
Enforce -mtune=core2 and -mtune=yonah on macOS
Browse files Browse the repository at this point in the history
I've used the same cpu which is used by Rust: `core2` for x86_64[1] and
`yonah` for i686[2]. I also used `mtine` instead of `mcpu` because it
was deprecated at gcc since version 5[3].

It closes thepowersgang#214

I also added missed `i686-apple-darwin` target.

Footnotes:
[1]  https://github.com/rust-lang/rust/blob/1.54.0/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs
[2]  https://github.com/rust-lang/rust/blob/1.54.0/compiler/rustc_target/src/spec/i686_apple_darwin.rs
[3]  gcc-mirror/gcc@9d913bb
  • Loading branch information
catap committed Feb 8, 2022
1 parent 1890905 commit 4f13099
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/trans/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,21 @@ namespace
ARCH_X86_64
};
}
else if(target_name == "i686-apple-darwin")
{
// NOTE: OSX uses Mach-O binaries, which don't fully support the defaults used for GNU targets
// The first 32bit Intel Mac was Core Solo aka yonah. It allows to use `-mtune=yonah` like Rust.
return TargetSpec {
"unix", "macos", "gnu", {CodegenMode::Gnu11, false, "x86_64-apple-darwin", {"-mtune=yonah"}, {}},
ARCH_X86_64
};
}
else if(target_name == "x86_64-apple-darwin")
{
// NOTE: OSX uses Mach-O binaries, which don't fully support the defaults used for GNU targets
// The first 64bit Intel Mac was Core Duo. It allows to use `-mtune=core2` like Rust.
return TargetSpec {
"unix", "macos", "gnu", {CodegenMode::Gnu11, false, "x86_64-apple-darwin", {}, {}},
"unix", "macos", "gnu", {CodegenMode::Gnu11, false, "x86_64-apple-darwin", {"-mtune=core2"}, {}},
ARCH_X86_64
};
}
Expand Down

0 comments on commit 4f13099

Please sign in to comment.