From be0e4ae0ce08bf86687e078f092f307b719c1ffa Mon Sep 17 00:00:00 2001 From: Chris 'BinGOs' Williams Date: Fri, 21 Mar 2025 13:41:43 +0000 Subject: [PATCH 1/3] Fix finding the correct cplusplus compiler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../lib/ExtUtils/CBuilder.pm | 2 +- .../lib/ExtUtils/CBuilder/Base.pm | 35 +++++++++++-------- .../lib/ExtUtils/CBuilder/Platform/Unix.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/VMS.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/Windows.pm | 2 +- .../ExtUtils/CBuilder/Platform/Windows/BCC.pm | 2 +- .../ExtUtils/CBuilder/Platform/Windows/GCC.pm | 2 +- .../CBuilder/Platform/Windows/MSVC.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/aix.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/android.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/cygwin.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/darwin.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/dec_osf.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/os2.pm | 2 +- 14 files changed, 34 insertions(+), 27 deletions(-) diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm index ddaf24da703e..958bce4e286a 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm @@ -7,7 +7,7 @@ use Perl::OSType qw/os_type/; use warnings; use strict; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA; # We only use this once - don't waste a symbol table entry on it. diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm index 3024de52ae9f..06748eede0be 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm @@ -9,7 +9,7 @@ use Text::ParseWords; use IPC::Cmd qw(can_run); use File::Temp qw(tempfile); -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION # More details about C/C++ compilers: # http://developers.sun.com/sunstudio/documentation/product/compiler.jsp @@ -51,24 +51,31 @@ sub new { ## If the path is just "cc", fileparse returns $ccpath as "./" $ccpath = "" if $self->{config}{cc} =~ /^\Q$ccbase$ccsfx\E$/; - + foreach my $cxx (@{$cc2cxx{$ccbase}}) { - my $cxx1 = File::Spec->catfile( $ccpath, $cxx . $ccsfx); - if( can_run( $cxx1 ) ) { - $self->{config}{cxx} = $cxx1; - last; - } - my $cxx2 = $cxx . $ccsfx; + if ( $ccpath ) { + my $cxx1 = File::Spec->catfile( $ccpath, $cxx . $ccsfx); + + if( can_run( $cxx1 ) ) { + $self->{config}{cxx} = $cxx1; + last; + } - if( can_run( $cxx2 ) ) { - $self->{config}{cxx} = $cxx2; - last; } + else { + my $cxx2 = $cxx . $ccsfx; + + if( can_run( $cxx2 ) ) { + $self->{config}{cxx} = $cxx2; + last; + } + + if( can_run( $cxx ) ) { + $self->{config}{cxx} = $cxx; + last; + } - if( can_run( $cxx ) ) { - $self->{config}{cxx} = $cxx; - last; } } unless ( exists $self->{config}{cxx} ) { diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm index bc7a4fe7b21e..d27fd9210dc4 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm @@ -4,7 +4,7 @@ use warnings; use strict; use ExtUtils::CBuilder::Base; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Base); sub link_executable { diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm index f7579a2bd5d0..d5bf13131419 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm @@ -4,7 +4,7 @@ use warnings; use strict; use ExtUtils::CBuilder::Base; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Base); use File::Spec::Functions qw(catfile catdir); diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm index 3ad649d281de..5497aba64368 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm @@ -8,7 +8,7 @@ use File::Spec; use ExtUtils::CBuilder::Base; use IO::File; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Base); =begin comment diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm index 737448fa053f..6856bf392aca 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm @@ -1,6 +1,6 @@ package ExtUtils::CBuilder::Platform::Windows::BCC; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION use strict; use warnings; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm index d2da1edb0077..ad7b3bdb5fd6 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm @@ -1,6 +1,6 @@ package ExtUtils::CBuilder::Platform::Windows::GCC; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION use warnings; use strict; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm index 2acca7aa3ef2..8102020abbad 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm @@ -1,6 +1,6 @@ package ExtUtils::CBuilder::Platform::Windows::MSVC; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION use warnings; use strict; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm index 373d025d6be3..c2df0357b1b6 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm @@ -5,7 +5,7 @@ use strict; use ExtUtils::CBuilder::Platform::Unix; use File::Spec; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Platform::Unix); sub need_prelink { 1 } diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm index 5eec4e55b809..827246fdbcc9 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm @@ -6,7 +6,7 @@ use File::Spec; use ExtUtils::CBuilder::Platform::Unix; use Config; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Platform::Unix); # The Android linker will not recognize symbols from diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm index 175d22ab5b36..39f63ad96bcd 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm @@ -5,7 +5,7 @@ use strict; use File::Spec; use ExtUtils::CBuilder::Platform::Unix; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Platform::Unix); # TODO: If a specific exe_file name is requested, if the exe created diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm index 42f28b1653f8..109cddcab4a4 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm @@ -5,7 +5,7 @@ use strict; use ExtUtils::CBuilder::Platform::Unix; use Config; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Platform::Unix); my ($osver) = split /\./, $Config{osvers}; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm index f020dcaec4e3..910f42f0d161 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm @@ -5,7 +5,7 @@ use strict; use ExtUtils::CBuilder::Platform::Unix; use File::Spec; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Platform::Unix); sub link_executable { diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm index 53e63b923fa6..cf96edf0d672 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm @@ -4,7 +4,7 @@ use warnings; use strict; use ExtUtils::CBuilder::Platform::Unix; -our $VERSION = '0.280240'; # VERSION +our $VERSION = '0.280241'; # VERSION our @ISA = qw(ExtUtils::CBuilder::Platform::Unix); sub need_prelink { 1 } From 5cda3c1170dad1732041e026e699fd91690e3738 Mon Sep 17 00:00:00 2001 From: Chris 'BinGOs' Williams Date: Fri, 21 Mar 2025 14:49:05 +0000 Subject: [PATCH 2/3] Added clang/clang++ to the C->C++ compiler mappings --- dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm index 06748eede0be..bc80f02c5144 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm @@ -24,6 +24,7 @@ my %cc2cxx = ( xlc => [ 'xlC' ], # IBM C/C++ Set, xlc without thread-safety xlc_r => [ 'xlC_r' ], # IBM C/C++ Set, xlc with thread-safety cl => [ 'cl' ], # Microsoft Visual Studio + clang => [ 'clang++' ], # LLVM compiler frontend ); sub new { From a9cee214e5d33cf5d28cb4af814d4e153ccdbcb0 Mon Sep 17 00:00:00 2001 From: Chris 'BinGOs' Williams Date: Tue, 25 Mar 2025 11:17:39 +0000 Subject: [PATCH 3/3] Remove literal tabs --- dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm index bc80f02c5144..01a76feb5731 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm @@ -60,7 +60,7 @@ sub new { if( can_run( $cxx1 ) ) { $self->{config}{cxx} = $cxx1; - last; + last; } } @@ -69,12 +69,12 @@ sub new { if( can_run( $cxx2 ) ) { $self->{config}{cxx} = $cxx2; - last; + last; } if( can_run( $cxx ) ) { $self->{config}{cxx} = $cxx; - last; + last; } }