[Driver] Reject -Wa,-mrelax-relocations= for non-ELF
This commit is contained in:
@@ -2582,6 +2582,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
|
||||
bool TakeNextArg = false;
|
||||
|
||||
const llvm::Triple &Triple = C.getDefaultToolChain().getTriple();
|
||||
bool IsELF = Triple.isOSBinFormatELF();
|
||||
bool Crel = false, ExperimentalCrel = false;
|
||||
bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
|
||||
bool UseNoExecStack = false;
|
||||
@@ -2621,10 +2622,16 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
|
||||
continue; // LLVM handles bigobj automatically
|
||||
|
||||
auto Equal = Value.split('=');
|
||||
auto checkArg = [&](std::initializer_list<const char *> Set) {
|
||||
if (!llvm::is_contained(Set, Equal.second))
|
||||
auto checkArg = [&](bool ValidTarget,
|
||||
std::initializer_list<const char *> Set) {
|
||||
if (!ValidTarget) {
|
||||
D.Diag(diag::err_drv_unsupported_opt_for_target)
|
||||
<< (Twine("-Wa,") + Equal.first + "=").str()
|
||||
<< Triple.getTriple();
|
||||
} else if (!llvm::is_contained(Set, Equal.second)) {
|
||||
D.Diag(diag::err_drv_unsupported_option_argument)
|
||||
<< (Twine("-Wa,") + Equal.first + "=").str() << Equal.second;
|
||||
}
|
||||
};
|
||||
switch (C.getDefaultToolChain().getArch()) {
|
||||
default:
|
||||
@@ -2634,7 +2641,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
|
||||
if (Equal.first == "-mrelax-relocations" ||
|
||||
Equal.first == "--mrelax-relocations") {
|
||||
UseRelaxRelocations = Equal.second == "yes";
|
||||
checkArg({"yes", "no"});
|
||||
checkArg(IsELF, {"yes", "no"});
|
||||
continue;
|
||||
}
|
||||
if (Value == "-msse2avx") {
|
||||
@@ -2656,7 +2663,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
|
||||
if (Equal.first == "-mimplicit-it") {
|
||||
// Only store the value; the last value set takes effect.
|
||||
ImplicitIt = Equal.second;
|
||||
checkArg({"always", "never", "arm", "thumb"});
|
||||
checkArg(true, {"always", "never", "arm", "thumb"});
|
||||
continue;
|
||||
}
|
||||
if (Value == "-mthumb")
|
||||
|
||||
@@ -8,3 +8,6 @@
|
||||
|
||||
// RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2
|
||||
// ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,'
|
||||
|
||||
// RUN: not %clang -### --target=x86_64-apple-darwin -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR3
|
||||
// ERR3: error: unsupported option '-Wa,-mrelax-relocations=' for target 'x86_64-apple-darwin'
|
||||
|
||||
Reference in New Issue
Block a user