From a590cfde0cf719c637b75e4784be0c0ae60e3b1f Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 12 Jul 2022 15:22:30 +0200 Subject: compilers: Add optimization=plain option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0` to pass `-O0` to the compiler. This change is reasonable by itself but unfortunately, it breaks `buildtype=plain`, which promises that “no extra build flags are used”. `buildtype=plain` is important for distros like NixOS, which manage compiler flags for optimization and hardening themselves. Let’s introduce a new optimization level that does nothing and set it as the default for `buildtype=plain`. --- mesonbuild/backend/xcodebackend.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mesonbuild/backend/xcodebackend.py') diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 0d8bafb..9e101ce 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -52,7 +52,8 @@ LANGNAMEMAP = {'c': 'C', 'objcpp': 'OBJCPLUSPLUS', 'swift': 'SWIFT_' } -OPT2XCODEOPT = {'0': '0', +OPT2XCODEOPT = {'plain': None, + '0': '0', 'g': '0', '1': '1', '2': '2', @@ -1561,7 +1562,9 @@ class XCodeBackend(backends.Backend): settings_dict.add_item('EXECUTABLE_SUFFIX', suffix) settings_dict.add_item('GCC_GENERATE_DEBUGGING_SYMBOLS', BOOL2XCODEBOOL[target.get_option(OptionKey('debug'))]) settings_dict.add_item('GCC_INLINES_ARE_PRIVATE_EXTERN', 'NO') - settings_dict.add_item('GCC_OPTIMIZATION_LEVEL', OPT2XCODEOPT[target.get_option(OptionKey('optimization'))]) + opt_flag = OPT2XCODEOPT[target.get_option(OptionKey('optimization'))] + if opt_flag is not None: + settings_dict.add_item('GCC_OPTIMIZATION_LEVEL', opt_flag) if target.has_pch: # Xcode uses GCC_PREFIX_HEADER which only allows one file per target/executable. Precompiling various header files and # applying a particular pch to each source file will require custom scripts (as a build phase) and build flags per each -- cgit v1.1