source: mainline/meson/part/compiler_args/meson.build@ 6068476

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6068476 was 200b2113, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 6 years ago

Reorganize main meson.build script

I split most of it into separate subdirs, so that the overall organization
is easier to follow.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1# This file sets the architecture-independent compiler flags used throughout
2# this repository.
3# For architecture-specific flags, see $srcroot/meson/cross/$arch.
4
5add_project_arguments(
6 # TODO: Remove from project arguments and only use where necessary.
7 # Any change in config forces everything to rebuild due to lack of granularity here.
8 '-imacros', meson.build_root() / 'config.h',
9 language : [ 'c' ],
10)
11
12add_project_link_arguments(
13 cc.get_supported_link_arguments([
14 '-Wl,--gc-sections',
15 '-Wl,--warn-common',
16 ]),
17 '-Wl,--fatal-warnings',
18 language : [ 'c', 'cpp' ],
19)
20
21# TODO: enable more warnings
22# FIXME: -fno-builtin-strftime works around seemingly spurious format warning.
23# We should investigate what's going on there.
24
25extra_common_flags = [
26 '-O' + OPTIMIZATION,
27 '-fexec-charset=UTF-8',
28 '-finput-charset=UTF-8',
29
30 '-D_HELENOS_SOURCE',
31
32 '-Wa,--fatal-warnings',
33
34 '-Wall',
35 '-Wextra',
36 '-Werror-implicit-function-declaration',
37 '-Wwrite-strings',
38 '-Wunknown-pragmas',
39
40 '-Wno-unused-parameter',
41
42 '-pipe',
43
44 '-ffunction-sections',
45 '-fno-common',
46 '-fdebug-prefix-map=' + meson.source_root() + '=.',
47]
48
49if cc.get_id() != 'clang'
50 # Clang's own headers emit macro redefinition warnings.
51 extra_common_flags += '-Wsystem-headers'
52endif
53
54if UARCH != 'ia64'
55 extra_common_flags += [ '-fvar-tracking-assignments' ]
56endif
57
58if CONFIG_DEBUG
59 extra_common_flags += [ '-Werror' ]
60endif
61
62if CONFIG_LINE_DEBUG
63 extra_common_flags += [ '-gdwarf-4', '-g3' ]
64endif
65
66extra_cflags = extra_common_flags + [
67 '-Wmissing-prototypes',
68
69 '-Wno-missing-braces',
70 '-Wno-missing-field-initializers',
71 '-Wno-unused-command-line-argument',
72 '-Wno-unused-parameter',
73 '-Wno-typedef-redefinition',
74 '-Wno-clobbered',
75 '-Wno-nonnull-compare',
76
77 '-fno-builtin-strftime',
78]
79
80if CONFIG_UBSAN
81 extra_cflags += '-fsanitize=undefined'
82endif
83
84extra_cppflags = extra_common_flags + [
85 '-fno-exceptions',
86 '-frtti',
87]
88
89w_flags = {
90 'c': extra_cflags,
91 'cpp': extra_cppflags,
92}
93
94# TODO: To remove noise in Meson output, we may want to cut down on
95# the explicitly checked flags and just enable those supported by
96# both gcc and clang unconditionally.
97
98# Process flags. Only sets those that compiler supports.
99foreach lang : [ 'c', 'cpp' ]
100 extra_cflags = meson.get_compiler(lang).get_supported_arguments(w_flags.get(lang))
101 add_project_arguments(extra_cflags, language : [ lang ])
102 add_project_link_arguments(extra_cflags, language : [ lang ])
103endforeach
Note: See TracBrowser for help on using the repository browser.