From 3f26aa32f2f9a17dd7fdf1a22321be02a6e63374 Mon Sep 17 00:00:00 2001 From: Lyude Paul Date: Wed, 24 Apr 2019 14:48:35 -0400 Subject: meson: Don't allow building with NDEBUG, ever Following some discussion and confusion around whether or not assert() should be used, it seems the decision has come to "yes, sometimes". To quote Petri Latvala on the appropriate points to use assert() in lib/: However, it's the thought that matters, and this is slightly going off on a tangent. Those uses of assert in lib/ are for places where 1) something is fatally wrong and we need to drop everything and stop executing 2) cannot use igt_assert for it. That's for places where we can say "you tried testing your kernel but it has a bug". The lib/ asserts are for "IGT has a bug", or in a couple of cases, "your IGT setup has a bug". While we did come to the conclusion that we should possibly consider introducing a new API to check for bugs with igt (and prevent further testing if any are found), until then let's at least make sure that assert() always works where we expect it. So, accomplish this by raising an error if b_ndebug isn't set to 'false'. Additionally, run the compile check in lib/check-ndebug.h to make sure that the user does not have -DNDEBUG set in their CFLAGS, c_args options, etc. Reviewed-by: Petri Latvala Signed-off-by: Lyude Paul --- meson.build | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 3d466d52..8196ab63 100644 --- a/meson.build +++ b/meson.build @@ -3,12 +3,22 @@ project('igt-gpu-tools', 'c', default_options: [ 'warning_level=2', 'c_std=gnu11', + 'b_ndebug=false', ], license : 'MIT', meson_version : '>=0.46.0') +if get_option('b_ndebug') != 'false' + error('Building without -Db_ndebug=false is not supported') +endif + cc = meson.get_compiler('c') +# Also make sure that the user doesn't have -DNDEBUG defined in their config +if not cc.compiles(files('lib/check-ndebug.h'), args: get_option('c_args')) + error('Building with NDEBUG defined is not supported') +endif + cc_args = [ '-Wbad-function-cast', '-Wdeclaration-after-statement', -- cgit v1.2.3