ltmain.sh: allow more flags at link-time

libtool defaults to filtering flags passed at link-time.

This brings the filtering in GCC's 'fork' of libtool into sync with
upstream libtool commit 22a7e547e9857fc94fe5bc7c921d9a4b49c09f8e.

In particular, this now allows some harmless diagnostic flags (especially
useful for things like -Werror=odr), more optimization flags, and some
Clang-specific options.

GCC's -flto documentation mentions:
> To use the link-time optimizer, -flto and optimization options should be
> specified at compile time and during the final link. It is recommended
> that you compile all the files participating in the same link with the
> same options and also specify those options at link time.

This allows compliance with that.

	* ltmain.sh (func_mode_link): Allow various flags through filter.
This commit is contained in:
Sam James 2024-08-14 04:09:39 +01:00
parent dfba4847f6
commit 71011d3cb1
No known key found for this signature in database
GPG Key ID: 738409F520DF9190

View File

@ -4968,19 +4968,41 @@ func_mode_link ()
arg="$func_quote_for_eval_result"
;;
# -64, -mips[0-9] enable 64-bit mode on the SGI compiler
# -r[0-9][0-9]* specifies the processor on the SGI compiler
# -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
# +DA*, +DD* enable 64-bit mode on the HP compiler
# -q* pass through compiler args for the IBM compiler
# -m*, -t[45]*, -txscale* pass through architecture-specific
# compiler args for GCC
# -F/path gives path to uninstalled frameworks, gcc on darwin
# -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
# @file GCC response files
# -tp=* Portland pgcc target processor selection
# Flags to be passed through unchanged, with rationale:
# -64, -mips[0-9] enable 64-bit mode for the SGI compiler
# -r[0-9][0-9]* specify processor for the SGI compiler
# -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
# +DA*, +DD* enable 64-bit mode for the HP compiler
# -q* compiler args for the IBM compiler
# -m*, -t[45]*, -txscale* architecture-specific flags for GCC
# -F/path path to uninstalled frameworks, gcc on darwin
# -p, -pg, --coverage, -fprofile-* profiling flags for GCC
# -fstack-protector* stack protector flags for GCC
# @file GCC response files
# -tp=* Portland pgcc target processor selection
# -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
# -specs=* GCC specs files
# -stdlib=* select c++ std lib with clang
# -fdiagnostics-color* simply affects output
# -frecord-gcc-switches used to verify flags were respected
# -fsanitize=* Clang/GCC memory and address sanitizer
# -fno-sanitize* Clang/GCC memory and address sanitizer
# -shared-libsan Link with shared sanitizer runtimes (Clang)
# -static-libsan Link with static sanitizer runtimes (Clang)
# -fuse-ld=* Linker select flags for GCC
# -rtlib=* select c runtime lib with clang
# --unwindlib=* select unwinder library with clang
# -f{file|debug|macro|profile}-prefix-map=* needed for lto linking
# -Wa,* Pass flags directly to the assembler
# -Werror, -Werror=* Report (specified) warnings as errors
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*)
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*| \
-O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*| \
-stdlib=*|-rtlib=*|--unwindlib=*| \
-specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \
-ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \
-fdiagnostics-color*|-frecord-gcc-switches| \
-fuse-ld=*|-Wa,*|-Werror|-Werror=*)
func_quote_for_eval "$arg"
arg="$func_quote_for_eval_result"
func_append compile_command " $arg"