| 1 | package Alien::OpenMP::configure; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | our $VERSION = '0.3.10'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # Alien::OpenMP describes the extension toolchain of the running Perl. | ||||||||||||||||||||||||||||
| 9 | # Do not silently let ENV{CC} select a compiler different from Config{cc}; | ||||||||||||||||||||||||||||
| 10 | # downstream XS/Inline tooling normally returns to Perl's configured compiler. | ||||||||||||||||||||||||||||
| 11 | 4 | our $CCNAME = $Config::Config{cc}; | |||||||||||||||||||||||||||
| 12 | 4 | our $OS = $^O; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Test hook. Production code leaves this undefined and detects the compiler | ||||||||||||||||||||||||||||
| 15 | # from its predefined macros. | ||||||||||||||||||||||||||||
| 16 | 4 | our $COMPILER_FAMILY; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | my $checked = 0; | |||||||||||||||||||||||||||
| 19 | 4 | my $profile; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub auto_include { | ||||||||||||||||||||||||||
|
Subroutine
auto_include: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 0 | shift->_update_supported; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | return $profile->{auto_include} || q{}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$profile->{'auto_include'} || ''
MC/DC0%0/1
$profile->{'auto_include'} || ''
$profile->{'auto_include'}
Truth table0%0/2
A
A= $profile->{'auto_include'}
| |||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 10 | ▶ | sub cflags { | ||||||||||||||||||||||||||
|
Subroutine
cflags: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 10 | shift->_update_supported; | |||||||||||||||||||||||||||
| 28 | 10 | ▶ | return join ' ', @{$profile->{cflags} || []}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$profile->{'cflags'} || []
MC/DC0%0/1
$profile->{'cflags'} || []
$profile->{'cflags'}
Truth table50%1/2
A
A= $profile->{'cflags'}
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 10 | ▶ | sub is_known { | ||||||||||||||||||||||||||
|
Subroutine
is_known: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 10 | shift->_update_supported; | |||||||||||||||||||||||||||
| 33 | 10 | return !!$profile->{known}; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub lddlflags { __PACKAGE__->libs } | ||||||||||||||||||||||||||
|
Subroutine
lddlflags: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 10 | ▶ | sub libs { | ||||||||||||||||||||||||||
|
Subroutine
libs: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 10 | shift->_update_supported; | |||||||||||||||||||||||||||
| 40 | 10 | ▶ | return join ' ', @{$profile->{libs} || []}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$profile->{'libs'} || []
MC/DC0%0/1
$profile->{'libs'} || []
$profile->{'libs'}
Truth table50%1/2
A
A= $profile->{'libs'}
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 9 | ▶ | sub compiler_family { | ||||||||||||||||||||||||||
|
Subroutine
compiler_family: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 9 | shift->_update_supported; | |||||||||||||||||||||||||||
| 45 | 9 | return $profile->{family}; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub unsupported { | ||||||||||||||||||||||||||
|
Subroutine
unsupported: called CC=11 SCAR=35.7
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 1 | my ($self, $build) = (shift, shift); | |||||||||||||||||||||||||||
| 50 | 1 | ▶ | my $family = eval { $self->compiler_family } || 'unknown'; | ||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
$self->compiler_family
}
} || 'unknown'
MC/DC0%0/1
eval {
do {
$self->compiler_family
}
} || 'unknown'
eval {
do {
$self->compiler_family
}
}
Truth table50%1/2
A
A= eval {
do {
$self->compiler_family
}
}
| |||||||||||||||||||||||||||||
| 51 | 1 | my @msg = ("Compiler '$CCNAME' ($family) does not have a supported OpenMP configuration"); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | ▶ | if ($OS eq 'darwin' && $family eq 'clang') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Alien::OpenMP::configure::OS eq "darwin" and $family eq "clang"
MC/DC0%0/2
$Alien::OpenMP::configure::OS eq "darwin" and $family eq "clang"
$Alien::OpenMP::configure::OS eq "darwin"
$family eq "clang"
Truth table33%1/3
A and B
A= $Alien::OpenMP::configure::OS eq "darwin"B= $family eq "clang"
| |||||||||||||||||||||||||||||
| 54 | 0 | push @msg, 'Apple Clang requires an OpenMP runtime such as Homebrew or MacPorts libomp'; | |||||||||||||||||||||||||||
| 55 | 0 | push @msg, ' brew install libomp'; | |||||||||||||||||||||||||||
| 56 | 0 | push @msg, ' port install libomp'; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | ▶ | if (ref($build)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return if $build->install_prop->{alien_openmp_compiler_has_openmp}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | unshift @msg, "phase = @{[$build->meta->{phase}]}"; | |||||||||||||||||||||||||||
| 62 | 0 | $build->log($_) for @msg; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | ▶ | elsif ($build && (my $log = $build->can('log'))) { | |||||||||||||||||||||||||||
|
Condition33%1/3
$build and my $log = $build->can("log")
MC/DC0%0/2
$build and my $log = $build->can("log")
$build
my $log = $build->can("log")
Truth table33%1/3
A and B
A= $buildB= my $log = $build->can("log")
| |||||||||||||||||||||||||||||
| 65 | 0 | unshift @msg, "phase = @{[$build->meta->{phase}]}"; | |||||||||||||||||||||||||||
| 66 | 0 | $log->($_) for @msg; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | else { | ||||||||||||||||||||||||||||
| 69 | 1 | warn join q{>}, __PACKAGE__, " $_\n" for @msg; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 1 | print "OS Unsupported\n"; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | ▶ | sub version_from_preprocessor { | ||||||||||||||||||||||||||
|
Subroutine
version_from_preprocessor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 3 | my ($self, $lines) = @_; | |||||||||||||||||||||||||||
| 76 | 3 | my ($define) = $lines =~ /^\s*#\s*define\s+_OPENMP\s+([0-9]+)\b/m; | |||||||||||||||||||||||||||
| 77 | return { | ||||||||||||||||||||||||||||
| 78 | 3 | openmp_version => $define, | |||||||||||||||||||||||||||
| 79 | version => _openmp_defined($define), | ||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 3 | ▶ | sub _openmp_defined { | ||||||||||||||||||||||||||
|
Subroutine
_openmp_defined: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 84 | 3 | my $define = pop; | |||||||||||||||||||||||||||
| 85 | 3 | my $versions = { | |||||||||||||||||||||||||||
| 86 | 200505 => '2.5', | ||||||||||||||||||||||||||||
| 87 | 200805 => '3.0', | ||||||||||||||||||||||||||||
| 88 | 201107 => '3.1', | ||||||||||||||||||||||||||||
| 89 | 201307 => '4.0', | ||||||||||||||||||||||||||||
| 90 | 201511 => '4.5', | ||||||||||||||||||||||||||||
| 91 | 201811 => '5.0', | ||||||||||||||||||||||||||||
| 92 | 202011 => '5.1', | ||||||||||||||||||||||||||||
| 93 | 202111 => '5.2', | ||||||||||||||||||||||||||||
| 94 | 202411 => '6.0', | ||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||
| 96 | 3 | ▶ | return $versions->{$define || ''} || 'unknown'; | ||||||||||||||||||||||||||
|
Condition100%4/4
$$versions{$define or ''} || 'unknown'
$define || ''
MC/DC100%1/1
$$versions{$define or ''} || 'unknown'
$$versions{$define or ''}
MC/DC100%1/1
$define || ''
$define
Truth table100%2/2
A
A= $$versions{$define or ''}
Truth table100%2/2
A
A= $define
| |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 9 | ▶ | sub _reset { | ||||||||||||||||||||||||||
|
Subroutine
_reset: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 100 | 9 | $checked = 0; | |||||||||||||||||||||||||||
| 101 | 9 | $profile = undef; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 39 | ▶ | sub _update_supported { | ||||||||||||||||||||||||||
|
Subroutine
_update_supported: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||
| 105 | 39 | ▶ | return if $checked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 10 | require File::Basename; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 10 | ▶ | my $command = $CCNAME || q{}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Alien::OpenMP::configure::CCNAME || ''
MC/DC0%0/1
$Alien::OpenMP::configure::CCNAME || ''
$Alien::OpenMP::configure::CCNAME
Truth table50%1/2
A
A= $Alien::OpenMP::configure::CCNAME
| |||||||||||||||||||||||||||||
| 109 | 10 | my $basename = File::Basename::basename($command); | |||||||||||||||||||||||||||
| 110 | 10 | ▶ | my $family = $COMPILER_FAMILY || _compiler_flavour(); | ||||||||||||||||||||||||||
|
Condition66%2/3
$Alien::OpenMP::configure::COMPILER_FAMILY || _compiler_flavour()
MC/DC0%0/2
$Alien::OpenMP::configure::COMPILER_FAMILY || _compiler_flavour()
$Alien::OpenMP::configure::COMPILER_FAMILY
_compiler_flavour()
Truth table66%2/3
A || B
A= $Alien::OpenMP::configure::COMPILER_FAMILYB= _compiler_flavour()
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 10 | $profile = { | |||||||||||||||||||||||||||
| 113 | known => 0, | ||||||||||||||||||||||||||||
| 114 | family => $family, | ||||||||||||||||||||||||||||
| 115 | cflags => [], | ||||||||||||||||||||||||||||
| 116 | libs => [], | ||||||||||||||||||||||||||||
| 117 | auto_include => '#include <omp.h>', | ||||||||||||||||||||||||||||
| 118 | }; | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 10 | ▶ | if ($family eq 'gcc') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 121 | # GCC has used -fopenmp to enable compilation and runtime linkage since | ||||||||||||||||||||||||||||
| 122 | # its original OpenMP support. This is also correct for GNU GCC on macOS. | ||||||||||||||||||||||||||||
| 123 | 7 | $profile->{known} = 1; | |||||||||||||||||||||||||||
| 124 | 7 | $profile->{cflags} = ['-fopenmp']; | |||||||||||||||||||||||||||
| 125 | 7 | $profile->{libs} = ['-fopenmp']; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | elsif ($family eq 'clang') { | ||||||||||||||||||||||||||||
| 128 | 2 | $profile->{known} = 1; | |||||||||||||||||||||||||||
| 129 | 2 | ▶ | if ($OS eq 'darwin') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | $profile->{cflags} = [ '-Xclang', '-fopenmp' ]; | |||||||||||||||||||||||||||
| 131 | 0 | $profile->{libs} = ['-lomp']; | |||||||||||||||||||||||||||
| 132 | 0 | _add_darwin_libomp_paths($profile); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||
| 135 | # Upstream LLVM Clang accepts -fopenmp directly. Probe::CBuilder is the | ||||||||||||||||||||||||||||
| 136 | # final authority and will reject installations lacking headers/runtime. | ||||||||||||||||||||||||||||
| 137 | 2 | $profile->{cflags} = ['-fopenmp']; | |||||||||||||||||||||||||||
| 138 | 2 | $profile->{libs} = ['-fopenmp']; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | # Keep basename available for diagnostics without using it as the primary | ||||||||||||||||||||||||||||
| 143 | # compiler-family detector. This supports gcc-16, target-prefixed gcc, etc. | ||||||||||||||||||||||||||||
| 144 | 10 | $CCNAME = $command; | |||||||||||||||||||||||||||
| 145 | 10 | $checked++; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub _add_darwin_libomp_paths { | ||||||||||||||||||||||||||
|
Subroutine
_add_darwin_libomp_paths: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 149 | 0 | my ($p) = @_; | |||||||||||||||||||||||||||
| 150 | 0 | require File::Which; | |||||||||||||||||||||||||||
| 151 | 0 | require Path::Tiny; | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if (my $brew = File::Which::which('brew')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 0 | my $prefix = qx{$brew --prefix libomp 2>/dev/null}; | |||||||||||||||||||||||||||
| 155 | 0 | chomp $prefix; | |||||||||||||||||||||||||||
| 156 | 0 | ▶ | if ($prefix) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 0 | push @{$p->{cflags}}, "-I$prefix/include"; | |||||||||||||||||||||||||||
| 158 | 0 | unshift @{$p->{libs}}, "-L$prefix/lib"; | |||||||||||||||||||||||||||
| 159 | 0 | return; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (my $port = File::Which::which('port')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 0 | my $prefix = Path::Tiny->new($port)->parent->parent; | |||||||||||||||||||||||||||
| 165 | 0 | push @{$p->{cflags}}, "-I$prefix/include/libomp"; | |||||||||||||||||||||||||||
| 166 | 0 | unshift @{$p->{libs}}, "-L$prefix/lib/libomp"; | |||||||||||||||||||||||||||
| 167 | 0 | return; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | # Conservative fallbacks for conventional Intel/Apple-Silicon Homebrew. | ||||||||||||||||||||||||||||
| 171 | 0 | push @{$p->{cflags}}, '-I/usr/local/opt/libomp/include', '-I/opt/homebrew/opt/libomp/include'; | |||||||||||||||||||||||||||
| 172 | 0 | unshift @{$p->{libs}}, '-L/usr/local/opt/libomp/lib', '-L/opt/homebrew/opt/libomp/lib'; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub _compiler_flavour { | ||||||||||||||||||||||||||
|
Subroutine
_compiler_flavour: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 176 | 1 | my $defines = _compiler_defines(); | |||||||||||||||||||||||||||
| 177 | 1 | return _compiler_family_from_defines($defines); | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 4 | ▶ | sub _compiler_family_from_defines { | ||||||||||||||||||||||||||
|
Subroutine
_compiler_family_from_defines: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 181 | 4 | my ($defines) = @_; | |||||||||||||||||||||||||||
| 182 | 4 | ▶ | return 'clang' if $defines =~ /^\s*#\s*define\s+__clang__\b/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 3 | ▶ | return 'gcc' if $defines =~ /^\s*#\s*define\s+__GNUC__\b/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 1 | return 'unknown'; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub _openmp_defines { | ||||||||||||||||||||||||||
|
Subroutine
_openmp_defines: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 188 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 189 | 0 | require Text::ParseWords; | |||||||||||||||||||||||||||
| 190 | 0 | ▶ | my @flags = Text::ParseWords::shellwords($self->cflags || q{}); | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->cflags || ''
MC/DC0%0/1
$self->cflags || ''
$self->cflags
Truth table0%0/2
A
A= $self->cflags
| |||||||||||||||||||||||||||||
| 191 | 0 | return _compiler_defines(@flags); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 1 | ▶ | sub _compiler_defines { | ||||||||||||||||||||||||||
|
Subroutine
_compiler_defines: called CC=8 SCAR=21.8
| |||||||||||||||||||||||||||||
| 195 | 1 | my @extra = @_; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 1 | require File::Temp; | |||||||||||||||||||||||||||
| 198 | 1 | require IPC::Open3; | |||||||||||||||||||||||||||
| 199 | 1 | require Text::ParseWords; | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 1 | ▶ | my @cc = Text::ParseWords::shellwords($CCNAME || q{}); | ||||||||||||||||||||||||||
|
Condition50%1/2
$Alien::OpenMP::configure::CCNAME || ''
MC/DC0%0/1
$Alien::OpenMP::configure::CCNAME || ''
$Alien::OpenMP::configure::CCNAME
Truth table50%1/2
A
A= $Alien::OpenMP::configure::CCNAME
| |||||||||||||||||||||||||||||
| 202 | 1 | ▶ | return q{} unless @cc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | # Do not drive the preprocessor through stdin. Strawberry Perl/MinGW GCC | ||||||||||||||||||||||||||||
| 205 | # can hang when gcc's stdin/stdout/stderr are all connected to open3 pipes. | ||||||||||||||||||||||||||||
| 206 | # Use a real temporary C file and direct stdout/stderr to temporary files. | ||||||||||||||||||||||||||||
| 207 | # Passing already-open output handles to open3 avoids pipe-buffer deadlocks. | ||||||||||||||||||||||||||||
| 208 | 1 | my ($source_fh, $source) = File::Temp::tempfile(SUFFIX => '.c', UNLINK => 0); | |||||||||||||||||||||||||||
| 209 | 1 | print {$source_fh} "\n"; | |||||||||||||||||||||||||||
| 210 | 1 | close $source_fh; | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 1 | my ($out_fh, $out_name) = File::Temp::tempfile(UNLINK => 1); | |||||||||||||||||||||||||||
| 213 | 1 | my ($err_fh, $err_name) = File::Temp::tempfile(UNLINK => 1); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 1 | my $in; | |||||||||||||||||||||||||||
| 216 | 1 | my $out = '>&' . fileno($out_fh); | |||||||||||||||||||||||||||
| 217 | 1 | my $err = '>&' . fileno($err_fh); | |||||||||||||||||||||||||||
| 218 | 1 | my $pid = eval { | |||||||||||||||||||||||||||
| 219 | 1 | IPC::Open3::open3( | |||||||||||||||||||||||||||
| 220 | $in, | ||||||||||||||||||||||||||||
| 221 | $out, | ||||||||||||||||||||||||||||
| 222 | $err, | ||||||||||||||||||||||||||||
| 223 | @cc, | ||||||||||||||||||||||||||||
| 224 | @extra, | ||||||||||||||||||||||||||||
| 225 | qw(-dM -E), | ||||||||||||||||||||||||||||
| 226 | $source, | ||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||
| 228 | }; | ||||||||||||||||||||||||||||
| 229 | 1 | ▶ | unless ($pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | unlink $source; | |||||||||||||||||||||||||||
| 231 | 0 | close $out_fh; | |||||||||||||||||||||||||||
| 232 | 0 | close $err_fh; | |||||||||||||||||||||||||||
| 233 | 0 | return q{}; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 1 | ▶ | close $in if $in; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 1 | waitpid $pid, 0; | |||||||||||||||||||||||||||
| 238 | 1 | my $status = $?; | |||||||||||||||||||||||||||
| 239 | 1 | unlink $source; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 1 | ▶ | seek $out_fh, 0, 0 or return q{}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 1 | local $/; | |||||||||||||||||||||||||||
| 243 | 1 | ▶ | my $defines = <$out_fh> || q{}; | ||||||||||||||||||||||||||
|
Condition50%1/2
readline $out_fh || ''
MC/DC0%0/1
readline $out_fh || ''
readline $out_fh
Truth table50%1/2
A
A= readline $out_fh
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 1 | close $out_fh; | |||||||||||||||||||||||||||
| 246 | 1 | close $err_fh; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 1 | ▶ | return $status == 0 ? $defines : q{}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 4 | 1; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =encoding utf8 | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | =head1 NAME | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | Alien::OpenMP::configure - Install time configuration helper | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | Internal helper for identifying the C compiler configured into the running | ||||||||||||||||||||||||||||
| 262 | Perl and supplying the OpenMP flags used by Alien::OpenMP. Compiler family | ||||||||||||||||||||||||||||
| 263 | is detected from predefined compiler macros rather than executable names, so | ||||||||||||||||||||||||||||
| 264 | versioned and target-prefixed GCC drivers are handled without special cases. | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | The running Perl's C<$Config{cc}> is authoritative. C<ENV{CC}> is deliberately | ||||||||||||||||||||||||||||
| 267 | not used to switch toolchains because normal XS and Inline::C builds inherit | ||||||||||||||||||||||||||||
| 268 | Perl's configured compiler and ABI settings. | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | =head1 METHODS | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 auto_include | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Return the OpenMP include inserted for Inline::C. | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =head2 cflags | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | Return compiler flags that enable OpenMP. | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =head2 compiler_family | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | Return C<gcc>, C<clang>, or C<unknown> for the configured compiler. | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =head2 is_known | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | Return true when this compiler/platform has a known OpenMP configuration. | ||||||||||||||||||||||||||||
| 287 | The subsequent compile/link probe remains the final capability check. | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | =head2 lddlflags | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | A synonym for L</libs>. | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =head2 libs | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | Return link flags needed for the OpenMP runtime. | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =head2 unsupported | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | Report an unsupported compiler/platform combination. | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head2 version_from_preprocessor | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | Parse C<#define _OPENMP> from preprocessor output and return both its dated | ||||||||||||||||||||||||||||
| 304 | value and the corresponding OpenMP specification version. This indicates the | ||||||||||||||||||||||||||||
| 305 | specification date advertised by the compiler; it is not a guarantee that every | ||||||||||||||||||||||||||||
| 306 | feature in that specification is implemented. | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =cut | ||||||||||||||||||||||||||||