diff options
author | nicole mazzuca <mazzucan@outlook.com> | 2019-05-05 11:19:04 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-05-05 21:19:04 +0300 |
commit | 24d5c73b0a55b83bbc6120a322b16808ec1c1118 (patch) | |
tree | a362ba829599aafdeec7033173a20ca5fad622d6 | |
parent | 261878f438261585daa637e147c37dc60922afb1 (diff) | |
download | meson-24d5c73b0a55b83bbc6120a322b16808ec1c1118.zip meson-24d5c73b0a55b83bbc6120a322b16808ec1c1118.tar.gz meson-24d5c73b0a55b83bbc6120a322b16808ec1c1118.tar.bz2 |
add -fno-exceptions if cpp_eh=none is specified
-rw-r--r-- | docs/markdown/Builtin-options.md | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/cpp.py | 46 | ||||
-rw-r--r-- | test cases/common/91 default options/meson.build | 11 |
3 files changed, 49 insertions, 16 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md index d25d7ab..db3af64 100644 --- a/docs/markdown/Builtin-options.md +++ b/docs/markdown/Builtin-options.md @@ -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`. diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index e2bcaf0..a089a5b 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -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 = { diff --git a/test cases/common/91 default options/meson.build b/test cases/common/91 default options/meson.build index c4c72ef..4a9fc2f 100644 --- a/test cases/common/91 default options/meson.build +++ b/test cases/common/91 default options/meson.build @@ -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"') |