| File: | config/auto/frames.pm |
| Coverage: | 73.1% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2009, Parrot Foundation. | ||||
| 2 | # $Id: frames.pm 42017 2009-10-22 10:06:13Z mikehh $ | ||||
| 3 | |||||
| 4 - 14 | =head1 NAME config/auto/frames =head1 DESCRIPTION Determines whether the current platform is capable of building NCI call frames dynamically. Use the C<--buildframes> option to override the default value for your CPU architecture and operating system. =cut | ||||
| 15 | |||||
| 16 | package auto::frames; | ||||
| 17 | |||||
| 18 | 2 2 2 | use strict; | |||
| 19 | 2 2 2 | use warnings; | |||
| 20 | |||||
| 21 | 2 2 2 | use base qw(Parrot::Configure::Step); | |||
| 22 | |||||
| 23 | sub _init { | ||||
| 24 | 2 | my $self = shift; | |||
| 25 | 2 | my %data; | |||
| 26 | 2 | $data{description} = q{Determine call frame building capability}; | |||
| 27 | 2 | $data{result} = q{}; | |||
| 28 | 2 | return \%data; | |||
| 29 | } | ||||
| 30 | |||||
| 31 | sub runstep { | ||||
| 32 | 2 | my ( $self, $conf ) = @_; | |||
| 33 | |||||
| 34 | 2 | my $can_build_call_frames = _call_frames_buildable($conf); | |||
| 35 | |||||
| 36 | 2 | $self->_handle_can_build_call_frames( $conf, $can_build_call_frames ); | |||
| 37 | |||||
| 38 | 2 | return 1; | |||
| 39 | } | ||||
| 40 | |||||
| 41 | sub _call_frames_buildable { | ||||
| 42 | 8 | my $conf = shift; | |||
| 43 | |||||
| 44 | 8 | my $osname = $conf->data->get('osname'); | |||
| 45 | 8 | my $cpuarch = $conf->data->get('cpuarch'); | |||
| 46 | 8 | my $nvsize = $conf->data->get('nvsize'); | |||
| 47 | 8 | my $can_build_call_frames; | |||
| 48 | |||||
| 49 | 8 | if (defined $conf->options->get('buildframes')) { | |||
| 50 | 2 | $can_build_call_frames = $conf->options->get('buildframes'); | |||
| 51 | } | ||||
| 52 | else { | ||||
| 53 | # TT #1132 | ||||
| 54 | # Temporary disable build frames automatically. | ||||
| 55 | #$can_build_call_frames = ($nvsize == 8 && $cpuarch eq 'i386' | ||||
| 56 | # && $osname ne 'darwin'); | ||||
| 57 | 6 | $can_build_call_frames = 0; | |||
| 58 | } | ||||
| 59 | 8 | return $can_build_call_frames; | |||
| 60 | } | ||||
| 61 | |||||
| 62 | sub _handle_can_build_call_frames { | ||||
| 63 | 4 | my ($self, $conf, $can_build_call_frames) = @_; | |||
| 64 | 4 | if ( $can_build_call_frames ) { | |||
| 65 | 1 | $conf->data->set( | |||
| 66 | cc_build_call_frames => '-DCAN_BUILD_CALL_FRAMES', | ||||
| 67 | ); | ||||
| 68 | # test for executable malloced memory | ||||
| 69 | 1 | my $osname = $conf->data->get( 'osname' ); | |||
| 70 | 1 | if ( -e "config/auto/frames/test_exec_${osname}_c.in" ) { | |||
| 71 | 0 | $conf->cc_gen("config/auto/frames/test_exec_${osname}_c.in"); | |||
| 72 | 0 0 | eval { $conf->cc_build(); }; | |||
| 73 | 0 | if ($@) { | |||
| 74 | 0 | $conf->data->set( has_exec_protect => 0 ); | |||
| 75 | } | ||||
| 76 | else { | ||||
| 77 | 0 | my $exec_protect_test = ( | |||
| 78 | $conf->cc_run(0) !~ /ok/ && $conf->cc_run(1) =~ /ok/ | ||||
| 79 | ); | ||||
| 80 | 0 | if ($exec_protect_test) { | |||
| 81 | 0 | $conf->data->set( has_exec_protect => 1 ); | |||
| 82 | } | ||||
| 83 | else { | ||||
| 84 | 0 | $conf->data->set( has_exec_protect => 0 ); | |||
| 85 | } | ||||
| 86 | } | ||||
| 87 | 0 | $conf->cc_clean(); | |||
| 88 | } | ||||
| 89 | else { | ||||
| 90 | 1 | $conf->data->set( has_exec_protect => 0 ); | |||
| 91 | } | ||||
| 92 | 1 | $self->set_result( 'yes' ); | |||
| 93 | } | ||||
| 94 | else { | ||||
| 95 | 3 | $conf->data->set( cc_build_call_frames => ''); | |||
| 96 | 3 | $self->set_result( 'no' ); | |||
| 97 | } | ||||
| 98 | 4 | return 1; | |||
| 99 | } | ||||
| 100 | |||||
| 101 | 1; | ||||
| 102 | |||||
| 103 | # Local Variables: | ||||
| 104 | # mode: cperl | ||||
| 105 | # cperl-indent-level: 4 | ||||
| 106 | # fill-column: 100 | ||||
| 107 | # End: | ||||
| 108 | # vim: expandtab shiftwidth=4: | ||||