2016-12-20 15:01 GMT+03:00 Pascal Stumpf <pas...@stumpf.co>:
> On Tue, 20 Dec 2016 12:33:47 +0200, Paul Irofti wrote:
>> Hi,
>>
>> The new Octave version requires a modern C++ compiler and so I switched
>> to gcc 4.9. All compiles and seems to be running fine until an exception
>> is raised, then the program faults.
>>
>> This seems to happen on all errors, not just Octave specific errors.
>> Could this be something we are doing wrong? I have no idea where to
>> start with investigating this issue.
>>
>> Here is a detailed report on the Octave bugtracker
>>
>>    https://savannah.gnu.org/bugs/index.php?49859
>>
>> any thoughts? Pointers?
>
> I know nothing about Octave, but the issue seems to be that it links to
> libgcc from base instead of the 4.9 port.

Given that math/octave uses libtool, the chances are that a libtool
patch being tested right now will fix the issue. Or maybe not. :) You
may give it a try anyway (attached).

--
  WBR,
  Vadim Zhukov
This is needed to fix another poppler linking issue, and likely some
other ports that get both -lstdc++ and -lestdc++ linked in (which is
bad by definition).

A side effect of this patch could/should be some stdc++ entries
in WANTLIB becoming extra ones. So, in theory, this _is_ a package
contents change. But PLIST_DB doesn't register checksums of files,
so this shouldn't affect bulk build itself.

I've tested this patch with a partial bulk build, and got no
regressions. But I've skipped many CPU hogs like webkit and libreoffice,
and even those that don't use libtool themselves could be a dependency
for autoconf/libtool-based stuff.

--
WBR,
  Vadim Zhukov


Index: LT/UList.pm
===================================================================
RCS file: /cvs/src/usr.bin/libtool/LT/UList.pm,v
retrieving revision 1.2
diff -u -p -r1.2 UList.pm
--- LT/UList.pm	20 Apr 2014 17:34:26 -0000	1.2
+++ LT/UList.pm	19 Dec 2016 08:34:15 -0000
@@ -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]->{$_};
Index: LT/Mode/Link.pm
===================================================================
RCS file: /cvs/src/usr.bin/libtool/LT/Mode/Link.pm,v
retrieving revision 1.33
diff -u -p -r1.33 Link.pm
--- LT/Mode/Link.pm	3 Nov 2016 10:23:01 -0000	1.33
+++ LT/Mode/Link.pm	19 Dec 2016 08:34:15 -0000
@@ -822,6 +822,20 @@ 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);

Reply via email to