configure: add LTO optarg

This allows users to specify an argument such as './configure
--enable-lto=thin' to use ThinLTO with Clang. The old functionality with
'./configure --enable-lto' is preserved.

Signed-off-by: J. Dekker <jdek@itanimul.li>
This commit is contained in:
J. Dekker 2023-03-23 14:38:51 +01:00
parent ee8fc4f355
commit 4f55568217
1 changed files with 11 additions and 9 deletions

20
configure vendored
View File

@ -412,7 +412,7 @@ Toolchain options:
--build-suffix=SUFFIX library name suffix [] --build-suffix=SUFFIX library name suffix []
--enable-pic build position-independent code --enable-pic build position-independent code
--enable-thumb compile for Thumb instruction set --enable-thumb compile for Thumb instruction set
--enable-lto use link-time optimization --enable-lto[=arg] use link-time optimization
--env="ENV=override" override the environment variables --env="ENV=override" override the environment variables
Advanced options (experts only): Advanced options (experts only):
@ -2524,7 +2524,6 @@ CMDLINE_SELECT="
debug debug
extra_warnings extra_warnings
logging logging
lto
optimizations optimizations
rpath rpath
stripping stripping
@ -4170,6 +4169,9 @@ for opt do
--enable-sdl) --enable-sdl)
enable sdl2 enable sdl2
;; ;;
--enable-lto*)
lto=-f${opt#--enable-}
;;
--enable-*=*|--disable-*=*) --enable-*=*|--disable-*=*)
eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/') eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt" is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
@ -4639,7 +4641,7 @@ icl_flags(){
# on Windows, does enable remarks so disable them here. # on Windows, does enable remarks so disable them here.
-Wall) echo $flag -Qdiag-disable:remark ;; -Wall) echo $flag -Qdiag-disable:remark ;;
-std=c99) echo -Qstd=c99 ;; -std=c99) echo -Qstd=c99 ;;
-flto) echo -ipo ;; -flto*) echo -ipo ;;
esac esac
done done
} }
@ -4647,7 +4649,7 @@ icl_flags(){
icc_flags(){ icc_flags(){
for flag; do for flag; do
case $flag in case $flag in
-flto) echo -ipo ;; -flto*) echo -ipo ;;
*) echo $flag ;; *) echo $flag ;;
esac esac
done done
@ -7182,17 +7184,17 @@ fi
check_optflags(){ check_optflags(){
check_cflags "$@" check_cflags "$@"
enabled lto && check_ldflags "$@" [ -n "$lto" ] && check_ldflags "$@"
} }
check_optflags $optflags check_optflags $optflags
check_optflags -fno-math-errno check_optflags -fno-math-errno
check_optflags -fno-signed-zeros check_optflags -fno-signed-zeros
if enabled lto; then if [ -n "$lto" ]; then
test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker" test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
check_cflags -flto check_cflags $lto
check_ldflags -flto $cpuflags check_ldflags $lto $cpuflags
disable inline_asm_direct_symbol_refs disable inline_asm_direct_symbol_refs
fi fi
@ -7223,7 +7225,7 @@ if enabled icc; then
# icc 11.0 and 11.1 work with ebp_available, but don't pass the test # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
enable ebp_available enable ebp_available
# The test above does not test linking # The test above does not test linking
enabled lto && disable symver_asm_label [ -n "$lto" ] && disable symver_asm_label
if enabled x86_32; then if enabled x86_32; then
icc_version=$($cc -dumpversion) icc_version=$($cc -dumpversion)
test ${icc_version%%.*} -ge 11 && test ${icc_version%%.*} -ge 11 &&