Use higher optimization level for building extensions

O3 on gcc/clang and O2 on MSVC
Fixes #2145 (Add -O3 to extension compile flags)
This commit is contained in:
Kovid Goyal 2023-12-29 09:37:07 +05:30
parent 2838d7382c
commit 9448c42a64
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -192,7 +192,7 @@ is_macos_universal_build = ismacos and 'universal2' in sysconfig.get_platform()
def basic_windows_flags(debug=False): def basic_windows_flags(debug=False):
cflags = '/c /nologo /W3 /EHsc /utf-8'.split() cflags = '/c /nologo /W3 /EHsc /O2 /utf-8'.split()
cflags.append('/Zi' if debug else '/DNDEBUG') cflags.append('/Zi' if debug else '/DNDEBUG')
suffix = ('d' if debug else '') suffix = ('d' if debug else '')
cflags.append('/MD' + suffix) cflags.append('/MD' + suffix)
@ -261,7 +261,7 @@ def init_env(debug=False, sanitize=False, compiling_for='native'):
cxx = os.environ.get('CXX', 'g++') cxx = os.environ.get('CXX', 'g++')
debug = '-ggdb' if debug else '' debug = '-ggdb' if debug else ''
cflags = os.environ.get('OVERRIDE_CFLAGS', cflags = os.environ.get('OVERRIDE_CFLAGS',
f'-Wall -DNDEBUG {debug} -fno-strict-aliasing -pipe') f'-Wall -DNDEBUG {debug} -fno-strict-aliasing -pipe -O3')
cflags = shlex.split(cflags) + ['-fPIC'] cflags = shlex.split(cflags) + ['-fPIC']
ldflags = os.environ.get('OVERRIDE_LDFLAGS', '-Wall') ldflags = os.environ.get('OVERRIDE_LDFLAGS', '-Wall')
ldflags = shlex.split(ldflags) ldflags = shlex.split(ldflags)