diff options
author | Michele Valente <valentactive@gmail.com> | 2019-04-24 15:50:48 +0200 |
---|---|---|
committer | Michele Valente <valentactive@gmail.com> | 2019-04-25 19:20:12 +0200 |
commit | 51f9042a5b9d5a11e0a4b54a1a277d63e43a316e (patch) | |
tree | cb3cbb9a407a8b62ef92f589410ef48c6e369e5c /platform | |
parent | e1d16e722ec9742c3f92d20dc433d540339c36e6 (diff) |
add option to use ThinLTO
This adds ThinLTO support when using Clang and the LLD Linker, it's
turned off by
default.
For now only support for Linux added as ThinLTO support on other
platforms may still be buggy.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/x11/detect.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 94a87a7c90..ac1b4c8f58 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -59,6 +59,7 @@ def get_opts(): return [ BoolVariable('use_llvm', 'Use the LLVM compiler', False), BoolVariable('use_lld', 'Use the LLD linker', False), + BoolVariable('use_thinlto', 'Use ThinLTO', False), BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically for better portability', False), BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False), BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False), @@ -134,6 +135,9 @@ def configure(env): if env['use_lld']: if env['use_llvm']: env.Append(LINKFLAGS=['-fuse-ld=lld']) + if env['use_thinlto']: + # A convenience so you don't need to write use_lto too when using SCons + env['use_lto'] = True else: print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.") sys.exit(255) @@ -154,12 +158,17 @@ def configure(env): env.Append(LINKFLAGS=['-fsanitize=leak']) if env['use_lto']: - env.Append(CCFLAGS=['-flto']) - if not env['use_llvm'] and env.GetOption("num_jobs") > 1: + env.Append(CCFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))]) else: - env.Append(LINKFLAGS=['-flto']) + if env['use_lld'] and env['use_thinlto']: + env.Append(CCFLAGS=['-flto=thin']) + env.Append(LINKFLAGS=['-flto=thin']) + else: + env.Append(CCFLAGS=['-flto']) + env.Append(LINKFLAGS=['-flto']) + if not env['use_llvm']: env['RANLIB'] = 'gcc-ranlib' env['AR'] = 'gcc-ar' |