Skip to content

Commit

Permalink
Enforce -march=core2 and -march=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 #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 authored and thepowersgang committed Feb 9, 2022
1 parent c7b69f8 commit 94ffdd3
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 `-march=yonah` like Rust.
return TargetSpec {
"unix", "macos", "gnu", {CodegenMode::Gnu11, false, "x86_64-apple-darwin", {"-march=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 `-march=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", {"-march=core2"}, {}},
ARCH_X86_64
};
}
Expand Down

0 comments on commit 94ffdd3

Please sign in to comment.