diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-07-10 11:41:11 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-07-10 11:41:11 +0000 |
commit | 4d9df6d17f7fe7a627c4f8a824e27f6655a49860 (patch) | |
tree | 581f1641cb81f8fa73b686823f735979a58a79bc /usr.bin/libtool | |
parent | 0ac20a8dd708335279255c571898c4ea4f1f240e (diff) |
full support for -static -shared -prefer-pic -prefer-non-pic -fpie*
in --mode=compile
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r-- | usr.bin/libtool/LT/LoFile.pm | 6 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Mode/Compile.pm | 51 |
2 files changed, 42 insertions, 15 deletions
diff --git a/usr.bin/libtool/LT/LoFile.pm b/usr.bin/libtool/LT/LoFile.pm index 40865838590..5b2f3ee0f23 100644 --- a/usr.bin/libtool/LT/LoFile.pm +++ b/usr.bin/libtool/LT/LoFile.pm @@ -1,4 +1,4 @@ -# $OpenBSD: LoFile.pm,v 1.4 2012/07/09 17:53:38 espie Exp $ +# $OpenBSD: LoFile.pm,v 1.5 2012/07/10 11:41:10 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -53,7 +53,7 @@ sub compile if (defined $self->{picobj}) { my @cmd = @$compiler; push @cmd, @$args if @$args; - push @cmd, @main::picflags, '-o'; + push @cmd, @{$self->{picflags}}, '-o'; my $o = ($odir eq '.') ? '' : "$odir/"; $o .= $self->{picobj}; push @cmd, $o; @@ -62,7 +62,7 @@ sub compile if (defined $self->{nonpicobj}) { my @cmd = @$compiler; push @cmd, @$args if @$args; - push @cmd, '-o'; + push @cmd, @{$self->{nonpicflags}}, '-o'; my $o = ($odir eq '.') ? '' : "$odir/"; $o .= $self->{nonpicobj}; push @cmd, $o; diff --git a/usr.bin/libtool/LT/Mode/Compile.pm b/usr.bin/libtool/LT/Mode/Compile.pm index c68bde54330..cf25d91a567 100644 --- a/usr.bin/libtool/LT/Mode/Compile.pm +++ b/usr.bin/libtool/LT/Mode/Compile.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Compile.pm,v 1.9 2012/07/09 21:59:18 espie Exp $ +# $OpenBSD: Compile.pm,v 1.10 2012/07/10 11:41:10 espie Exp $ # # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -43,6 +43,19 @@ sub run my ($class, $ltprog, $gp, $noshared) = @_; my $lofile = LT::LoFile->new; + my $pic = !$noshared; + my $nonpic = 1; + if ($gp->has_tag('disable-shared')) { + $pic = 0; + } + if ($gp->has_tag('disable-static') && $pic) { + $nonpic = 0; + } + + my $pic_mode = 0; + + my @pie_flags = (); + $gp->handle_permuted_options('o:@', qr{\-Wc\,(.*)}, sub { @@ -52,17 +65,25 @@ sub run sub { $gp->keep_for_later($_[2]); }, - # recognize, don't do shit - 'no-suppress', - 'prefer-pic', 'prefer-non-pic', 'static', 'shared'); - # XXX options ignored: -prefer-pic and -prefer-non-pic - my $pic = 0; - my $nonpic = 1; - # assume we need to build pic objects - $pic = 1 if (!$noshared); - $nonpic = 0 if ($pic && $gp->has_tag('disable-static')); - $pic = 0 if ($nonpic && $gp->has_tag('disable-shared')); - $nonpic = 1 if $gp->static; + 'pie|fpie|fPIE', + sub { + push(@pie_flags, $_[3]); + }, + 'no-suppress', # we just ignore that one + 'prefer-pic', sub { $pic_mode = 1; }, + 'prefer-non-pic', sub { $pic_mode = 0; }, + 'static', + sub { + $pic = 0; + $nonpic = 1; + }, + 'shared', + sub { + if (!$pic) { + shortdie "bad configuration: can't build shared library"; + } + $nonpic = 0; + }); my ($outfile, $odir, $ofile, $srcfile, $srcext); # XXX check whether -c flag is present and if not, die? @@ -99,6 +120,12 @@ sub run $lofile->{picobj} = $picobj if $pic; $lofile->{nonpicobj} = $nonpicobj if $nonpic; + $lofile->{picflags} = \@main::picflags; + if ($pic_mode) { + $lofile->{nonpicflags} = \@main::picflags; + } else { + $lofile->{nonpicflags} = \@pie_flags; + } $lofile->compile($ltprog, $odir, \@ARGV); $lofile->write($outfile); } |