mirror of
https://github.com/postgres/postgres.git
synced 2025-10-15 05:46:52 +03:00
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
This commit is contained in:
85
meson.build
85
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
|
||||
|
Reference in New Issue
Block a user