toys/tools/gcc.wrapper
sparky
cvs at pld-linux.org
Fri Aug 4 16:21:38 CEST 2006
Author: sparky
Date: Fri Aug 4 16:21:36 2006
New Revision: 7593
Modified:
toys/tools/gcc.wrapper
Log:
- rewritten to make it smarter:
-- reports when there is -l<sometging> before -Wl,--as-needed
-- reports when -Os was overwritten by other -O
Modified: toys/tools/gcc.wrapper
==============================================================================
--- toys/tools/gcc.wrapper (original)
+++ toys/tools/gcc.wrapper Fri Aug 4 16:21:36 2006
@@ -13,9 +13,14 @@
# warning: glibc changes flags order
my $cflags = "-fno-align-loops -fno-align-jumps -fno-align-functions";
+my $wanted_optimize = "-Os";
+my $wanted_ldflag = "-Wl,--as-needed";
+
my $link = 1;
my $compile = 1;
my $source = 0;
+my $optimize = "";
+my $asneeded_first = undef;
FORARGS:
foreach my $arg (@ARGV) {
@@ -42,7 +47,20 @@
$compile = 0;
last FORARGS;
}
- $source = 1 if $arg =~ /\.(c|cpp|cxx)$/;
+ if (length $wanted_optimize and $arg =~ /^(-O[s0-9])$/) {
+ $optimize = $1;
+ next;
+ }
+ if (length $wanted_ldflag and not defined $asneeded_first) {
+ if ($arg =~ /^-l/) {
+ $asneeded_first = 0;
+ next;
+ } elsif ($arg eq $wanted_ldflag) {
+ $asneeded_first = 1;
+ next;
+ }
+ }
+ $source = 1 if $arg =~ /\.(c|cc|cpp|cxx)$/;
}
$compile = 0 unless $source;
@@ -51,25 +69,34 @@
if ($link or $compile) {
(my $pwd = $ENV{PWD}) =~ s#.*BUILD/##;
my $args = join ' ', @ARGV;
- if (length $ldflags and $link) {
- unless ($args =~ /$ldflags/o) {
- open PROBLEMS, ">> $ENV{HOME}/ldflags-problems"
- or die "$!\n";
- print PROBLEMS "LDFLAGS! $pwd: $args\n";
- close PROBLEMS;
+ my @problems;
+ if ($link) {
+ if (length $ldflags and $args !~ /$ldflags/) {
+ push @problems, "LDFLAGS";
+ }
+ if (length $wanted_ldflag and defined $asneeded_first
+ and $asneeded_first == 0 ) {
+ push @problems, "ASNEEDED";
}
}
- if (length $cflags and $compile) {
- unless ($args =~ /$cflags/o) {
- open PROBLEMS, ">> $ENV{HOME}/ldflags-problems"
- or die "$!\n";
- print PROBLEMS "CFLAGS! $pwd: $args\n";
- close PROBLEMS;
+ if ($compile) {
+ if (length $cflags and $args !~ /$cflags/) {
+ push @problems, "CFLAGS";
+ }
+ if (length $wanted_optimize and $optimize ne $wanted_optimize) {
+ push @problems, "OPTIMIZE($optimize)";
}
}
unless ($prog eq "ppc-pld-linux-gcc" or $prog eq "ppc-pld-linux-g++") {
- open PROBLEMS, ">> $ENV{HOME}/ldflags-problems" or die "$!\n";
- print PROBLEMS "PROGRAM! $pwd: $0\n";
+ push @problems, "PROGRAM";
+ }
+
+ #push @problems, "TEST";
+ if (@problems) {
+ open PROBLEMS, ">> $ENV{HOME}/ldflags-problems"
+ or die "$!\n";
+ local $" = "! ";
+ print PROBLEMS "@problems! $pwd: $0 $args\n";
close PROBLEMS;
}
}
More information about the pld-cvs-commit
mailing list