diff options
author | Vadim Zhukov <zhuk@cvs.openbsd.org> | 2016-12-25 13:46:19 +0000 |
---|---|---|
committer | Vadim Zhukov <zhuk@cvs.openbsd.org> | 2016-12-25 13:46:19 +0000 |
commit | 3b6f0850aee4690b9c9649fe15f9d17da9b61a33 (patch) | |
tree | 367db19a6f16732222de04fe97952f6384b48d06 /usr.bin/libtool | |
parent | e8074547e4eade3d12346796307429763764b835 (diff) |
Teach libtool how to deal with both -lestdc++ and -lstdc++ in command line.
This helps to avoid linking both libraries, making -lestdc++ the only one
there. The concrete example would be print/poppler port after Qt5 update,
which is coming right now.
This hack would go away together with libestdc++...
Kind support on all the way by aja@, thanks!
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r-- | usr.bin/libtool/LT/Mode/Link.pm | 17 | ||||
-rw-r--r-- | usr.bin/libtool/LT/UList.pm | 30 |
2 files changed, 43 insertions, 4 deletions
diff --git a/usr.bin/libtool/LT/Mode/Link.pm b/usr.bin/libtool/LT/Mode/Link.pm index f4696954c45..56cf7a570c1 100644 --- a/usr.bin/libtool/LT/Mode/Link.pm +++ b/usr.bin/libtool/LT/Mode/Link.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Link.pm,v 1.33 2016/11/03 10:23:01 ajacoutot Exp $ +# $OpenBSD: Link.pm,v 1.34 2016/12/25 13:46:18 zhuk Exp $ # # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -822,6 +822,21 @@ sub common1 my $staticlibs = []; my $args = $parser->parse_linkargs2($gp, $orderedlibs, $staticlibs, $dirs, $libs); + + my $tiedlibs = tied(@$orderedlibs); + my $ie = $tiedlibs->indexof("estdc++"); + my $is = $tiedlibs->indexof("stdc++"); + if (defined($ie) and defined($is)) { + tsay {"stripping stdc++ from orderedlibs due to having estdc++ already; ie=$ie, is=$is"}; + # check what library comes later + if ($ie < $is) { + splice(@$orderedlibs, $ie, 1); + splice(@$orderedlibs, $is, 1, "estdc++"); + $ie = $is; + } else { + splice(@$orderedlibs, $is, 1); + } + } tsay {"staticlibs = \n", join("\n", @$staticlibs)}; tsay {"orderedlibs = @$orderedlibs"}; return ($staticlibs, $orderedlibs, $args); diff --git a/usr.bin/libtool/LT/UList.pm b/usr.bin/libtool/LT/UList.pm index 08ecf506fa7..9d34108aa00 100644 --- a/usr.bin/libtool/LT/UList.pm +++ b/usr.bin/libtool/LT/UList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: UList.pm,v 1.2 2014/04/20 17:34:26 zhuk Exp $ +# $OpenBSD: UList.pm,v 1.3 2016/12/25 13:46:18 zhuk Exp $ # # Copyright (c) 2013 Vadim Zhukov <zhuk@openbsd.org> # @@ -63,6 +63,8 @@ sub TIEARRAY { # returned by tie() or tied() instead. sub exists { return exists $_[0]->[0]->{$_[1]}; } +sub indexof { return exists($_[0]->[0]->{$_[1]}) ? ($_[0]->[0]->{$_[1]} - 1) : undef; } + sub FETCHSIZE { return scalar(@{$_[0]}) - 1; } # not needed @@ -144,8 +146,30 @@ sub SPLICE $length = $maxrm; } - # do not ever dream of adding items here - my @ret = splice(@$self, $offset, $length); + my $i = @$self; + + # make sure no duplicates get added + @_ = grep { !exists $self->[0] or + $self->[0]->{$_} >= $offset && + $self->[0]->{$_} < $offset + $length } @_; + + for (@_) { + # set up index + $self->[0]->{$_} = $i++; + } + + # + # Renumber (in advance) trailing items, in case something gets added + # and number of added and removed items differs. + # + my $delta = scalar(@_) - $length; + if (scalar(@_) and $delta) { + for $i ($offset + $length .. scalar(@$self)) { + $self->[0]->{$self->[$i]} += $delta; + } + } + + my @ret = splice(@$self, $offset, $length, @_); for (@ret) { delete $self->[0]->{$_}; |