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

ticket/834-toolchain-update
Last change on this file since 0557618 was 27bfbed, checked in by Vojtech Horky <vojtech.horky@…>, 3 years ago

C++: silence misleading indentation warnings

  • Property mode set to 100644
File size: 3.8 KB
Line 
1#
2# Copyright (c) 2019 Jiří Zárevúcky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29# This file sets the architecture-independent compiler flags used throughout
30# this repository.
31# For architecture-specific flags, see $srcroot/meson/cross/$arch.
32
33add_project_arguments(
34 # TODO: Remove from project arguments and only use where necessary.
35 # Any change in config forces everything to rebuild due to lack of granularity here.
36 '-imacros', meson.build_root() / 'config.h',
37 language : [ 'c' ],
38)
39
40add_project_link_arguments(
41 '-Wl,--gc-sections',
42 '-Wl,--warn-common',
43 '-Wl,--fatal-warnings',
44 language : [ 'c', 'cpp' ],
45)
46
47# TODO: enable more warnings
48# FIXME: -fno-builtin-strftime works around seemingly spurious format warning.
49# We should investigate what's going on there.
50
51extra_common_flags = [
52 '-O' + OPTIMIZATION,
53 '-fexec-charset=UTF-8',
54 '-finput-charset=UTF-8',
55
56 '-D_HELENOS_SOURCE',
57
58 '-Wa,--fatal-warnings',
59
60 '-Wall',
61 '-Wextra',
62 '-Wwrite-strings',
63 '-Wunknown-pragmas',
64
65 '-Wno-unused-parameter',
66
67 '-pipe',
68
69 '-ffunction-sections',
70 '-fno-common',
71 '-fdebug-prefix-map=' + meson.source_root() + '=.',
72]
73
74if cc.get_id() != 'clang'
75 # Clang's own headers emit macro redefinition warnings.
76 extra_common_flags += '-Wsystem-headers'
77endif
78
79if UARCH != 'ia64'
80 extra_common_flags += [ '-fvar-tracking-assignments' ]
81endif
82
83if CONFIG_DEBUG
84 extra_common_flags += [ '-Werror' ]
85endif
86
87if CONFIG_LINE_DEBUG
88 extra_common_flags += [ '-gdwarf-4', '-g3' ]
89endif
90
91extra_cflags = extra_common_flags + [
92 '-Wmissing-prototypes',
93 '-Werror-implicit-function-declaration',
94
95 '-Wno-missing-braces',
96 '-Wno-missing-field-initializers',
97 '-Wno-unused-command-line-argument',
98 '-Wno-unused-parameter',
99 '-Wno-typedef-redefinition',
100 '-Wno-clobbered',
101 '-Wno-nonnull-compare',
102
103 '-fno-builtin-strftime',
104]
105
106if CONFIG_UBSAN
107 extra_cflags += '-fsanitize=undefined'
108endif
109
110extra_cppflags = extra_common_flags + [
111 '-fno-exceptions',
112 '-Wno-misleading-indentation',
113 '-frtti',
114]
115
116w_flags = {
117 'c': extra_cflags,
118 'cpp': extra_cppflags,
119}
120
121# TODO: To remove noise in Meson output, we may want to cut down on
122# the explicitly checked flags and just enable those supported by
123# both gcc and clang unconditionally.
124
125# Process flags. Only sets those that compiler supports.
126foreach lang : [ 'c', 'cpp' ]
127 extra_cflags = meson.get_compiler(lang).get_supported_arguments(w_flags.get(lang))
128 add_project_arguments(extra_cflags, language : [ lang ])
129 add_project_link_arguments(extra_cflags, language : [ lang ])
130endforeach
Note: See TracBrowser for help on using the repository browser.