@@ -2582,6 +2582,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
2582
2582
bool TakeNextArg = false ;
2583
2583
2584
2584
const llvm::Triple &Triple = C.getDefaultToolChain ().getTriple ();
2585
+ bool IsELF = Triple.isOSBinFormatELF ();
2585
2586
bool Crel = false , ExperimentalCrel = false ;
2586
2587
bool UseRelaxRelocations = C.getDefaultToolChain ().useRelaxRelocations ();
2587
2588
bool UseNoExecStack = false ;
@@ -2621,10 +2622,16 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
2621
2622
continue ; // LLVM handles bigobj automatically
2622
2623
2623
2624
auto Equal = Value.split (' =' );
2624
- auto checkArg = [&](std::initializer_list<const char *> Set) {
2625
- if (!llvm::is_contained (Set, Equal.second ))
2625
+ auto checkArg = [&](bool ValidTarget,
2626
+ std::initializer_list<const char *> Set) {
2627
+ if (!ValidTarget) {
2628
+ D.Diag (diag::err_drv_unsupported_opt_for_target)
2629
+ << (Twine (" -Wa," ) + Equal.first + " =" ).str ()
2630
+ << Triple.getTriple ();
2631
+ } else if (!llvm::is_contained (Set, Equal.second )) {
2626
2632
D.Diag (diag::err_drv_unsupported_option_argument)
2627
2633
<< (Twine (" -Wa," ) + Equal.first + " =" ).str () << Equal.second ;
2634
+ }
2628
2635
};
2629
2636
switch (C.getDefaultToolChain ().getArch ()) {
2630
2637
default :
@@ -2634,7 +2641,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
2634
2641
if (Equal.first == " -mrelax-relocations" ||
2635
2642
Equal.first == " --mrelax-relocations" ) {
2636
2643
UseRelaxRelocations = Equal.second == " yes" ;
2637
- checkArg ({" yes" , " no" });
2644
+ checkArg (IsELF, {" yes" , " no" });
2638
2645
continue ;
2639
2646
}
2640
2647
if (Value == " -msse2avx" ) {
@@ -2656,7 +2663,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
2656
2663
if (Equal.first == " -mimplicit-it" ) {
2657
2664
// Only store the value; the last value set takes effect.
2658
2665
ImplicitIt = Equal.second ;
2659
- checkArg ({" always" , " never" , " arm" , " thumb" });
2666
+ checkArg (true , {" always" , " never" , " arm" , " thumb" });
2660
2667
continue ;
2661
2668
}
2662
2669
if (Value == " -mthumb" )
0 commit comments