Skip to content

Commit ea0856c

Browse files
committed
Fix finding the correct cplusplus compiler
ExtUtils::CBuilder was using a slightly maverick method for finding the matching cplusplus compiler to the c compiler used to build perl. On a Linux system with a perl built with the Oracle Developer cc cc='/opt/oracle/developerstudio12.6/bin/cc' Errors were observed: "c++: error: unrecognized command line option ‘-KPIC’; did you mean ‘-fPIC’?" The cplusplus command for Oracle Developer suite is CC not c++ and the detection was picking up the system c++ (g++). If there is a ccpath, the code should exhaust all the options and not fail through to using no path. Added a test to exercise ccpath behaviour Added clang/clang++ to the C->C++ compiler mappings
1 parent 3c2aa9f commit ea0856c

File tree

15 files changed

+48
-29
lines changed

15 files changed

+48
-29
lines changed

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Perl::OSType qw/os_type/;
77

88
use warnings;
99
use strict;
10-
our $VERSION = '0.280240'; # VERSION
10+
our $VERSION = '0.280241'; # VERSION
1111
our @ISA;
1212

1313
# We only use this once - don't waste a symbol table entry on it.

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use Text::ParseWords;
99
use IPC::Cmd qw(can_run);
1010
use File::Temp qw(tempfile);
1111

12-
our $VERSION = '0.280240'; # VERSION
12+
our $VERSION = '0.280241'; # VERSION
1313

1414
# More details about C/C++ compilers:
1515
# http://developers.sun.com/sunstudio/documentation/product/compiler.jsp
@@ -24,6 +24,7 @@ my %cc2cxx = (
2424
xlc => [ 'xlC' ], # IBM C/C++ Set, xlc without thread-safety
2525
xlc_r => [ 'xlC_r' ], # IBM C/C++ Set, xlc with thread-safety
2626
cl => [ 'cl' ], # Microsoft Visual Studio
27+
clang => [ 'clang++' ], # LLVM compiler frontend
2728
);
2829

2930
sub new {
@@ -51,24 +52,31 @@ sub new {
5152

5253
## If the path is just "cc", fileparse returns $ccpath as "./"
5354
$ccpath = "" if $self->{config}{cc} =~ /^\Q$ccbase$ccsfx\E$/;
54-
55+
5556
foreach my $cxx (@{$cc2cxx{$ccbase}}) {
56-
my $cxx1 = File::Spec->catfile( $ccpath, $cxx . $ccsfx);
5757

58-
if( can_run( $cxx1 ) ) {
59-
$self->{config}{cxx} = $cxx1;
60-
last;
61-
}
62-
my $cxx2 = $cxx . $ccsfx;
58+
if ( $ccpath ) {
59+
my $cxx1 = File::Spec->catfile( $ccpath, $cxx . $ccsfx);
60+
61+
if( can_run( $cxx1 ) ) {
62+
$self->{config}{cxx} = $cxx1;
63+
last;
64+
}
6365

64-
if( can_run( $cxx2 ) ) {
65-
$self->{config}{cxx} = $cxx2;
66-
last;
6766
}
67+
else {
68+
my $cxx2 = $cxx . $ccsfx;
69+
70+
if( can_run( $cxx2 ) ) {
71+
$self->{config}{cxx} = $cxx2;
72+
last;
73+
}
74+
75+
if( can_run( $cxx ) ) {
76+
$self->{config}{cxx} = $cxx;
77+
last;
78+
}
6879

69-
if( can_run( $cxx ) ) {
70-
$self->{config}{cxx} = $cxx;
71-
last;
7280
}
7381
}
7482
unless ( exists $self->{config}{cxx} ) {

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use warnings;
44
use strict;
55
use ExtUtils::CBuilder::Base;
66

7-
our $VERSION = '0.280240'; # VERSION
7+
our $VERSION = '0.280241'; # VERSION
88
our @ISA = qw(ExtUtils::CBuilder::Base);
99

1010
sub link_executable {

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use warnings;
44
use strict;
55
use ExtUtils::CBuilder::Base;
66

7-
our $VERSION = '0.280240'; # VERSION
7+
our $VERSION = '0.280241'; # VERSION
88
our @ISA = qw(ExtUtils::CBuilder::Base);
99

1010
use File::Spec::Functions qw(catfile catdir);

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use File::Spec;
88
use ExtUtils::CBuilder::Base;
99
use IO::File;
1010

11-
our $VERSION = '0.280240'; # VERSION
11+
our $VERSION = '0.280241'; # VERSION
1212
our @ISA = qw(ExtUtils::CBuilder::Base);
1313

1414
=begin comment

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ExtUtils::CBuilder::Platform::Windows::BCC;
22

3-
our $VERSION = '0.280240'; # VERSION
3+
our $VERSION = '0.280241'; # VERSION
44

55
use strict;
66
use warnings;

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ExtUtils::CBuilder::Platform::Windows::GCC;
22

3-
our $VERSION = '0.280240'; # VERSION
3+
our $VERSION = '0.280241'; # VERSION
44

55
use warnings;
66
use strict;

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ExtUtils::CBuilder::Platform::Windows::MSVC;
22

3-
our $VERSION = '0.280240'; # VERSION
3+
our $VERSION = '0.280241'; # VERSION
44

55
use warnings;
66
use strict;

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use ExtUtils::CBuilder::Platform::Unix;
66
use File::Spec;
77

8-
our $VERSION = '0.280240'; # VERSION
8+
our $VERSION = '0.280241'; # VERSION
99
our @ISA = qw(ExtUtils::CBuilder::Platform::Unix);
1010

1111
sub need_prelink { 1 }

dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use File::Spec;
66
use ExtUtils::CBuilder::Platform::Unix;
77
use Config;
88

9-
our $VERSION = '0.280240'; # VERSION
9+
our $VERSION = '0.280241'; # VERSION
1010
our @ISA = qw(ExtUtils::CBuilder::Platform::Unix);
1111

1212
# The Android linker will not recognize symbols from

0 commit comments

Comments
 (0)