add -fno-exceptions if cpp_eh=none is specified

pull/5330/head
nicole mazzuca 6 years ago committed by Jussi Pakkanen
parent 261878f438
commit 24d5c73b0a
  1. 8
      docs/markdown/Builtin-options.md
  2. 46
      mesonbuild/compilers/cpp.py
  3. 11
      test cases/common/91 default options/meson.build

@ -134,7 +134,7 @@ compiler being used:
| cpp_link_args| | free-form comma-separated list | C++ link arguments to use |
| cpp_std | none | none, c++98, c++03, c++11, c++14, c++17, <br/>c++1z, gnu++03, gnu++11, gnu++14, gnu++17, gnu++1z, <br/> vc++14, vc++17, vc++latest | C++ language standard to use |
| cpp_debugstl | false | true, false | C++ STL debug mode |
| cpp_eh | sc | none, a, s, sc | C++ exception handling type |
| cpp_eh | default | none, default, a, s, sc | C++ exception handling type |
| cpp_winlibs | see below | free-form comma-separated list | Standard Windows libs to link against |
The default values of `c_winlibs` and `cpp_winlibs` are in compiler-specific
@ -144,3 +144,9 @@ shell32, ole32, oleaut32, uuid, comdlg32, advapi32.
c_args, cpp_args, c_link_args, and cpp_link_args only affect native builds,
when cross compiling they will not be applied to binaries or libraries
targeting the host system, only those being run on the build system.
When using MSVC, `cpp_eh=none` will result in no exception flags being passed,
while the `cpp_eh=[value]` will result in `/EH[value]`.
Since *0.51.0* `cpp_eh=default` will result in `/EHsc` on MSVC. When using
gcc-style compilers, nothing is passed (allowing exceptions to work), while
`cpp_eh=none` passes `-fno-exceptions`.

@ -142,7 +142,11 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
def get_options(self):
opts = CPPCompiler.get_options(self)
opts.update({'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
'C++ exception handling type.',
['none', 'default'],
'default'),
'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a',
'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'],
'none')})
@ -153,6 +157,8 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
std = options['cpp_std']
if std.value != 'none':
args.append(self._find_best_cpp_std(std.value))
if options['cpp_eh'].value == 'none':
args.append('-fno-exceptions')
return args
def get_option_link_args(self, options):
@ -174,7 +180,11 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
def get_options(self):
opts = CPPCompiler.get_options(self)
opts.update({'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
'C++ exception handling type.',
['none', 'default'],
'default'),
'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17',
'gnu++98', 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17'],
'none')})
@ -185,6 +195,8 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
std = options['cpp_std']
if std.value != 'none':
args.append('-std=' + std.value)
if options['cpp_eh'].value == 'none':
args.append('-fno-exceptions')
return args
def get_option_link_args(self, options):
@ -203,7 +215,11 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
def get_options(self):
opts = CPPCompiler.get_options(self)
opts.update({'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
'C++ exception handling type.',
['none', 'default'],
'default'),
'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a',
'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'],
'none'),
@ -221,6 +237,8 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
std = options['cpp_std']
if std.value != 'none':
args.append(self._find_best_cpp_std(std.value))
if options['cpp_eh'].value == 'none':
args.append('-fno-exceptions')
if options['cpp_debugstl'].value:
args.append('-D_GLIBCXX_DEBUG=1')
return args
@ -251,7 +269,11 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler):
# It does not support c++/gnu++ 17 and 1z, but still does support 0x, 1y, and gnu++98.
def get_options(self):
opts = CPPCompiler.get_options(self)
opts.update({'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
'C++ exception handling type.',
['none', 'default'],
'default'),
'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none', 'c++98', 'c++03', 'c++0x', 'c++11', 'c++14', 'c++1y',
'gnu++98', 'gnu++03', 'gnu++0x', 'gnu++11', 'gnu++14', 'gnu++1y'],
'none'),
@ -297,7 +319,11 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
c_stds += ['c++17']
if version_compare(self.version, '>=17.0.0'):
g_stds += ['gnu++14']
opts.update({'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
'C++ exception handling type.',
['none', 'default'],
'default'),
'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none'] + c_stds + g_stds,
'none'),
'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
@ -314,6 +340,8 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
'gnu++03': 'gnu++98'
}
args.append('-std=' + remap_cpp03.get(std.value, std.value))
if options['cpp_eh'].value == 'none':
args.append('-fno-exceptions')
if options['cpp_debugstl'].value:
args.append('-D_GLIBCXX_DEBUG=1')
return args
@ -343,8 +371,8 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
opts = CPPCompiler.get_options(self)
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
'C++ exception handling type.',
['none', 'a', 's', 'sc'],
'sc'),
['none', 'a', 's', 'sc', 'default'],
'default'),
'cpp_std': coredata.UserComboOption('cpp_std',
'C++ language standard to use',
cpp_stds,
@ -358,7 +386,9 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
args = []
eh = options['cpp_eh']
if eh.value != 'none':
if eh.value == 'default':
args.append('/EHsc')
elif eh.value != 'none':
args.append('/EH' + eh.value)
vc_version_map = {

@ -8,13 +8,10 @@ project('default options', 'cpp', 'c', default_options : [
assert(get_option('buildtype') == 'debugoptimized', 'Build type default value wrong.')
if meson.get_compiler('cpp').get_argument_syntax() == 'msvc'
cpp_eh = get_option('cpp_eh')
assert(cpp_eh == 'none', 'MSVC eh value is "' + cpp_eh + '" instead of "none"')
else
cpp_std = get_option('cpp_std')
assert(cpp_std == 'c++11', 'C++ std value is "' + cpp_std + '" instead of c++11.')
endif
cpp_eh = get_option('cpp_eh')
assert(cpp_eh == 'none', 'EH value is "' + cpp_eh + '" instead of "none"')
cpp_std = get_option('cpp_std')
assert(cpp_std == 'c++11', 'C++ std value is "' + cpp_std + '" instead of c++11.')
w_level = get_option('warning_level')
assert(w_level == '3', 'warning level "' + w_level + '" instead of "3"')

Loading…
Cancel
Save