@@ -2582,6 +2582,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
25822582 bool TakeNextArg = false ;
25832583
25842584 const llvm::Triple &Triple = C.getDefaultToolChain ().getTriple ();
2585+ bool IsELF = Triple.isOSBinFormatELF ();
25852586 bool Crel = false , ExperimentalCrel = false ;
25862587 bool UseRelaxRelocations = C.getDefaultToolChain ().useRelaxRelocations ();
25872588 bool UseNoExecStack = false ;
@@ -2621,10 +2622,16 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26212622 continue ; // LLVM handles bigobj automatically
26222623
26232624 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 )) {
26262632 D.Diag (diag::err_drv_unsupported_option_argument)
26272633 << (Twine (" -Wa," ) + Equal.first + " =" ).str () << Equal.second ;
2634+ }
26282635 };
26292636 switch (C.getDefaultToolChain ().getArch ()) {
26302637 default :
@@ -2634,7 +2641,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26342641 if (Equal.first == " -mrelax-relocations" ||
26352642 Equal.first == " --mrelax-relocations" ) {
26362643 UseRelaxRelocations = Equal.second == " yes" ;
2637- checkArg ({" yes" , " no" });
2644+ checkArg (IsELF, {" yes" , " no" });
26382645 continue ;
26392646 }
26402647 if (Value == " -msse2avx" ) {
@@ -2656,7 +2663,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26562663 if (Equal.first == " -mimplicit-it" ) {
26572664 // Only store the value; the last value set takes effect.
26582665 ImplicitIt = Equal.second ;
2659- checkArg ({" always" , " never" , " arm" , " thumb" });
2666+ checkArg (true , {" always" , " never" , " arm" , " thumb" });
26602667 continue ;
26612668 }
26622669 if (Value == " -mthumb" )
0 commit comments