Skip to content
Snippets Groups Projects
Commit 7704d155 authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

build system: Add libtool patch to handle -Wl,--as-needed

parent b261fec0
No related tags found
1 merge request!30Add libtool patch to handle -Wl,--as-needed
Pipeline #73863 passed
This patch changes ltmain.sh to keep the relative order of the GNU ld library
options --as-needed/--no-as-needed and --whole-archive/--no-whole-archive on the
command line.
The patch was originally taken from the Debian dh-autoreconf project
(https://salsa.debian.org/debian/dh-autoreconf) and then combined with the
existing 03ltmain-ld-groups-patch.
To allow for multiple appearances of the options on the command line, the patch
was further extended following (some of) the recommendations in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=347650#65
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -5829,7 +5829,9 @@ func_mode_link ()
arg=$func_stripname_result
;;
- -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\))
+ -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\)| \
+ -Wl,--as-needed|-Wl,-as-needed|-Wl,--no-as-needed|-Wl,-no-as-needed| \
+ -Wl,--whole-archive|-Wl,-whole-archive|-Wl,--no-whole-archive|-Wl,-no-whole-archive)
func_append deplibs " $arg"
continue
;;
@@ -6465,7 +6467,9 @@ func_mode_link ()
alldeplibs=yes
continue
;;
- -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\))
+ -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\)| \
+ -Wl,--as-needed|-Wl,-as-needed|-Wl,--no-as-needed|-Wl,-no-as-needed| \
+ -Wl,--whole-archive|-Wl,-whole-archive|-Wl,--no-whole-archive|-Wl,-no-whole-archive)
if test "$linkmode,$pass" = "prog,link"; then
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
@@ -7240,6 +7244,10 @@ func_mode_link ()
func_stripname '-R' '' "$deplib"
func_add2xrpath "$func_stripname_result"
;;
+ -Wl,--as-needed|-Wl,-as-needed|-Wl,--no-as-needed|-Wl,-no-as-needed| \
+ -Wl,--whole-archive|-Wl,-whole-archive|-Wl,--no-whole-archive|-Wl,-no-whole-archive)
+ new_libs="$deplib $new_libs"
+ ;;
*)
# And here is the reason: when a library appears more
# than once as an explicit dependence of a library, or
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -7250,7 +7250,9 @@ func_mode_link ()
arg=$func_stripname_result
;;
- -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\))
+ -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\)| \
+ -Wl,--as-needed|-Wl,-as-needed|-Wl,--no-as-needed|-Wl,-no-as-needed| \
+ -Wl,--whole-archive|-Wl,-whole-archive|-Wl,--no-whole-archive|-Wl,-no-whole-archive)
func_append deplibs " $arg"
continue
;;
@@ -7911,7 +7913,9 @@ func_mode_link ()
alldeplibs=:
continue
;;
- -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\))
+ -Wl,--start-group|-Wl,--end-group|-Wl,-\(|-Wl,-\)| \
+ -Wl,--as-needed|-Wl,-as-needed|-Wl,--no-as-needed|-Wl,-no-as-needed| \
+ -Wl,--whole-archive|-Wl,-whole-archive|-Wl,--no-whole-archive|-Wl,-no-whole-archive)
if test "$linkmode,$pass" = "prog,link"; then
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
@@ -8684,6 +8688,10 @@ func_mode_link ()
func_stripname '-R' '' "$deplib"
func_add2xrpath "$func_stripname_result"
;;
+ -Wl,--as-needed|-Wl,-as-needed|-Wl,--no-as-needed|-Wl,-no-as-needed| \
+ -Wl,--whole-archive|-Wl,-whole-archive|-Wl,--no-whole-archive|-Wl,-no-whole-archive)
+ new_libs="$deplib $new_libs"
+ ;;
*)
# And here is the reason: when a library appears more
# than once as an explicit dependence of a library, or
......@@ -88,7 +88,8 @@ case "$libtoolversion" in
contrib/07ltmain-early-xcompile-patch/ltmain-early-xcompile-libtool-2.4.6.patch \
contrib/08ltmain-parallel-printf-patch/ltmain-parallel-printf-libtool-2.4.6.patch \
contrib/09debian-no-overlink-patch/deplib_binary.patch \
contrib/09debian-no-overlink-patch/link_all_deplibs.patch)
contrib/09debian-no-overlink-patch/link_all_deplibs.patch \
contrib/10ltmain-ld-positional-wl-patch/ltmain-ld-positional-wl-libtool-2.4.6.patch)
;;
(2.4.2)
patches=(contrib/00nagfor-libtool-patch/nagfor-libtool-2.4.2.patch \
......@@ -100,7 +101,8 @@ case "$libtoolversion" in
contrib/06ltmain_nag_pthread-patch/ltmain_nag_pthread-libtool-2.4.2.patch \
contrib/08ltmain-parallel-printf-patch/ltmain-parallel-printf-libtool-2.4.2.patch \
contrib/09debian-no-overlink-patch/deplib_binary-libtool-2.4.2.patch \
contrib/09debian-no-overlink-patch/link_all_deplibs-libtool-2.4.2.patch)
contrib/09debian-no-overlink-patch/link_all_deplibs-libtool-2.4.2.patch \
contrib/10ltmain-ld-positional-wl-patch/ltmain-ld-positional-wl-libtool-2.4.2.patch)
;;
esac
for patch in "${patches[@]}"; do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment