[cig-commits] r12793 - cs/buildbot/trunk/binbot/mac/powerpc/bin
leif at geodynamics.org
leif at geodynamics.org
Wed Sep 3 12:45:28 PDT 2008
Author: leif
Date: 2008-09-03 12:45:28 -0700 (Wed, 03 Sep 2008)
New Revision: 12793
Added:
cs/buildbot/trunk/binbot/mac/powerpc/bin/g95
Log:
Assembled a 'g95' wrapper script using code cribbed from apgcc. The
only purpose of this script is to append '-lSystemStubs' to the g95
link line on Mac/PowerPC. Without this kludge, attempts to link
Fortran code with GCC-4-compiled C code fail with unresolved
'LDBLStub' symbols; e.g.:
ld: Undefined symbols:
_fprintf$LDBLStub
(With GCC 3, this was not an issue.) Note: the Mac/PowerPC BinBot
uses prebuilt 'g95' binaries downloaded from http://www.g95.org/.
Added: cs/buildbot/trunk/binbot/mac/powerpc/bin/g95
===================================================================
--- cs/buildbot/trunk/binbot/mac/powerpc/bin/g95 (rev 0)
+++ cs/buildbot/trunk/binbot/mac/powerpc/bin/g95 2008-09-03 19:45:28 UTC (rev 12793)
@@ -0,0 +1,145 @@
+#!/usr/bin/env perl
+
+# Append -lSystemStubs to g95 link line. Code cribbed from apgcc.
+
+use warnings;
+use strict;
+use IO::Socket;
+
+
+
+our $g95 = '/Users/buildbot/opt/g95/bin/powerpc-apple-darwin6.8-g95';
+our @linking = ('-lSystemStubs');
+our @include = ();
+
+
+######## Special constants; used for parsing GCC parameters ########
+
+# Parameters that require an extra parameter
+our $extraTypes = 'o|u|Xlinker|b|V|MF|MT|MQ|I|L|R|Wl,-rpath|isystem|D';
+# Linker parameters
+our $linkerTypes = 'L|Wl|o$|l|s|n|R';
+# Files with these extensions are objects
+our $objectTypes = 'o|a|so|la|lo|al';
+our $headerTypes = 'h|hpp';
+
+
+
+
+# Detect the situation in which the compiler is used.
+# Basically, there are 5 situations in which the compiler is used:
+# 1) Compilation (to an object file).
+# 2) Linking.
+# 3) Compilation and linking.
+# 4) Dependancy checking with -M* or -E.
+# 5) None of the above. Compiler is invoked with --help or something.
+# Note that source files may also contain non-C/C++ files.
+sub situation {
+ my ($args) = @_;
+ for (@{$args}) {
+ if (/^-c$/) {
+ # Situation 1
+ return 'compile';
+ } elsif (/^-M(|M|G)$/ || /^-E$/ || /^.+\.gch$/) {
+ # Situation 4
+ return 'depcheck';
+ }
+ }
+
+ my $i = 0;
+ for (@{$args}) {
+ if (!(/^-/) && !(/\.($objectTypes)$/)) {
+ if ($i > 0 && $args->[$i - 1] =~ /^-($extraTypes)$/) {
+ $i++;
+ next;
+ }
+ # Situation 3
+ return 'compile and link';
+ }
+ $i++;
+ }
+
+ my $files = 0;
+ for (@{$args}) {
+ $files++ if (!(/^-/));
+ }
+
+ if ($files == 0) {
+ # Situation 5
+ return 'other';
+ } else {
+ # Situation 2
+ return 'linking';
+ }
+}
+
+
+our $debugOpened = 0;
+
+sub empty {
+ return !defined($_[0]) || $_[0] eq '';
+}
+
+sub debug {
+ return if (empty($ENV{APBUILD_DEBUG}));
+
+ if (!$debugOpened) {
+ if (open DEBUG, '>/dev/tty') {
+ $debugOpened = 1;
+ } else {
+ return;
+ }
+ }
+
+ my @args = split /\n/, "@_";
+ foreach (@args) {
+ $_ = '# ' . $_;
+ $_ .= "\n";
+ }
+
+ print DEBUG "\033[1;33m";
+ print DEBUG join '', @args;
+ print DEBUG "\033[0m";
+ DEBUG->flush;
+}
+
+
+
+
+# Detect compilation situation
+our $situation = situation(\@ARGV);
+debug "g95 @ARGV\n";
+debug "Situation: $situation\n";
+
+
+# Handle each situation
+# Only situations that involve compiling or linking need to be treated specially
+
+if ($situation eq 'compile') {
+ my @command = ($g95, @include, @ARGV);
+ debug "@command\n";
+ my $status = system(@command);
+ exit (127) if ($status == -1);
+ exit ($status / 256) if ($status != 0);
+
+} elsif ($situation eq 'linking') {
+ my @command = ($g95, @ARGV, @linking);
+ debug "@command\n";
+ my $status = system(@command);
+ exit (127) if ($status == -1);
+ exit ($status / 256) if ($status != 0);
+
+} elsif ($situation eq 'compile and link') {
+ my @command = ($g95, @include, @ARGV, @linking);
+ debug "@command\n";
+ my $status = system(@command);
+ exit (127) if ($status == -1);
+ exit ($status / 256) if ($status != 0);
+
+} else {
+ my $ret = system($g95, @ARGV);
+ $ret /= 256;
+ exit $ret;
+}
+
+
Property changes on: cs/buildbot/trunk/binbot/mac/powerpc/bin/g95
___________________________________________________________________
Name: svn:executable
+ *
More information about the cig-commits
mailing list