From 5f659af870011e74299d1455a65c2cd5f5ace51f Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 5 Dec 2023 14:26:54 -0500 Subject: 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. --- test cases/failing build/1 vala c werror/meson.build | 10 ---------- test cases/failing build/1 vala c werror/prog.vala | 7 ------- test cases/failing build/1 vala c werror/unused-var.c | 8 -------- test cases/vala/5 target glib/meson.build | 4 ---- 4 files changed, 29 deletions(-) delete mode 100644 test cases/failing build/1 vala c werror/meson.build delete mode 100644 test cases/failing build/1 vala c werror/prog.vala delete mode 100644 test cases/failing build/1 vala c werror/unused-var.c (limited to 'test cases') diff --git a/test cases/failing build/1 vala c werror/meson.build b/test cases/failing build/1 vala c werror/meson.build deleted file mode 100644 index 736d7aa..0000000 --- a/test cases/failing build/1 vala c werror/meson.build +++ /dev/null @@ -1,10 +0,0 @@ -project('valatest', 'c', default_options : 'werror=true') - -if find_program('valac', required : false).found() - add_languages('vala') - valadeps = [dependency('glib-2.0'), dependency('gobject-2.0')] - # Must fail due to -Werror and unused variable in C file - executable('valaprog', 'prog.vala', 'unused-var.c', dependencies : valadeps) -else - executable('failprog', 'unused-var.c') -endif diff --git a/test cases/failing build/1 vala c werror/prog.vala b/test cases/failing build/1 vala c werror/prog.vala deleted file mode 100644 index 638e776..0000000 --- a/test cases/failing build/1 vala c werror/prog.vala +++ /dev/null @@ -1,7 +0,0 @@ -class MainProg : GLib.Object { - - public static int main(string[] args) { - stdout.printf("Vala is working.\n"); - return 0; - } -} diff --git a/test cases/failing build/1 vala c werror/unused-var.c b/test cases/failing build/1 vala c werror/unused-var.c deleted file mode 100644 index 6b85078..0000000 --- a/test cases/failing build/1 vala c werror/unused-var.c +++ /dev/null @@ -1,8 +0,0 @@ -#warning "something" - -int -somelib(void) -{ - int unused_var; - return 33; -} diff --git a/test cases/vala/5 target glib/meson.build b/test cases/vala/5 target glib/meson.build index f285d9f..089bb3c 100644 --- a/test cases/vala/5 target glib/meson.build +++ b/test cases/vala/5 target glib/meson.build @@ -1,9 +1,5 @@ project('valatest', 'vala', 'c') -if not meson.is_unity() - add_global_arguments('-Werror', language : 'c') -endif - valadeps = [dependency('glib-2.0', version : '>=2.32'), dependency('gobject-2.0')] e = executable('valaprog', 'GLib.Thread.vala', 'retcode.c', dependencies : valadeps) -- cgit v1.1