Use -Ofast on x11. Also introduced use_lto option.

debug_release doesn't turn off optimizations for release target now. Ensure that sanitizer options apply to both C and C++ files.

Built-in optimization/debug flags are prepended such that user-specified flags can override them.

Based on and around the discussion in PR #5194.
This commit is contained in:
Ferenc Arn 2017-01-25 12:40:54 -06:00
parent 1005a56e5a
commit 7a85d25218

View file

@ -61,6 +61,7 @@ def get_opts():
('use_static_cpp', 'link stdc++ statically', 'no'),
('use_sanitizer', 'Use llvm compiler sanitize address', 'no'),
('use_leak_sanitizer', 'Use llvm compiler sanitize memory leaks', 'no'),
('use_lto', 'Use link time optimization', 'no'),
('pulseaudio', 'Detect & Use pulseaudio', 'yes'),
('udev', 'Use udev for gamepad connection callbacks', 'no'),
('debug_release', 'Add debug symbols to release version', 'no'),
@ -97,12 +98,12 @@ def configure(env):
env.extra_suffix = ".llvm"
if (env["use_sanitizer"] == "yes"):
env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
if (env["use_leak_sanitizer"] == "yes"):
env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
@ -111,22 +112,28 @@ def configure(env):
# env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
# env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
if (env["target"] == "release"):
if (env["use_lto"] == "yes"):
env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto'])
env.Append(CCFLAGS=['-pipe'])
env.Append(LINKFLAGS=['-pipe'])
if (env["target"] == "release"):
env.Prepend(CCFLAGS=['-Ofast'])
if (env["debug_release"] == "yes"):
env.Append(CCFLAGS=['-g2'])
else:
env.Append(CCFLAGS=['-O3', '-ffast-math'])
env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "release_debug"):
env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
if (env["debug_release"] == "yes"):
env.Append(CCFLAGS=['-g2'])
env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "debug"):
env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env.Prepend(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env.ParseConfig('pkg-config x11 --cflags --libs')
env.ParseConfig('pkg-config xinerama --cflags --libs')