Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 1 | import platform |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 2 | from waflib import Configure, Logs, Utils |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 3 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 4 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 5 | def options(opt): |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 6 | opt.add_option('--debug', '--with-debug', action='store_true', default=False, |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 7 | help='Compile in debugging mode with minimal optimizations (-Og)') |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 8 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 9 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 10 | def configure(conf): |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 11 | conf.start_msg('Checking C++ compiler version') |
| 12 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 13 | cxx = conf.env.CXX_NAME # generic name of the compiler |
| 14 | ccver = tuple(int(i) for i in conf.env.CC_VERSION) |
| 15 | ccverstr = '.'.join(conf.env.CC_VERSION) |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 16 | errmsg = '' |
| 17 | warnmsg = '' |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 18 | if cxx == 'gcc': |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 19 | if ccver < (7, 4, 0): |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 20 | errmsg = ('The version of gcc you are using is too old.\n' |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 21 | 'The minimum supported gcc version is 9.3.') |
| 22 | elif ccver < (9, 3, 0): |
| 23 | warnmsg = ('Using a version of gcc older than 9.3 is not ' |
| 24 | 'officially supported and may result in build failures.') |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 25 | conf.flags = GccFlags() |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 26 | elif cxx == 'clang': |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 27 | if Utils.unversioned_sys_platform() == 'darwin': |
| 28 | if ccver < (10, 0, 0): |
| 29 | errmsg = ('The version of Xcode you are using is too old.\n' |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 30 | 'The minimum supported Xcode version is 12.4.') |
| 31 | elif ccver < (12, 0, 0): |
| 32 | warnmsg = ('Using a version of Xcode older than 12.4 is not ' |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 33 | 'officially supported and may result in build failures.') |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 34 | elif ccver < (7, 0, 0): |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 35 | errmsg = ('The version of clang you are using is too old.\n' |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 36 | 'The minimum supported clang version is 7.0.') |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 37 | conf.flags = ClangFlags() |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 38 | else: |
Davide Pesavento | ede5963 | 2022-08-26 20:35:44 -0400 | [diff] [blame] | 39 | warnmsg = f'{cxx} compiler is unsupported' |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 40 | conf.flags = CompilerFlags() |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 41 | |
| 42 | if errmsg: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 43 | conf.end_msg(ccverstr, color='RED') |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 44 | conf.fatal(errmsg) |
| 45 | elif warnmsg: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 46 | conf.end_msg(ccverstr, color='YELLOW') |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 47 | Logs.warn('WARNING: ' + warnmsg) |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 48 | else: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 49 | conf.end_msg(ccverstr) |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 50 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 51 | conf.areCustomCxxflagsPresent = len(conf.env.CXXFLAGS) > 0 |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 52 | |
Davide Pesavento | a08dc3f | 2018-05-24 00:40:28 -0400 | [diff] [blame] | 53 | # General flags are always applied (e.g., selecting C++ language standard) |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 54 | generalFlags = conf.flags.getGeneralFlags(conf) |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 55 | conf.add_supported_cxxflags(generalFlags['CXXFLAGS']) |
| 56 | conf.add_supported_linkflags(generalFlags['LINKFLAGS']) |
| 57 | conf.env.DEFINES += generalFlags['DEFINES'] |
| 58 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 59 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 60 | @Configure.conf |
| 61 | def check_compiler_flags(conf): |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 62 | # Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the |
| 63 | # corresponding environment variables are not set. |
| 64 | # DEFINES are always applied. |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 65 | if conf.options.debug: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 66 | extraFlags = conf.flags.getDebugFlags(conf) |
| 67 | if conf.areCustomCxxflagsPresent: |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 68 | missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS] |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 69 | if missingFlags: |
| 70 | Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"' |
| 71 | % ' '.join(conf.env.CXXFLAGS)) |
| 72 | Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags)) |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 73 | else: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 74 | extraFlags = conf.flags.getOptimizedFlags(conf) |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 76 | if not conf.areCustomCxxflagsPresent: |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 77 | conf.add_supported_cxxflags(extraFlags['CXXFLAGS']) |
| 78 | conf.add_supported_linkflags(extraFlags['LINKFLAGS']) |
| 79 | |
| 80 | conf.env.DEFINES += extraFlags['DEFINES'] |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 81 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 82 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 83 | @Configure.conf |
| 84 | def add_supported_cxxflags(self, cxxflags): |
| 85 | """ |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 86 | Check which cxxflags are supported by the active compiler and add them to env.CXXFLAGS variable. |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 87 | """ |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 88 | if len(cxxflags) == 0: |
| 89 | return |
| 90 | |
| 91 | self.start_msg('Checking supported CXXFLAGS') |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 92 | |
| 93 | supportedFlags = [] |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 94 | for flags in cxxflags: |
| 95 | flags = Utils.to_list(flags) |
| 96 | if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False): |
| 97 | supportedFlags += flags |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 98 | |
| 99 | self.end_msg(' '.join(supportedFlags)) |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 100 | self.env.prepend_value('CXXFLAGS', supportedFlags) |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 101 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 102 | |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 103 | @Configure.conf |
| 104 | def add_supported_linkflags(self, linkflags): |
| 105 | """ |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 106 | Check which linkflags are supported by the active compiler and add them to env.LINKFLAGS variable. |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 107 | """ |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 108 | if len(linkflags) == 0: |
| 109 | return |
| 110 | |
| 111 | self.start_msg('Checking supported LINKFLAGS') |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 112 | |
| 113 | supportedFlags = [] |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 114 | for flags in linkflags: |
| 115 | flags = Utils.to_list(flags) |
| 116 | if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False): |
| 117 | supportedFlags += flags |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 118 | |
| 119 | self.end_msg(' '.join(supportedFlags)) |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 120 | self.env.prepend_value('LINKFLAGS', supportedFlags) |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 121 | |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 122 | |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 123 | class CompilerFlags: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 124 | def getCompilerVersion(self, conf): |
| 125 | return tuple(int(i) for i in conf.env.CC_VERSION) |
| 126 | |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 127 | def getGeneralFlags(self, conf): |
| 128 | """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed""" |
Davide Pesavento | 5a1d77a | 2024-03-13 19:24:11 -0400 | [diff] [blame] | 129 | return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []} |
| 130 | |
| 131 | def getDebugFlags(self, conf): |
| 132 | """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode""" |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 133 | return { |
| 134 | 'CXXFLAGS': [], |
| 135 | 'LINKFLAGS': [], |
| 136 | 'DEFINES': ['BOOST_ASIO_NO_DEPRECATED', 'BOOST_FILESYSTEM_NO_DEPRECATED'], |
| 137 | } |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 138 | |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 139 | def getOptimizedFlags(self, conf): |
| 140 | """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode""" |
| 141 | return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']} |
| 142 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 143 | |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 144 | class GccClangCommonFlags(CompilerFlags): |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 145 | """ |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 146 | This class defines common flags that work for both gcc and clang compilers. |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 147 | """ |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 148 | |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 149 | def getGeneralFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 150 | flags = super().getGeneralFlags(conf) |
Davide Pesavento | c1d0e8e | 2022-06-15 14:26:02 -0400 | [diff] [blame] | 151 | flags['CXXFLAGS'] += ['-std=c++17'] |
Davide Pesavento | 65ee992 | 2022-11-16 00:21:43 -0500 | [diff] [blame] | 152 | if Utils.unversioned_sys_platform() != 'darwin': |
Davide Pesavento | e556991 | 2019-01-29 19:39:06 -0500 | [diff] [blame] | 153 | flags['LINKFLAGS'] += ['-fuse-ld=lld'] |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 154 | return flags |
| 155 | |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 156 | __cxxFlags = [ |
| 157 | '-fdiagnostics-color', |
| 158 | '-Wall', |
| 159 | '-Wextra', |
| 160 | '-Wpedantic', |
| 161 | '-Wenum-conversion', |
| 162 | '-Wextra-semi', |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 163 | '-Wno-unused-parameter', |
| 164 | ] |
| 165 | __linkFlags = ['-Wl,-O1'] |
| 166 | |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 167 | def getDebugFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 168 | flags = super().getDebugFlags(conf) |
| 169 | flags['CXXFLAGS'] += ['-Og', '-g'] + self.__cxxFlags + [ |
| 170 | '-Werror', |
| 171 | '-Wno-error=deprecated-declarations', # Bug #3795 |
| 172 | '-Wno-error=maybe-uninitialized', # Bug #1615 |
| 173 | ] |
| 174 | flags['LINKFLAGS'] += self.__linkFlags |
Davide Pesavento | da43c61 | 2024-01-19 16:44:25 -0500 | [diff] [blame] | 175 | # Enable assertions in libstdc++ |
| 176 | # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html |
| 177 | flags['DEFINES'] += ['_GLIBCXX_ASSERTIONS=1'] |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 178 | return flags |
| 179 | |
| 180 | def getOptimizedFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 181 | flags = super().getOptimizedFlags(conf) |
| 182 | flags['CXXFLAGS'] += ['-O2', '-g1'] + self.__cxxFlags |
| 183 | flags['LINKFLAGS'] += self.__linkFlags |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 184 | return flags |
| 185 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 186 | |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 187 | class GccFlags(GccClangCommonFlags): |
| 188 | __cxxFlags = [ |
| 189 | '-Wcatch-value=2', |
| 190 | '-Wcomma-subscript', # enabled by default in C++20 |
| 191 | '-Wduplicated-branches', |
| 192 | '-Wduplicated-cond', |
| 193 | '-Wlogical-op', |
| 194 | '-Wredundant-tags', |
| 195 | '-Wvolatile', # enabled by default in C++20 |
| 196 | ] |
| 197 | |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 198 | def getDebugFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 199 | flags = super().getDebugFlags(conf) |
| 200 | flags['CXXFLAGS'] += self.__cxxFlags |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 201 | if platform.machine() == 'armv7l': |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 202 | flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106 |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 203 | return flags |
| 204 | |
| 205 | def getOptimizedFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 206 | flags = super().getOptimizedFlags(conf) |
| 207 | flags['CXXFLAGS'] += self.__cxxFlags |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 208 | if platform.machine() == 'armv7l': |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 209 | flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106 |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 210 | return flags |
| 211 | |
Davide Pesavento | 5110a8a | 2023-08-20 21:42:11 -0400 | [diff] [blame] | 212 | |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 213 | class ClangFlags(GccClangCommonFlags): |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 214 | def getGeneralFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 215 | flags = super().getGeneralFlags(conf) |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 216 | if Utils.unversioned_sys_platform() == 'darwin': |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 217 | # Bug #4296 |
Davide Pesavento | ede5963 | 2022-08-26 20:35:44 -0400 | [diff] [blame] | 218 | brewdir = '/opt/homebrew' if platform.machine() == 'arm64' else '/usr/local' |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 219 | flags['CXXFLAGS'] += [ |
| 220 | ['-isystem', f'{brewdir}/include'], # for Homebrew |
| 221 | ['-isystem', '/opt/local/include'], # for MacPorts |
| 222 | ] |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 223 | elif Utils.unversioned_sys_platform() == 'freebsd': |
| 224 | # Bug #4790 |
| 225 | flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']] |
Davide Pesavento | da43c61 | 2024-01-19 16:44:25 -0500 | [diff] [blame] | 226 | if self.getCompilerVersion(conf) >= (18, 0, 0): |
| 227 | # Bug #5300 |
| 228 | flags['CXXFLAGS'] += ['-Wno-enum-constexpr-conversion'] |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 229 | return flags |
| 230 | |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 231 | __cxxFlags = [ |
| 232 | '-Wundefined-func-template', |
| 233 | '-Wno-unused-local-typedef', # Bugs #2657 and #3209 |
| 234 | ] |
| 235 | |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 236 | def getDebugFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 237 | flags = super().getDebugFlags(conf) |
| 238 | flags['CXXFLAGS'] += self.__cxxFlags |
Davide Pesavento | da43c61 | 2024-01-19 16:44:25 -0500 | [diff] [blame] | 239 | # Enable assertions in libc++ |
| 240 | if self.getCompilerVersion(conf) >= (18, 0, 0): |
| 241 | # https://libcxx.llvm.org/Hardening.html |
| 242 | flags['DEFINES'] += ['_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] |
| 243 | elif self.getCompilerVersion(conf) >= (15, 0, 0): |
| 244 | # https://releases.llvm.org/15.0.0/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode |
| 245 | flags['DEFINES'] += ['_LIBCPP_ENABLE_ASSERTIONS=1'] |
Davide Pesavento | 5a1d77a | 2024-03-13 19:24:11 -0400 | [diff] [blame] | 246 | # Tell libc++ to avoid including transitive headers |
| 247 | # https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html |
| 248 | flags['DEFINES'] += ['_LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1'] |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 249 | return flags |
| 250 | |
| 251 | def getOptimizedFlags(self, conf): |
Davide Pesavento | eed3209 | 2023-08-20 21:45:54 -0400 | [diff] [blame] | 252 | flags = super().getOptimizedFlags(conf) |
| 253 | flags['CXXFLAGS'] += self.__cxxFlags |
Alexander Afanasyev | f9f3910 | 2015-12-01 17:43:40 -0800 | [diff] [blame] | 254 | return flags |