source: mainline/meson/part/compiler_args/meson.build@ 5e109e1

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

Fix —gc-sections with current Meson

Meson started adding —fatal-warnings to its argument checking
invocation, which means it now incorrectly establishes all
linker options to be unsupported. Fixed by not using the detection
functionality.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[c21d4d6]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
[200b211]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(
[18969ce]41 '-Wl,--gc-sections',
42 '-Wl,--warn-common',
[200b211]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 '-Werror-implicit-function-declaration',
63 '-Wwrite-strings',
64 '-Wunknown-pragmas',
65
66 '-Wno-unused-parameter',
67
68 '-pipe',
69
70 '-ffunction-sections',
71 '-fno-common',
72 '-fdebug-prefix-map=' + meson.source_root() + '=.',
73]
74
75if cc.get_id() != 'clang'
76 # Clang's own headers emit macro redefinition warnings.
77 extra_common_flags += '-Wsystem-headers'
78endif
79
80if UARCH != 'ia64'
81 extra_common_flags += [ '-fvar-tracking-assignments' ]
82endif
83
84if CONFIG_DEBUG
85 extra_common_flags += [ '-Werror' ]
86endif
87
88if CONFIG_LINE_DEBUG
89 extra_common_flags += [ '-gdwarf-4', '-g3' ]
90endif
91
92extra_cflags = extra_common_flags + [
93 '-Wmissing-prototypes',
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 '-frtti',
113]
114
115w_flags = {
116 'c': extra_cflags,
117 'cpp': extra_cppflags,
118}
119
120# TODO: To remove noise in Meson output, we may want to cut down on
121# the explicitly checked flags and just enable those supported by
122# both gcc and clang unconditionally.
123
124# Process flags. Only sets those that compiler supports.
125foreach lang : [ 'c', 'cpp' ]
126 extra_cflags = meson.get_compiler(lang).get_supported_arguments(w_flags.get(lang))
127 add_project_arguments(extra_cflags, language : [ lang ])
128 add_project_link_arguments(extra_cflags, language : [ lang ])
129endforeach
Note: See TracBrowser for help on using the repository browser.