diff --git a/config/init/optimize.pm b/config/init/optimize.pm
index ff97e57..c2d88e8 100644
a
|
b
|
|
35 | 35 | |
36 | 36 | # A plain --optimize means use perl5's $Config{optimize}. If an argument |
37 | 37 | # is given, however, use that instead. |
38 | | my $request_optimize = $conf->options->get('optimize'); |
| 38 | my $request_optimize = $conf->options->get('optimize') || ''; |
39 | 39 | |
40 | | if (! defined $request_optimize) { |
| 40 | if (! $request_optimize) { |
41 | 41 | $self->set_result('no'); |
42 | 42 | $conf->debug("(none requested) "); |
43 | 43 | return 1; |
44 | 44 | } |
45 | 45 | |
46 | | $self->set_result('yes'); |
47 | | my $gccversion = $conf->data->get( 'gccversion' ); |
48 | | |
49 | | my $options; |
50 | | if ( $request_optimize ) { |
| 46 | my $optimization_level; |
| 47 | if ( $request_optimize eq '1' ) { |
| 48 | # i.e., if command-line has '--optimize', |
51 | 49 | # start with perl5's flags ... |
52 | | $options = $conf->data->get('optimize_provisional'); |
| 50 | $optimization_level = $conf->data->get('optimize_provisional'); |
53 | 51 | |
54 | 52 | # ... but gcc 4.1 doesn't like -mcpu=xx, i.e. it's deprecated |
| 53 | my $gccversion = $conf->data->get( 'gccversion' ); |
55 | 54 | if ( defined $gccversion and $gccversion > 3.3 ) { |
56 | | $options =~ s/-mcpu=/-march=/; |
| 55 | $optimization_level =~ s/-mcpu=/-march=/; |
57 | 56 | } |
58 | 57 | } |
59 | 58 | else { |
60 | | # use the command line verbatim |
61 | | $options = $request_optimize; |
| 59 | # Otherwise, use the command-line verbatim, e.g. '--optimize=O3' |
| 60 | $optimization_level = $request_optimize; |
62 | 61 | } |
63 | 62 | |
64 | 63 | # save the options, however we got them. |
65 | | $conf->data->set( optimize => $options ); |
66 | | $conf->debug("optimize options: ", $options, "\n"); |
| 64 | $conf->data->set( optimize => $optimization_level ); |
| 65 | $conf->debug("optimize options: ", $optimization_level, "\n"); |
67 | 66 | |
68 | 67 | # disable debug flags. |
69 | 68 | $conf->data->set( cc_debug => '' ); |
… |
… |
|
73 | 72 | if ($conf->data->get('cpuarch') eq 'amd64') { |
74 | 73 | $conf->data->set('optimize::src/gc/system.c',''); |
75 | 74 | } |
| 75 | $self->set_result('yes'); |
76 | 76 | |
77 | 77 | return 1; |
78 | 78 | } |
diff --git a/t/steps/init/optimize-01.t b/t/steps/init/optimize-01.t
index 39c37bb..f2a6502 100644
a
|
b
|
|
3 | 3 | # init/optimize-01.t |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | | use Test::More tests => 28; |
| 6 | use Test::More tests => 34; |
7 | 7 | use Carp; |
8 | 8 | use lib qw( lib t/configure/testlib ); |
9 | 9 | use_ok('config::init::optimize'); |
… |
… |
|
68 | 68 | |
69 | 69 | $conf->replenish($serialized); |
70 | 70 | |
| 71 | ########## --optimize ########## |
| 72 | |
| 73 | # 'bare' --optimize should mean: default to what Perl 5 uses (typically, -O2), |
| 74 | # but perhaps with some manipulation due to GCC variations |
| 75 | ($args, $step_list_ref) = process_options( { |
| 76 | argv => [q{--optimize}], |
| 77 | mode => q{configure}, |
| 78 | } ); |
| 79 | $conf->options->set( %{$args} ); |
| 80 | $step = test_step_constructor_and_description($conf); |
| 81 | $ret = $step->runstep($conf); |
| 82 | ok( defined $ret, "runstep() returned defined value" ); |
| 83 | my $perl5_setting = $conf->data->get('optimize_provisional'); |
| 84 | like( $conf->data->get('optimize'), |
| 85 | qr/$perl5_setting/, |
| 86 | "Simple '--optimize' defaulted to Perl 5 optimization level" ); |
| 87 | |
| 88 | $conf->replenish($serialized); |
| 89 | |
71 | 90 | ########## --optimize=O2 ########## |
72 | 91 | |
73 | 92 | ($args, $step_list_ref) = process_options( { |
74 | | argv => [q{--optimize=O2}], |
| 93 | argv => [q{--optimize=-O3}], |
75 | 94 | mode => q{configure}, |
76 | 95 | } ); |
77 | 96 | $conf->options->set( %{$args} ); |
78 | 97 | $step = test_step_constructor_and_description($conf); |
79 | 98 | $ret = $step->runstep($conf); |
80 | 99 | ok( defined $ret, "runstep() returned defined value" ); |
| 100 | is( $conf->data->get('optimize'), '-O3', |
| 101 | "Got optimization level explicitly requested" ); |
81 | 102 | |
82 | 103 | $conf->replenish($serialized); |
83 | 104 | |