Closed hakonhagland closed 3 years ago
Couldn't execute cc -arch x86_64 -g -pipe -fno-strict-aliasing -fstack-protector-strong \
-DPERL_USE_SAFE_PUTENV -Os "-I/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE" \
-c HASCOMPILERiHHX/TESTy9Go.c -o HASCOMPILERiHHX/TESTy9Go.o
I think the problem is the include path:
-I/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE
On my machine EXTERN.h
is located in another place, here:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE
The tests run fine if I include that directory:
$ CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/compare.t .. ok
All tests successful.
Files=1, Tests=3, 6 wallclock secs ( 0.02 usr 0.01 sys + 3.44 cusr 1.45 csys = 4.92 CPU)
Result: PASS
Does this patch solve the problem?
diff --git lib/ExtUtils/HasCompiler.pm lib/ExtUtils/HasCompiler.pm
index 08dd74b..ede455d 100644
--- lib/ExtUtils/HasCompiler.pm
+++ lib/ExtUtils/HasCompiler.pm
@@ -83,6 +83,9 @@ sub can_compile_loadable_object {
my $object_file = $abs_basename.$_o;
my $loadable_object = "$abs_basename.$dlext";
+ my $apple_core = $^O eq 'darwin' && $^X eq '/usr/bin/perl' && ($config->get('osvers') =~ /(\d+)/)[0] >= 18;
+ $incdir =~ s/"-I(\$\(PERL_INC\))"/-iwithsysroot "$1"/g if $apple_core;
+
my @commands;
if ($^O eq 'MSWin32' && $cc =~ /^cl/) {
push @commands, qq{$cc $ccflags $cccdlflags $optimize /I "$incdir" /c $source_name /Fo$object_file};
Unfortunately, it does not work.
First, I checked in the debugger $^X
is perl
and not /usr/bin/perl
, second, $incdir
is /System/Library/Perl/5.28/darwin-thread-multi-2level/CORE
so even if $apple_core
was true, the line:
$incdir =~ s/"-I(\$\(PERL_INC\))"/-iwithsysroot "$1"/g if $apple_core;
will not do anything.
How about this?
--- lib/ExtUtils/HasCompiler.pm
+++ lib/ExtUtils/HasCompiler.pm
@@ -100,6 +100,7 @@ sub can_compile_loadable_object {
}
else {
my @extra;
+ my $inc = qq{"-I$incdir"};
if ($^O eq 'MSWin32') {
my $lib = '-l' . ($libperl =~ /lib([^.]+)\./)[0];
push @extra, "$abs_basename.def", $lib, $perllibs;
@@ -114,7 +115,10 @@ sub can_compile_loadable_object {
elsif ($^O eq 'android') {
push @extra, qq{"-L$incdir"}, '-lperl', $perllibs;
}
- push @commands, qq{$cc $ccflags $optimize "-I$incdir" $cccdlflags -c $source_name -o $object_file};
+ elsif ($^O eq 'darwin' && $config->get('perlpath') eq '/usr/bin/perl' && ($config->get('osvers') =~ /(\d+)/)[0] >= 18) {
+ $inc = qq{-iwithsysroot "$incdir"};
+ }
+ push @commands, qq{$cc $ccflags $optimize $inc $cccdlflags -c $source_name -o $object_file};
push @commands, qq{$ld $object_file -o $loadable_object $lddlflags @extra};
}
Yes it works!
Released as 0.023.
I'd bet good money on ExtUtils::CBuilder
having the same bug, an issue for that should probably be filed as well.
Nevermind X_X Comment deleted.
I am on macOS Big Sur 11.1:
See also this isssue on stackoverflow.com