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

Switch to a white list of archs wrt. -m32/-m64 in cc cmdlines #3460

Merged
merged 1 commit into from
Jun 11, 2020
Merged
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
23 changes: 13 additions & 10 deletions driver/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ void appendTargetArgsForGcc(std::vector<std::string> &args) {

const auto &triple = *global.params.targetTriple;
const auto arch64 = triple.get64BitArchVariant().getArch();
const auto arch32 = triple.get32BitArchVariant().getArch();

// Only specify -m32/-m64 for architectures where the two variants actually
// exist (as e.g. the GCC ARM toolchain doesn't recognize the switches).
if (arch64 == Triple::UnknownArch || arch32 == Triple::UnknownArch ||
arch64 == Triple::aarch64 || arch64 == Triple::aarch64_be) {
switch (arch64) {
// Specify -m32/-m64 for architectures where gcc supports those flags.
case Triple::x86_64:
case Triple::ppc64:
case Triple::ppc64le:
case Triple::sparcv9:
case Triple::nvptx64:
args.push_back(triple.isArch64Bit() ? "-m64" : "-m32");
return;
}

// MIPS does not have -m32/-m64 but requires -mabi=.
if (arch64 == Triple::mips64 || arch64 == Triple::mips64el) {
case Triple::mips64:
case Triple::mips64el:
switch (getMipsABI()) {
case MipsABI::EABI:
args.push_back("-mabi=eabi");
Expand All @@ -120,11 +123,11 @@ void appendTargetArgsForGcc(std::vector<std::string> &args) {
case MipsABI::Unknown:
break;
}

return;
}

args.push_back(triple.isArch64Bit() ? "-m64" : "-m32");
default:
break;
}
}

//////////////////////////////////////////////////////////////////////////////
Expand Down