postgres.git / summary / log / commit / refs
commit 4a4038068bb29eff2516296fc842b88741625afd
Author: Peter Eisentraut <peter@eisentraut.org>
Date: Mon Aug 18 05:35:55 2025 +0000
meson: Move C99 test earlier
Move the test for compiler options for C99 earlier in meson.build,
before we make use of the compiler for other tests. That way, if any
command-line options are needed, subsequent tests will also use them.
This is at the moment a theoretical problem, but it seems better to
get this correct. It also matches the order in the Autoconf-based
build more closely.
Discussion: https://www.postgresql.org/message-id/flat/01a69441-af54-4822-891b-ca28e05b215a@eisentraut.org
meson.build | 85 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 42 insertions(+), 43 deletions(-)
diff --git a/meson.build b/meson.build
index 30e0edda3e7..a87eb913fff 100644
--- a/meson.build
+++ b/meson.build
@@ -550,6 +550,48 @@ dir_doc_extension = dir_doc / 'extension'
# used, they need to be added to test_c_args as well.
###############################################################
+# Do we need -std=c99 to compile C99 code? We don't want to add -std=c99
+# unnecessarily, because we optionally rely on newer features.
+c99_test = '''
+#include <stdbool.h>
+#include <complex.h>
+#include <tgmath.h>
+#include <inttypes.h>
+
+struct named_init_test {
+ int a;
+ int b;
+};
+
+extern void structfunc(struct named_init_test);
+
+int main(int argc, char **argv)
+{
+ struct named_init_test nit = {
+ .a = 3,
+ .b = 5,
+ };
+
+ for (int loop_var = 0; loop_var < 3; loop_var++)
+ {
+ nit.a += nit.b;
+ }
+
+ structfunc((struct named_init_test){1, 0});
+
+ return nit.a != 0;
+}
+'''
+
+if not cc.compiles(c99_test, name: 'c99')
+ if cc.compiles(c99_test, name: 'c99 with -std=c99', args: ['-std=c99'])
+ cflags += '-std=c99'
+ else
+ error('C compiler does not support C99')
+ endif
+endif
+
+
postgres_inc = [include_directories(postgres_inc_d)]
test_lib_d = postgres_lib_d
test_c_args = cppflags + cflags
@@ -1704,49 +1746,6 @@ endif
# Compiler tests
###############################################################
-# Do we need -std=c99 to compile C99 code? We don't want to add -std=c99
-# unnecessarily, because we optionally rely on newer features.
-c99_test = '''
-#include <stdbool.h>
-#include <complex.h>
-#include <tgmath.h>
-#include <inttypes.h>
-
-struct named_init_test {
- int a;
- int b;
-};
-
-extern void structfunc(struct named_init_test);
-
-int main(int argc, char **argv)
-{
- struct named_init_test nit = {
- .a = 3,
- .b = 5,
- };
-
- for (int loop_var = 0; loop_var < 3; loop_var++)
- {
- nit.a += nit.b;
- }
-
- structfunc((struct named_init_test){1, 0});
-
- return nit.a != 0;
-}
-'''
-
-if not cc.compiles(c99_test, name: 'c99', args: test_c_args)
- if cc.compiles(c99_test, name: 'c99 with -std=c99',
- args: test_c_args + ['-std=c99'])
- test_c_args += '-std=c99'
- cflags += '-std=c99'
- else
- error('C compiler does not support C99')
- endif
-endif
-
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
endif
[parent: ba3d93b2e806]