[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] libtool munges '-(' and '-)' options.
From: |
C. Scott Ananian |
Subject: |
[patch] libtool munges '-(' and '-)' options. |
Date: |
Tue, 10 Sep 2002 12:04:13 -0400 (EDT) |
Certain applications require the linker flags --start-group
and --end-group (abbreviated "-(" and "-)" ) in order to
resolve circular references between libraries. However,
libtool "sorts" these flags and places them at the beginning
of the command-line, destroying their utility. At the end
of this report is a uuencoded archive containing three
source files and a Makefile demonstrating the problem.
We end up with an archive A.a which uses symbols defined in B.a
and an archive B.a which uses symbols defined in A.a --- a
circular dependency. The command:
gcc -o foo c.o -Wl,"-(" A.a B.a -Wl,"-)"
correctly builds these archives into an executable by telling
ld that it should iterate over A.a and B.a to resolve all
circular references, instead of ld's usual search-once strategy.
However:
libtool gcc -o foo c.o -Wl,"-(" A.a B.a -Wl,"-)"
yields:
$ libtool gcc -o foo c.o -Wl,"-(" A.a B.a -Wl,"-)"
gcc -o foo c.o -Wl,"-(" -Wl,"-)" A.a B.a
B.a(b.o): In function `b':
b.o(.text+0x1b): undefined reference to `a'
collect2: ld returned 1 exit status
As you can see, libtool re-orders the -( and -) flags, destroying
their function. This is a bug in libtool (and it's making my
life quite difficult at the moment, as my libraries have unavoidable
circular references).
Appended is a quick & dirty patch to fix the problem by specially
treating the '-(' and '-)' flags (and the equivalent --start-group
and --end-group flags) and allowing these to go into deplibs in the proper
context.
This is also debian bug #159760:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=159760&repeatmerged=yes
and comments can be recorded in the debian bug-tracking system for
the use of the debian maintainer or libtool by email to
address@hidden
--scott
terrorist postcard United Nations Leitrim Cocaine munitions payment
LA Washington justice MI6 Marxist mail drop Ft. Bragg assassination politics
( http://cscott.net/ )
---- source archive demonstrating the problem ----
begin 644 libtool-bug.tgz
M'XL(`%R9=ST``^V476O;,!2&?6O]BH/)0.YJ5W*L&AP"[6"#P7JS7>QF%&3%
M#J:*'6P'LH[MMU?.QS#)address@hidden:UAL[#\B2CJ2C(Q^]TGG2E*7VDL7TS'HA&`N#
M2`A3,QX)UJVW6"P20Q'Q4`Q#B_%A&`06B)<*J,NB;F0%8"E9R"*7Q:%Y#XW_
MH^A._J_D39KE.CWV'HPS=AZ&!_,?[>5?,&'RSXX=R)_XS_/_X>address@hidden)>^
MI-(O77AG&DG;4'Y)I-8Q--5WWGX"HG0JBYC8`_KYRH43OS1%PLDODLE<\Q@&
M=.7.)?94*?!*R,JR]=-Z;QV3N:SK^^9Y7_6IXU%GNV!C<)W5#D%WY>;BPCT[
M/6;^X1W))*^;V%Z=&3HR\9OI+=GIQ[#5#DA?06**\A6Q9S>3O#)!)+)."SE+
M87!A0E%S&%SO6,^(W=Y#=9N9WO[8^H][5;;K[+GY[^K?A'Z,*[7'0_KG_'SW
M_8^B"/7_&N1%`PEMOTMW1-I:;address@hidden&=#E>,Q<J-)F417`1L::ZCK=&OC;
MA"X];A;_),^^C<AKT]5_TIO^!>J_)[J*7^L_>:K^Y6_]]WT8Y,ET]:_ZTC]#
M_??%8?V/R*H[DWE!UX_!O#*&C#IO)M\*Y]1,Y,Q%W2,(@B`(@B`(@B`(@B`(
address@hidden(W\<address@hidden
`
end
---- patch to fix the problem ----
diff -ruHp libtool-1.4.2.orig/ltmain.sh libtool-1.4.2/ltmain.sh
--- libtool-1.4.2.orig/ltmain.sh 2002-09-05 16:03:23.000000000 -0400
+++ libtool-1.4.2/ltmain.sh 2002-09-05 16:04:07.000000000 -0400
@@ -934,9 +934,17 @@ compiler."
continue
;;
xlinker)
+ prev=
+ if test "$qarg" = "\"-(\"" -o "$qarg" = "--start-group" ; then
+ deplibs="$deplibs --start-group"
+ continue
+ fi
+ if test "$qarg" = "\"-)\"" -o "$qarg" = "--end-group" ; then
+ deplibs="$deplibs --end-group"
+ continue
+ fi
linker_flags="$linker_flags $qarg"
compiler_flags="$compiler_flags $wl$qarg"
- prev=
compile_command="$compile_command $wl$qarg"
finalize_command="$finalize_command $wl$qarg"
continue
@@ -1177,6 +1185,14 @@ compiler."
save_ifs="$IFS"; IFS=','
for flag in $args; do
IFS="$save_ifs"
+ if test "$flag" = "-(" -o "$flag" = "--start-group" ; then
+ deplibs="$deplibs --start-group"
+ continue;
+ fi
+ if test "$flag" = "-)" -o "$flag" = "--end-group" ; then
+ deplibs="$deplibs --end-group"
+ continue
+ fi
case $flag in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
flag="\"$flag\""
@@ -1464,6 +1480,12 @@ compiler."
deplibs="$deplib $deplibs"
continue
;;
+ --start-group|--end-group)
+ deplibs="$deplib $deplibs"
+ compile_deplibs="$wl$deplib $compile_deplibs"
+ finalize_deplibs="$wl$deplib $finalize_deplibs"
+ continue
+ ;;
*.la) lib="$deplib" ;;
*.$libext)
if test $pass = conv; then
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [patch] libtool munges '-(' and '-)' options.,
C. Scott Ananian <=