Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ExtUtils/CppGuess.pm
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ sub _cc_is_clang {
$self->{is_clang} = 0;
my $cc_version = _capture( "$cc --version" );
if (
$cc_version =~ m/\A(?:clang|apple llvm)/i
$cc_version =~ m/\A(?:(?:\S+ )?clang version|apple llvm)/i
|| $cc eq 'clang' # because why would they lie?
|| (($self->_config->{gccversion} || '') =~ /Clang|Apple LLVM/),
) {
Expand Down
55 changes: 55 additions & 0 deletions t/002_icpp.t
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,61 @@ my @METHODS = qw(

run_test(@$_) for @DATA;

# mock some compiler output
my $old_capture = \&ExtUtils::CppGuess::_capture;
our $CAPTURES;
{
no warnings "redefine";
*ExtUtils::CppGuess::_capture =
sub {
my @cmd = @_;
if (my $result = $CAPTURES->{"@cmd"}) {
note "Mocking output of @cmd: $result";
return $result;
}
goto &$old_capture;
};
}
my @CAPS =
(
[
{ cc => "cc", config => { ccflags => '' } },
{
is_sunstudio => 0,
is_msvc => undef, is_gcc => undef, is_clang => 1,
compiler_command => 'clang++ -xc++ -Wno-reserved-user-defined-literal',
linker_flags => '-lstdc++',
},
{ "cc --version" => "OpenBSD clang version 10.0.1" },
],
[
{ cc => "clang-15", config => { ccflags => '' } },
{
is_sunstudio => 0,
is_msvc => undef, is_gcc => undef, is_clang => 1,
compiler_command => 'clang++ -xc++ -Wno-reserved-user-defined-literal',
linker_flags => '-lstdc++',
},
{ "clang-15 --version" => "Debian clang version 15.0.7" },
],
[
{ cc => "cc", config => { ccflags => '' } },
{
is_sunstudio => 0,
is_msvc => undef, is_gcc => 1, is_clang => 0,
compiler_command => 'g++ -xc++',
linker_flags => '-lstdc++',
},
{ "cc --version" => "cc (Debian 12.2.0-14) 12.2.0" },
],
);

for my $test (@CAPS) {
my ($args, $expect, $cap) = @$test;
local $CAPTURES = $cap;
run_test($args, $expect);
}

done_testing;

sub run_test {
Expand Down