Skip to content

Commit d0774de

Browse files
committed
Use config args to control optimization flags
Currently two settings, one for core, one for cpan.
1 parent 27249cd commit d0774de

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/Perl/Dist/Strawberry/Step/InstallPerlCore.pm

+11-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ sub run {
112112
my $u64 = defined $self->global->{perl_64bitint} ? $self->global->{perl_64bitint} : ($self->{config}->{perl_64bitint} // $self->{config}->{use_64_bit_int} // 0);
113113
# XXX use_64_bit_int is for backwards compatibility
114114

115+
# Optionally override the default optimization settings.
116+
# This hack is needed as some perls need -Os to build but then modules need -O2.
117+
my $optimize_core = $self->global->{optimize_core} // $self->{config}->{optimize_core};
118+
my $optimize_cpan = $self->global->{optimize_cpan} // $self->{config}->{optimize_cpan};
119+
115120
# Build win32 perl
116121
SCOPE: {
117122
my $wd = $self->_push_dir( $unpack_to, $perlsrc, 'win32' );
@@ -160,6 +165,10 @@ sub run {
160165
$new_env->{PROCESSOR_ARCHITECTURE} = 'x86';
161166
push @make_args, 'WIN64=undef';
162167
}
168+
if ($optimize_core) {
169+
push @make_args, "OPTIMIZE=${optimize_core}";
170+
$self->boss->message(3, "Building core using OPTIMIZE=${optimize_core}");
171+
}
163172

164173
my $maketool = $self->global->{maketool} || 'dmake';
165174
#create debuging build scripts in 'win32' subdir
@@ -256,8 +265,7 @@ sub run {
256265

257266
die "FATAL: perl.exe not properly installed" unless -f catfile($image_dir, qw/perl bin perl.exe/);
258267

259-
do {
260-
# could shell out to 'perl -i'?
268+
if ($optimize_cpan) {
261269
my $config_heavy = catfile($image_dir, qw/perl lib Config_heavy.pl/);
262270
if (-e $config_heavy) { # it should always be there
263271
$self->boss->message(3, "Updating optimize settings in Config_heavy.pl");
@@ -269,7 +277,7 @@ sub run {
269277
my $data = <$fh>;
270278
$fh->close;
271279
# now update the file
272-
$data =~ s/^(optimize=.+)$/optimize='-O2'/m;
280+
$data =~ s/^optimize=(.+)$/optimize='$optimize_cpan'/m;
273281
my $ro_flag = $self->_unset_ro($config_heavy);
274282
open my $ofh, '>', $config_heavy or die "Unable to open $config_heavy for writing, $?";
275283
print {$ofh} $data;

0 commit comments

Comments
 (0)