Merge pull request #28402 from Valentactive/add-thinlto-support-x11
Add option to use ThinLTO
This commit is contained in:
commit
7e65a11bcf
1 changed files with 12 additions and 3 deletions
|
@ -59,6 +59,7 @@ def get_opts():
|
||||||
return [
|
return [
|
||||||
BoolVariable('use_llvm', 'Use the LLVM compiler', False),
|
BoolVariable('use_llvm', 'Use the LLVM compiler', False),
|
||||||
BoolVariable('use_lld', 'Use the LLD linker', 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_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_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False),
|
||||||
BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False),
|
BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False),
|
||||||
|
@ -136,6 +137,9 @@ def configure(env):
|
||||||
if env['use_lld']:
|
if env['use_lld']:
|
||||||
if env['use_llvm']:
|
if env['use_llvm']:
|
||||||
env.Append(LINKFLAGS=['-fuse-ld=lld'])
|
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:
|
else:
|
||||||
print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.")
|
print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.")
|
||||||
sys.exit(255)
|
sys.exit(255)
|
||||||
|
@ -156,12 +160,17 @@ def configure(env):
|
||||||
env.Append(LINKFLAGS=['-fsanitize=leak'])
|
env.Append(LINKFLAGS=['-fsanitize=leak'])
|
||||||
|
|
||||||
if env['use_lto']:
|
if env['use_lto']:
|
||||||
env.Append(CCFLAGS=['-flto'])
|
|
||||||
|
|
||||||
if not env['use_llvm'] and env.GetOption("num_jobs") > 1:
|
if not env['use_llvm'] and env.GetOption("num_jobs") > 1:
|
||||||
|
env.Append(CCFLAGS=['-flto'])
|
||||||
env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
|
env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
|
||||||
else:
|
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']:
|
if not env['use_llvm']:
|
||||||
env['RANLIB'] = 'gcc-ranlib'
|
env['RANLIB'] = 'gcc-ranlib'
|
||||||
env['AR'] = 'gcc-ar'
|
env['AR'] = 'gcc-ar'
|
||||||
|
|
Loading…
Add table
Reference in a new issue