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

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

Add copyright headers for new files

Most are a copy of the headers that were present in original Makefiles.

  • 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 cc.get_supported_link_arguments([
42 '-Wl,--gc-sections',
43 '-Wl,--warn-common',
44 ]),
45 '-Wl,--fatal-warnings',
46 language : [ 'c', 'cpp' ],
47)
48
49# TODO: enable more warnings
50# FIXME: -fno-builtin-strftime works around seemingly spurious format warning.
51# We should investigate what's going on there.
52
53extra_common_flags = [
54 '-O' + OPTIMIZATION,
55 '-fexec-charset=UTF-8',
56 '-finput-charset=UTF-8',
57
58 '-D_HELENOS_SOURCE',
59
60 '-Wa,--fatal-warnings',
61
62 '-Wall',
63 '-Wextra',
64 '-Werror-implicit-function-declaration',
65 '-Wwrite-strings',
66 '-Wunknown-pragmas',
67
68 '-Wno-unused-parameter',
69
70 '-pipe',
71
72 '-ffunction-sections',
73 '-fno-common',
74 '-fdebug-prefix-map=' + meson.source_root() + '=.',
75]
76
77if cc.get_id() != 'clang'
78 # Clang's own headers emit macro redefinition warnings.
79 extra_common_flags += '-Wsystem-headers'
80endif
81
82if UARCH != 'ia64'
83 extra_common_flags += [ '-fvar-tracking-assignments' ]
84endif
85
86if CONFIG_DEBUG
87 extra_common_flags += [ '-Werror' ]
88endif
89
90if CONFIG_LINE_DEBUG
91 extra_common_flags += [ '-gdwarf-4', '-g3' ]
92endif
93
94extra_cflags = extra_common_flags + [
95 '-Wmissing-prototypes',
96
97 '-Wno-missing-braces',
98 '-Wno-missing-field-initializers',
99 '-Wno-unused-command-line-argument',
100 '-Wno-unused-parameter',
101 '-Wno-typedef-redefinition',
102 '-Wno-clobbered',
103 '-Wno-nonnull-compare',
104
105 '-fno-builtin-strftime',
106]
107
108if CONFIG_UBSAN
109 extra_cflags += '-fsanitize=undefined'
110endif
111
112extra_cppflags = extra_common_flags + [
113 '-fno-exceptions',
114 '-frtti',
115]
116
117w_flags = {
118 'c': extra_cflags,
119 'cpp': extra_cppflags,
120}
121
122# TODO: To remove noise in Meson output, we may want to cut down on
123# the explicitly checked flags and just enable those supported by
124# both gcc and clang unconditionally.
125
126# Process flags. Only sets those that compiler supports.
127foreach lang : [ 'c', 'cpp' ]
128 extra_cflags = meson.get_compiler(lang).get_supported_arguments(w_flags.get(lang))
129 add_project_arguments(extra_cflags, language : [ lang ])
130 add_project_link_arguments(extra_cflags, language : [ lang ])
131endforeach
Note: See TracBrowser for help on using the repository browser.