mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-16 22:08:28 +01:00
Only use custom LTO flags when we actually want LTO
This considerably speeds up linking of release binaries with msvc when testing locally, when LTO is of no concern. Also properly override b_lto and b_vscrt in all cases for all targets, never leaving them to take default values.
This commit is contained in:
parent
a85bee5578
commit
9233b0036f
2
.github/build.sh
vendored
2
.github/build.sh
vendored
@ -308,7 +308,7 @@ if [[ "$BSH_HOST_PLATFORM-$BSH_HOST_LIBC" == "windows-mingw" ]]; then
|
||||
meson_configure+=$'\t'-Dwindows_icons=false
|
||||
fi
|
||||
if [[ $BSH_DEBUG_RELEASE-$BSH_STATIC_DYNAMIC == release-static ]]; then
|
||||
meson_configure+=$'\t'-Db_lto=true
|
||||
meson_configure+=$'\t'-Dlto=true
|
||||
fi
|
||||
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_ARCH == darwin-aarch64 ]]; then
|
||||
meson_configure+=$'\t'--cross-file=.github/macaa64-ghactions.ini
|
||||
|
33
meson.build
33
meson.build
@ -261,16 +261,23 @@ if not is_debug
|
||||
project_cpp_args += args_ccomp_opt
|
||||
endif
|
||||
|
||||
if not is_debug
|
||||
args_ccomp_lto = []
|
||||
if cpp_compiler.get_id() in [ 'clang', 'clang-cl' ]
|
||||
# use ThinLTO for Clang/LLVM
|
||||
args_ccomp_lto += [ '-flto=thin' ]
|
||||
elif cpp_compiler.get_argument_syntax() == 'msvc'
|
||||
args_ccomp_lto += [ '/GL' ]
|
||||
lto = get_option('lto')
|
||||
if cpp_compiler.get_argument_syntax() == 'msvc'
|
||||
if lto
|
||||
# apparently meson doesn't know how to tell msvc to use lto: b_lto doesn't even exist when using msvc
|
||||
# https://github.com/mesonbuild/meson/blob/1.4.2/mesonbuild/compilers/mixins/visualstudio.py#L113
|
||||
# so we do it ourselves
|
||||
project_cpp_args += [ '/GL' ]
|
||||
project_link_args += [ '/LTCG' ]
|
||||
endif
|
||||
project_cpp_args += args_ccomp_lto
|
||||
else
|
||||
target_options += [ 'b_lto=@0@'.format(lto) ]
|
||||
if lto
|
||||
if cpp_compiler.get_id() in [ 'clang', 'clang-cl' ]
|
||||
# use ThinLTO for Clang/LLVM
|
||||
project_cpp_args += [ '-flto=thin' ]
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if cpp_compiler.get_argument_syntax() == 'msvc'
|
||||
@ -358,10 +365,12 @@ if host_platform == 'windows'
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
if tpt_libs_static == 'static' and host_libc == 'msvc'
|
||||
target_options += [
|
||||
'b_vscrt=static_from_buildtype',
|
||||
]
|
||||
if host_libc == 'msvc'
|
||||
if tpt_libs_static == 'static'
|
||||
target_options += [ 'b_vscrt=static_from_buildtype' ]
|
||||
else
|
||||
target_options += [ 'b_vscrt=from_buildtype' ]
|
||||
endif
|
||||
endif
|
||||
foreach def : defs_ccomp_win
|
||||
if cpp_compiler.get_argument_syntax() == 'msvc'
|
||||
|
@ -5,6 +5,12 @@ option(
|
||||
value: 'none',
|
||||
description: 'Build statically using libraries present on the system (\'system\') or using prebuilt libraries official builds use (\'prebuilt\')'
|
||||
)
|
||||
option(
|
||||
'lto',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Link-time optimization, mostly a wrapper around the b_lto built-in option'
|
||||
)
|
||||
option(
|
||||
'beta',
|
||||
type: 'boolean',
|
||||
|
Loading…
x
Reference in New Issue
Block a user