aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2023-12-05 14:26:54 -0500
committerEli Schwartz <eschwartz93@gmail.com>2023-12-05 19:51:56 -0500
commit5f659af870011e74299d1455a65c2cd5f5ace51f (patch)
treedf320935a1f2883795e72e284715004800c8b7e5 /unittests
parent30184a48a032e6a2a6dbf0a76e437aa676c3e4aa (diff)
downloadmeson-5f659af870011e74299d1455a65c2cd5f5ace51f.zip
meson-5f659af870011e74299d1455a65c2cd5f5ace51f.tar.gz
meson-5f659af870011e74299d1455a65c2cd5f5ace51f.tar.bz2
ninja backend: don't hide all compiler warnings for transpiled languages
This was originally added for vala only, with the rationale that vala generates bad code that has warnings. Unfortunately, the rationale was fatally flawed. The compiler warns about a number of things, which the user can control depending on their code (or their code generator's code), but some of those things are absolutely critical to warn about. In particular, GCC 14 and clang 17 are updating their defaults to warn -- and error by default for -- invalid C code that breaks the standard, but has been silently accepted for over 20 years "because lots of people do it". The code in question is UB, and compilers will generate faulty machine code that behaves erroneously and probably has a mass of CVEs waiting to happen. Compiler warnings are NOT safe to just... universally turn off. Compiler warnings could be either: - coding style lints - threatening statements that the code is factually and behaviorally wrong There is no magic bullet to ignore the former while respecting the latter. And the very last thing we should ever do is pass `-w`, since that causes ALL warnings to be disabled, even the manually added `-Werror=XXX`. If vala generated code creates warnings, then the vala compiler can decrease the log level by generating better code, or by adding warning suppression pragmas for *specific* issues, such as unused functions.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/linuxliketests.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index 4fcf52e..a02c99e 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -298,43 +298,6 @@ class LinuxlikeTests(BasePlatformTests):
self.build()
self._run(self.mtest_command)
- def test_vala_c_warnings(self):
- '''
- Test that no warnings are emitted for C code generated by Vala. This
- can't be an ordinary test case because we need to inspect the compiler
- database.
- https://github.com/mesonbuild/meson/issues/864
- '''
- if not shutil.which('valac'):
- raise SkipTest('valac not installed.')
- testdir = os.path.join(self.vala_test_dir, '5 target glib')
- self.init(testdir)
- compdb = self.get_compdb()
- vala_command = None
- c_command = None
- for each in compdb:
- if each['file'].endswith('GLib.Thread.c'):
- vala_command = each['command']
- elif each['file'].endswith('GLib.Thread.vala'):
- continue
- elif each['file'].endswith('retcode.c'):
- c_command = each['command']
- else:
- m = 'Unknown file {!r} in vala_c_warnings test'.format(each['file'])
- raise AssertionError(m)
- self.assertIsNotNone(vala_command)
- self.assertIsNotNone(c_command)
- # -w suppresses all warnings, should be there in Vala but not in C
- self.assertIn(" -w ", vala_command)
- self.assertNotIn(" -w ", c_command)
- # -Wall enables all warnings, should be there in C but not in Vala
- self.assertNotIn(" -Wall ", vala_command)
- self.assertIn(" -Wall ", c_command)
- # -Werror converts warnings to errors, should always be there since it's
- # injected by an unrelated piece of code and the project has werror=true
- self.assertIn(" -Werror ", vala_command)
- self.assertIn(" -Werror ", c_command)
-
@skipIfNoPkgconfig
def test_qtdependency_pkgconfig_detection(self):
'''