|
29 | 29 | import mesonbuild.scripts.depfixer |
30 | 30 | import mesonbuild.scripts.env2mfile |
31 | 31 | from mesonbuild import coredata |
32 | | -from mesonbuild.compilers.c import ClangCCompiler, GnuCCompiler |
33 | | -from mesonbuild.compilers.compilers import Compiler, ManyInOneLinkerOptionStyle |
| 32 | +from mesonbuild.compilers import Compiler |
| 33 | +from mesonbuild.compilers.c import ClangCCompiler, ClangClCCompiler, GnuCCompiler |
| 34 | +from mesonbuild.compilers.compilers import CompileCheckMode, ManyInOneLinkerOptionStyle |
34 | 35 | from mesonbuild.compilers.cpp import VisualStudioCPPCompiler |
35 | 36 | from mesonbuild.compilers.d import DmdDCompiler |
36 | 37 | from mesonbuild.compilers.detect import detect_c_compiler |
@@ -435,6 +436,27 @@ def test_clike_sanity_check_drops_link_only_args_when_compile_only(self): |
435 | 436 | self.assertEqual(largs, []) |
436 | 437 |
|
437 | 438 |
|
| 439 | + def test_clang_family_compiler_check_args_contain_werror_unknown_warning(self): |
| 440 | + env = get_fake_env() |
| 441 | + mold = linkers.MoldDynamicLinker([], env, MachineChoice.HOST, '-Wl,', []) |
| 442 | + lld_link = linkers.ClangClDynamicLinker(env, MachineChoice.HOST, []) |
| 443 | + |
| 444 | + compilers = { |
| 445 | + 'clang': ClangCCompiler([], [], '14.0.0', MachineChoice.HOST, env, linker=mold), |
| 446 | + 'clang-cl': ClangClCCompiler([], '14.0.0', MachineChoice.HOST, env, 'x64', linker=lld_link), |
| 447 | + } |
| 448 | + |
| 449 | + for name, cc in compilers.items(): |
| 450 | + with self.subTest(compiler=name): |
| 451 | + self.assertIn('-Werror=unknown-warning-option', |
| 452 | + cc.get_compiler_check_args(CompileCheckMode.COMPILE)) |
| 453 | + # Both clang and clang-cl only apply this diagnostic when |
| 454 | + # actually compiling; it's intentionally omitted for LINK to |
| 455 | + # avoid failing on flags that are unused during linking. |
| 456 | + self.assertNotIn('-Werror=unknown-warning-option', |
| 457 | + cc.get_compiler_check_args(CompileCheckMode.LINK)) |
| 458 | + |
| 459 | + |
438 | 460 | def test_msvc_unix_args_to_native(self): |
439 | 461 | # joined |
440 | 462 | self.assertEqual(MSVCCompiler.unix_args_to_native(['-isystemfoo']), ['/Ifoo']) |
|
0 commit comments