Skip to content

Commit

Permalink
GH-320 Reorder potential library paths for macOS Monterey compatibility.
Browse files Browse the repository at this point in the history
Running 'perl Makefile.PL' may fail with:
   WARNING: .../perl is loading libcrypto in an unsafe way

See #329
and https://openradar.appspot.com/FB9725981 (linked by GH-329) for
more information.

To summarise why this commit helps in this case:

  The failure is triggered when the prospective library directory exists but
  does not contain the desired library file. That is, $prefix/lib64 does not
  trigger the failure because the directory pointed by OPENSSL_PREFIX does not
  contain lib64 subdirectory.
  • Loading branch information
h-vn committed Dec 29, 2021
1 parent 175e1f4 commit 8ab1cfe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ Revision history for Perl extension Net::SSLeay.
functions return double and options functions return
long. This partially fixes GH-315, 32bit integer Perls need
to be handled separately.
- Work around macOS Monterey build failure during 'perl
Makefile.PL' that causes perl to exit with 'WARNING:
.../perl is loading libcrypto in an unsafe way' or similar
message. This fixes GH-329. Thanks to Daniel J. Luke for the
report and John Napiorkowski for additional help.

1.91_01 2021-10-24
- Correct X509_STORE_CTX_init() return value to integer. Previous
Expand Down
22 changes: 19 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,25 @@ sub ssleay_get_build_opts {
}
}

# Note: the order matters for macOS Monterey.
for ("$prefix/lib64", "$prefix/lib", "$prefix/out32dll", $prefix) {
push @{$opts->{lib_paths}}, $_ if -d $_;
# Directory order matters. With macOS Monterey a poisoned dylib is
# returned if the directory exists without the desired
# library. See GH-329 for more information. With Strawberry Perl
# 5.26 and later the paths must be in different order or the link
# phase fails.
my @try_lib_paths = (
["$prefix/lib64", "$prefix/lib", "$prefix/out32dll", $prefix] => sub {$OSNAME eq 'darwin' },
[$prefix, "$prefix/lib64", "$prefix/lib", "$prefix/out32dll"] => sub { 1 },
);
while (
!defined $opts->{lib_paths}
&& defined( my $dirs = shift @try_lib_paths )
&& defined( my $cond = shift @try_lib_paths )
) {
if ( $cond->() ) {
foreach my $dir (@{$dirs}) {
push @{$opts->{lib_paths}}, $dir if -d $dir;
}
}
}

print <<EOM;
Expand Down

0 comments on commit 8ab1cfe

Please sign in to comment.