Author: bernhard
Date: Wed Sep 14 11:30:31 2005
New Revision: 9194
Added:
trunk/config/inter/shlibs.pl
Modified:
trunk/Configure.pl
trunk/MANIFEST
trunk/config/init/data.pl
trunk/config/init/hints/solaris.pl
trunk/config/init/optimize.pl
trunk/config/inter/progs.pl
trunk/lib/Parrot/Configure/RunSteps.pm
trunk/lib/Parrot/Configure/Step.pm
Log:
This patch makes it easier to compile parrot with a compiler other than
the one used to compile perl5. It re-arranges the order in which various
defaults are set so that the user may override them either with hints
files or interactively, via ask.
Thanks to Andy Dougherty [perl #37160]
Modified: trunk/Configure.pl
==============================================================================
--- trunk/Configure.pl (original)
+++ trunk/Configure.pl Wed Sep 14 11:30:31 2005
@@ -76,7 +76,11 @@ Turn on profiled compile (gcc only for n
=item C<--optimize>
-Tell the compiler to do an optimization phase.
+Add perl5's $Config{optimize} to the compiler flags.
+
+=item C<--optimize=flags>
+
+Add C<flags> to the compiler flags.
=item C<--inline>
@@ -314,6 +318,7 @@ e.g. : --ccflags="rem{-g} :add{-O2}"
--debugging=0 Disable debugging, default = 1
--profile Turn on profiled compile (gcc only for now)
--optimize Optimized compile
+ --optimize=flags Add given optimizer flags
--inline Compiler supports inline
--cc=(compiler) Use the given compiler
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Wed Sep 14 11:30:31 2005
@@ -308,6 +308,7 @@ config/inter/encoding.pl
config/inter/exp.pl []
config/inter/ops.pl []
config/inter/pmc.pl []
+config/inter/shlibs.pl []
config/inter/progs.pl []
config/inter/types.pl []
docs/ROADMAP [devel]doc
Modified: trunk/config/init/data.pl
==============================================================================
--- trunk/config/init/data.pl (original)
+++ trunk/config/init/data.pl Wed Sep 14 11:30:31 2005
@@ -37,7 +37,10 @@ sub runstep {
my(%c)=(
debugging => $debugging ? 1 : 0,
- optimize => $optimize ? $Config{optimize} : '',
+ # A plain --optimize means use perl5's $Config{optimize}. If an argument
is
+ # given, however, use that instead. This logic really belongs in the
optimize
+ # unit.
+ optimize => $optimize ? ($optimize eq "1" ? $Config{optimize} :
$optimize) : '',
verbose => $verbose,
build_dir => $FindBin::Bin,
Modified: trunk/config/init/hints/solaris.pl
==============================================================================
--- trunk/config/init/hints/solaris.pl (original)
+++ trunk/config/init/hints/solaris.pl Wed Sep 14 11:30:31 2005
@@ -1,5 +1,6 @@
# Copyright: 2005 The Perl Foundation. All Rights Reserved.
# $Id$
+use Parrot::Configure::Step qw(cc_gen cc_run);
my $libs = Configure::Data->get('libs');
if ( $libs !~ /-lpthread/ ) {
@@ -13,24 +14,51 @@ Configure::Data->set(
);
################################################################
-my $link = Configure::Data->get('link');
-# Going to assume Sun's compiler
-# In which case we need to link with the C++ compiler (CC) rather than the
-# C compiler (cc)
-$link =~ s/\bcc\b/CC/;
-Configure::Data->set('link', $link);
-
-# if it turns out we're using gcc, then we need to make sure we're linking
-# with g++, not gcc. We can't make this decision until the gccversion test
-# has been run.
+# If we're going to be using ICU (or any other C++-compiled library) we
+# need to use the c++ compiler as a linker. As soon as the user
+# selects a compiler, we will run the gccversion test. (If we were to
+# wait till it's normally run, the linker question would have already
+# been asked.)
my $solaris_link_cb = sub {
- my ($key, $gccversion) = @_;
- if ($gccversion) {
- Configure::Data->set('link', 'g++');
- Configure::Data->deltrigger("gccversion", "solaris_link");
- }
+ use Carp;
+ my ($key, $cc) = @_;
+ my %gnuc;
+ my $link = Configure::Data->get('link');
+ cc_gen("config/auto/gcc/test_c.in");
+ # Can't call cc_build since we haven't set all the flags yet.
+ # This should suffice for this test.
+ Parrot::Configure::Step::_run_command("$cc -o test test.c", 'test.cco',
'test.cco')
+ and confess "C compiler failed (see test.cco)";
+ %gnuc=eval cc_run() or die "Can't run the test program: $!";
+ if (defined $gnuc{__GNUC__}) {
+ $link = 'g++';
+ }
+ else {
+ $link =~ s/\bcc\b/CC/;
+ }
+ Configure::Data->set('link', $link);
+ Configure::Data->deltrigger("cc", "solaris_link");
+};
+Configure::Data->settrigger("cc", "solaris_link", $solaris_link_cb);
+
+################################################################
+# cc_shared: Flags to instruct the compiler to use position-independent
+# code for use in shared libraries. -KPIC for Sun's compiler, -fPIC for
+# gcc. We don't know which compiler we're using till after the
+# gccversion test.
+# XXX Should this go into the shlibs.pl Configure.pl unit instead?
+my $solaris_cc_shared_cb = sub {
+ my ($key, $gccversion) = @_;
+ if ($gccversion) {
+ Configure::Data->set('cc_shared', '-fPIC');
+ }
+ else {
+ Configure::Data->set('cc_shared', '-KPIC');
+ }
+ Configure::Data->deltrigger("gccversion", "solaris_cc_shared");
};
-Configure::Data->settrigger("gccversion", "solaris_link", $solaris_link_cb);
+Configure::Data->settrigger("gccversion", "solaris_cc_shared",
+ $solaris_cc_shared_cb);
################################################################
# Parrot usually aims for IEEE-754 compliance.
Modified: trunk/config/init/optimize.pl
==============================================================================
--- trunk/config/init/optimize.pl (original)
+++ trunk/config/init/optimize.pl Wed Sep 14 11:30:31 2005
@@ -1,4 +1,4 @@
-# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# Copyright: 2001-2005 The Perl Foundation. All Rights Reserved.
# $Id$
=head1 NAME
@@ -9,6 +9,7 @@ config/init/optimize.pl - Optimization
Enables optimization by adding the appropriate flags for the local
platform to the C<CCFLAGS>.
+Should this be part of config/inter/progs.pl ? XXX
=cut
@@ -20,9 +21,10 @@ use Parrot::Configure::Step;
$description="Enabling optimization...";
[EMAIL PROTECTED](verbose);
[EMAIL PROTECTED](verbose optimize);
sub runstep {
+ my ($verbose, $optimize) = @_;
if (Configure::Data->get('optimize')) {
my($ccflags, $optimize) =
Configure::Data->get(qw(ccflags optimize));
@@ -33,7 +35,7 @@ sub runstep {
);
}
else {
- print "(none requested) " if $_[0];
+ print "(none requested) " if $verbose;
}
}
Modified: trunk/config/inter/progs.pl
==============================================================================
--- trunk/config/inter/progs.pl (original)
+++ trunk/config/inter/progs.pl Wed Sep 14 11:30:31 2005
@@ -1,4 +1,4 @@
-# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# Copyright: 2001-2005 The Perl Foundation. All Rights Reserved.
# $Id$
=head1 NAME
@@ -29,20 +29,9 @@ sub runstep {
@[EMAIL PROTECTED]@_;
my($cc, $cxx, $link, $ld, $ccflags, $ccwarn, $linkflags, $ldflags, $libs,
$lex,
- $yacc) =
- Configure::Data->get(qw(cc cxx link ld ccflags ccwarn linkflags ldflags
- libs lex yacc));
- $ccflags =~ s/-D((PERL|HAVE)_\w+\s*|USE_PERLIO)//g;
- $ccflags =~ s/-fno-strict-aliasing//g;
- $ccflags =~ s/-fnative-struct//g;
- $linkflags =~ s/-libpath:\S+//g;
- $ldflags =~ s/-libpath:\S+//g;
- my $debug='n';
-
- $libs=join ' ',
- grep { $^O=~/VMS|MSWin/ || !/^-l(c|gdbm(_compat)?|dbm|ndbm|db)$/ }
- split(' ', $libs);
+ $yacc);
+ # Find a working version of a program:
# Try each alternative, until one works.
# If none work, then set to null command.
# XXX need config support for a null command.
@@ -54,20 +43,6 @@ sub runstep {
}
return $null;
};
- if ($args{'maintainer'}) {
- $lex = &$first_working($lex, 'flex', 'lex' );
- $yacc = &$first_working($yacc, 'bison -v -y', 'yacc', 'byacc');
- }
- else {
- $lex = $yacc = $null;
- }
-
- for my $var(qw(cc cxx link ld ccflags linkflags ldflags libs ccwarn lex
yacc)) {
- #Symrefs to lexicals are a no-no, so we have to use eval STRING. %MY,
anyone?
- eval qq{ \$$var=integrate(\$$var, \$args{$var}) if defined \$args{$var} };
- }
-
- $debug='y' if $args{debugging};
if($args{ask}) {
print <<'END';
@@ -80,20 +55,74 @@ sub runstep {
configuration.
END
+ }
- $cc=prompt("What C compiler do you want to use?", $cc);
- $link=prompt("How about your linker?", $link);
- $ld=prompt("What program do you want to use to build shared libraries?",
- $ld);
- $ccflags=prompt("What flags should your C compiler receive?", $ccflags);
- $linkflags=prompt("And your linker?", $linkflags);
- $ldflags=prompt("And your $ld for building shared libraries?", $ldflags);
- $libs=prompt("What libraries should your C compiler use?", $libs);
- $cxx=prompt("What C++ compiler do you want to use?", $cxx);
- $debug=prompt("Do you want a debugging build of Parrot?", $debug);
- $lex=prompt("Do you have a lexical analyzer generator, like flex or
lex?",$lex);
- $yacc=prompt("Do you have a parser generator, like bison or yacc?",$yacc);
- }
+ # Set each variable individually so that hints files can use them as
+ # triggers to help pick the correct defaults for later answers.
+
+ $cc = integrate(Configure::Data->get('cc'), $args{cc});
+ $cc = prompt("What C compiler do you want to use?", $cc) if $args{ask};
+ Configure::Data->set(cc => $cc);
+
+ $link = integrate(Configure::Data->get('link'), $args{link});
+ $link = prompt("How about your linker?", $link) if $args{ask};
+ Configure::Data->set(link => $link);
+
+ $ld = integrate(Configure::Data->get('ld'), $args{ld});
+ $ld = prompt("What program do you want to use to build shared libraries?",
$ld) if $args{ask};
+ Configure::Data->set(ld => $ld);
+
+ $ccflags = Configure::Data->get('ccflags');
+ # Remove some perl5-isms.
+ $ccflags =~ s/-D((PERL|HAVE)_\w+\s*|USE_PERLIO)//g;
+ $ccflags =~ s/-fno-strict-aliasing//g;
+ $ccflags =~ s/-fnative-struct//g;
+ $ccflags = integrate($ccflags, $args{ccflags});
+ $ccflags = prompt("What flags should your C compiler receive?", $ccflags)
if $args{ask};
+ Configure::Data->set(ccflags => $ccflags);
+
+ $linkflags = Configure::Data->get('linkflags');
+ $linkflags =~ s/-libpath:\S+//g; # XXX No idea why.
+ $linkflags = integrate($linkflags, $args{linkflags});
+ $linkflags = prompt("And your linker?", $linkflags) if $args{ask};
+ Configure::Data->set(linkflags => $linkflags);
+
+ $ldflags = Configure::Data->get('ldflags');
+ $ldflags =~ s/-libpath:\S+//g; # XXX No idea why.
+ $ldflags = integrate($ldflags, $args{ldflags});
+ $ldflags = prompt("And your $ld for building shared libraries?", $ldflags)
if $args{ask};
+ Configure::Data->set(ldflags => $ldflags);
+
+ $libs = Configure::Data->get('libs');
+ $libs=join ' ',
+ grep { $^O=~/VMS|MSWin/ || !/^-l(c|gdbm(_compat)?|dbm|ndbm|db)$/ }
+ split(' ', $libs);
+ $libs = integrate($libs, $args{libs});
+ $libs = prompt("What libraries should your C compiler use?", $libs) if
$args{ask};
+ Configure::Data->set(libs => $libs);
+
+ $cxx = integrate(Configure::Data->get('cxx'), $args{cxx});
+ $cxx = prompt("What C++ compiler do you want to use?", $cxx) if $args{ask};
+ Configure::Data->set(cxx => $cxx);
+
+ my $debug='n';
+ $debug='y' if $args{debugging};
+ $debug = prompt("Do you want a debugging build of Parrot?", $debug) if
$args{ask};
+
+ if ($args{'maintainer'}) {
+ $lex = integrate(Configure::Data->get('lex'), $args{lex});
+ $lex = &$first_working($lex, 'flex', 'lex');
+ $yacc = integrate(Configure::Data->get('yacc'), $args{yacc});
+ $yacc = &$first_working($yacc, 'bison -v -y', 'yacc', 'byacc');
+ }
+ else {
+ $lex = $yacc = $null;
+ }
+ $lex = prompt("Do you have a lexical analyzer generator, like flex or
lex?",$lex) if $args{ask};
+ Configure::Data->set(lex => $lex);
+
+ $yacc = prompt("Do you have a parser generator, like bison or
yacc?",$yacc) if $args{ask};
+ Configure::Data->set(yacc => $yacc);
if(!$debug || $debug =~ /n/i) {
Configure::Data->set(
@@ -103,19 +132,9 @@ END
);
}
- Configure::Data->set(
- cc => $cc,
- cxx => $cxx,
- link => $link,
- ld => $ld,
- ccflags => $ccflags,
- linkflags => $linkflags,
- ldflags => $ldflags,
- libs => $libs,
- ccwarn => $ccwarn,
- lex => $lex,
- yacc => $yacc,
- );
+ # This one isn't prompted for above. I don't know why.
+ $ccwarn = integrate(Configure::Data->get('ccwarn'), $args{ccwarn});
+ Configure::Data->set(ccwarn => $ccwarn);
}
1;
Added: trunk/config/inter/shlibs.pl
==============================================================================
--- (empty file)
+++ trunk/config/inter/shlibs.pl Wed Sep 14 11:30:31 2005
@@ -0,0 +1,39 @@
+# Copyright: 2005 The Perl Foundation. All Rights Reserved.
+# $Id: cc_shared.pl $
+
+=head1 NAME
+
+config/inter/shlibs.pl - Flags for shared libraries.
+
+=head1 DESCRIPTION
+
+Asks the user which flags are needed for compiling position-independent
+code for use in shared libraries. Eventually, other
+shared-library-related prompts may end up here.
+
+This is a separate unit from config/inter/progs.pl because the answers
+depend on which compiler is in use. Thus it should come after the
+gccversion test.
+
+=cut
+
+package Configure::Step;
+
+use strict;
+use vars qw($description @args);
+use Parrot::Configure::Step ':inter';
+
+$description = 'Determining flags for building shared libraries...';
+
[EMAIL PROTECTED] = qw(ask verbose cc_shared);
+
+sub runstep {
+ my ($ask, $verbose, $cc_shared) = @_;
+ $cc_shared = integrate(Configure::Data->get('cc_shared'), $cc_shared);
+ $cc_shared=prompt(
+ "\nWhat flags instruct your compiler to compile code suitable for use
in a shared library?",
+ $cc_shared) if $ask;
+ Configure::Data->set(cc_shared => $cc_shared);
+ $Configure::Step::result = $cc_shared;
+}
+1;
Modified: trunk/lib/Parrot/Configure/RunSteps.pm
==============================================================================
--- trunk/lib/Parrot/Configure/RunSteps.pm (original)
+++ trunk/lib/Parrot/Configure/RunSteps.pm Wed Sep 14 11:30:31 2005
@@ -33,6 +33,7 @@ use vars qw(@steps);
inter/progs.pl
auto/gcc.pl
init/optimize.pl
+ inter/shlibs.pl
inter/charset.pl
inter/encoding.pl
inter/types.pl
Modified: trunk/lib/Parrot/Configure/Step.pm
==============================================================================
--- trunk/lib/Parrot/Configure/Step.pm (original)
+++ trunk/lib/Parrot/Configure/Step.pm Wed Sep 14 11:30:31 2005
@@ -49,7 +49,8 @@ use vars qw(@ISA @EXPORT @EXPORT_OK %EXP
=item C<integrate($orig, $new)>
-Integrates C<$new> into C<$orig>.
+Integrates C<$new> into C<$orig>. Returns C<$orig> if C<$new>
+is undefined.
=cut
@@ -57,7 +58,11 @@ sub integrate {
my($orig, $new) = @_;
unless(defined $new) {
- warn "String to be integrated in to '$orig' undefined";
+ # Rather than sprinkling "if defined(...)", everywhere,
+ # config/inter/progs.pl just passes in potentially undefined
+ # strings. Just pass back the original in that case. Don't
+ # bother warning. --AD, 12 Sep 2005
+ # warn "String to be integrated in to '$orig' undefined";
return $orig;
}