Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install DateTime@1.63 for perl-5.10.1 on macOS 14 Sonoma #141

Closed
bombsimon opened this issue Oct 27, 2023 · 8 comments
Closed

Can't install DateTime@1.63 for perl-5.10.1 on macOS 14 Sonoma #141

bombsimon opened this issue Oct 27, 2023 · 8 comments

Comments

@bombsimon
Copy link

Hey, thanks for this awesome package!

I have a project (and pipeline) that uses the latest version of DateTime. With the latest auto bump of my action I noticed that I can no longer install latest DateTime (currently at 1.63) on Perl 5.10.1 and macOS 14. Here's a link to a failed pipeline.

! Installing DateTime failed. See /Users/runner/.cpanm/work/1698418075.3228/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'DateTime' is not installed, Module 'DateTime::Duration' is not installed
! Bailing out the installation for ..

To try to sort this out I installed perl-5.10.1 locally on my macOS 14 machine but when I try to install DateTime I get the same issue.

--> Working on DateTime
Fetching http://www.cpan.org/authors/id/D/DR/DROLSKY/DateTime-1.63.tar.gz ... OK
Configuring DateTime-1.63 ... OK
Building and testing DateTime-1.63 ... FAIL
! Installing DateTime failed. See /Users/simon/.cpanm/work/1698444409.31367/build.log for details. Retry with --force to force install it.

Looking at the build.log I see that all the test fails with a similar error:

t/00-report-prereqs.t .... ok
#   Failed test 'use DateTime;'
#   at t/00load.t line 8.
#     Tried to use 'DateTime'.
#     Error:  Can't load '/Users/simon/.cpanm/work/1698444031.29827/DateTime-1.63/blib/arch/auto/DateTime/DateTime.bundle' for module DateTime: dlopen(/Users/simon/.cpanm/work/1698444031.29827/DateTime-1.63/blib/arch/auto/DateTime/DateTime.bundle, 0x0002): symbol not found in flat namespace '_Perl_is_inf' at /Users/simon/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/darwin-2level/DynaLoader.pm line 204.
#  at /Users/simon/.cpanm/work/1698444031.29827/DateTime-1.63/blib/lib/DateTime.pm line 46
# Compilation failed in require at t/00load.t line 8.
# BEGIN failed--compilation aborted at t/00load.t line 8.
# Looks like you failed 1 test of 1.

This looks similar, although not the same, as the release notes for the TRIAL RELEASEs 1.60, 1.61 and 1.62, could this be related? Any clues on what is going on here?

And although this looks related to the C bindings for DateTime this is the rest of my environment (freshly installed and just running cpanm DateTime):

Version for all modules
# Versions for all modules listed in MYMETA.json (including optional ones):
# 
# === Configure Requires ===
# 
#     Module               Want Have
#     -------------------- ---- ----
#     Dist::CheckConflicts 0.02 0.11
#     ExtUtils::MakeMaker   any 7.70
# 
# === Configure Suggests ===
# 
#     Module      Want    Have
#     -------- ------- -------
#     JSON::PP 2.27300 2.27203
# 
# === Build Requires ===
# 
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.70
# 
# === Test Requires ===
# 
#     Module                    Want     Have
#     ------------------------ ----- --------
#     CPAN::Meta::Check        0.011    0.018
#     CPAN::Meta::Requirements   any    2.131
#     ExtUtils::MakeMaker        any     7.70
#     File::Spec                 any     3.30
#     Storable                   any     2.20
#     Test::Fatal                any    0.017
#     Test::More                0.96 1.302195
#     Test::Warnings           0.005    0.032
#     Test::Without::Module      any     0.21
#     utf8                       any     1.07
# 
# === Test Recommends ===
# 
#     Module         Want     Have
#     ---------- -------- --------
#     CPAN::Meta 2.120900 2.143240
# 
# === Runtime Requires ===
# 
#     Module                         Want     Have
#     -------------------------- -------- --------
#     Carp                            any     1.11
#     DateTime::Locale               1.06     1.39
#     DateTime::TimeZone             2.44     2.60
#     Dist::CheckConflicts           0.02     0.11
#     POSIX                           any     1.17
#     Params::ValidationCompiler     0.26     0.31
#     Scalar::Util                    any     1.63
#     Specio                         0.18     0.48
#     Specio::Declare                 any     0.48
#     Specio::Exporter                any     0.48
#     Specio::Library::Builtins       any     0.48
#     Specio::Library::Numeric        any     0.48
#     Specio::Library::String         any     0.48
#     Specio::Subs                    any     0.48
#     Try::Tiny                       any     0.31
#     XSLoader                        any     0.10
#     integer                         any     1.00
#     namespace::autoclean           0.19     0.29
#     overload                        any     1.07
#     parent                          any    0.221
#     perl                       5.008004 5.010001
#     strict                          any     1.04
#     warnings                        any     1.06
#     warnings::register              any     1.01
@bombsimon
Copy link
Author

bombsimon commented Oct 28, 2023

I'm not familiar with the API in perl.h at all but I tried to be naive and just removed the definition of dt_isfinite if on macOS and with this diff all the tests now passes with make test with perl 5.10.1:

diff --git a/DateTime.xs b/DateTime.xs
index 09778cf..9409144 100644
--- a/DateTime.xs
+++ b/DateTime.xs
@@ -13,7 +13,9 @@
 #     define dt_isfinite Perl_isfinite
 #   endif
 # else
-#   define dt_isfinite Perl_isfinite
+#   ifndef __APPLE__
+#     define dt_isfinite Perl_isfinite
+#   endif
 # endif

 #define DAYS_PER_400_YEARS  146097

Looking at perl.h bundled with perl 5.10.1 I don't even see they refer to Perl_isfinite so that would explain why it's not defined on 5.10. Compared to on the blead branch where it's mentioned 37 times and seems guaranteed to be set. No clue why it works on 5.10 on Linux in CI though 🤔

Never mind, it's for sure defined here: https://github.com/Perl/perl5/blob/5348debf9fd57fc15c26529386769684fab96e57/perl.h#L2140-L2154

Seems to be this line that fails which is the one calling Perl_is_inf which fails: https://github.com/Perl/perl5/blob/5348debf9fd57fc15c26529386769684fab96e57/perl.h#L2150. Not sure if we should add an extra guard to this codebase and check if Perl_is_inf is defined before setting dt_isfinite or if we should just skip this for Apple on <= 5.10. Haven't tested if this works on versions between 5.10.1 and 5.32.0.

@bombsimon
Copy link
Author

Is this a typo that never got discovered somehow? Searching for Perl_is_inf yields very few results.

It was originally added 2001 in Perl/perl5@758a5d7, updated in 2014 in Perl/perl5@4efd38a and then shortly after removed in Perl/perl5@25c46df but without any mention regarding the use of Perl_is_inf and Perl_is_nan. This was only ever used if Perl_fp_class_finite wasn't defined so maybe that's why it doesn't affect Windows or Linux systems.

If this actually is a typo maybe we can fix this by redefining this given the same conditional as the original code? This fix also solves my issue:

diff --git a/DateTime.xs b/DateTime.xs
index 09778cf..c546d05 100644
--- a/DateTime.xs
+++ b/DateTime.xs
@@ -13,6 +13,10 @@
 #     define dt_isfinite Perl_isfinite
 #   endif
 # else
+#   if !defined(Perl_fp_class_finite)
+#     define Perl_is_inf Perl_isinf
+#     define Perl_is_nan Perl_isnan
+#   endif
 #   define dt_isfinite Perl_isfinite
 # endif

If you think that's reasonable I'll happily make a PR!

@autarch
Copy link
Member

autarch commented Oct 29, 2023

I think the simplest thing is just to not worry about this on older macOS builds, similarly to how the code currently handles Windows pre-5.22.0. I'd note that 5.10.1 is now more than 14 years old. I don't want to invest a huge amount of effort in supporting it.

@autarch
Copy link
Member

autarch commented Oct 29, 2023

I can't get my CI to work with older Perls on macOS. I'll do a trial release with the fix and monitor CPAN Testers.

bombsimon added a commit to bombsimon/DateTime.pm that referenced this issue Oct 29, 2023
@bombsimon
Copy link
Author

bombsimon commented Oct 29, 2023

I think the simplest thing is just to not worry about this on older macOS builds, similarly to how the code currently handles Windows pre-5.22.0. I'd note that 5.10.1 is now more than 14 years old. I don't want to invest a huge amount of effort in supporting it.

Yeah that sounds reasonable! I just wanted to do the right thing:tm: but I agree it's not worth spending effort on such old versions. Tbh I haven't used such old versions in a long time and the package I mentioned is probably not used much. It was mostly since both my package and this one claims to support this version.

I created a PR with your suggested fix. Closed this, missed your branch without PR.

I can't get my CI to work with older Perls on macOS. I'll do a trial release with the fix and monitor CPAN Testers.

Let me know if there's anything you want me to try for you if you don't have access to macOS!

@autarch
Copy link
Member

autarch commented Oct 30, 2023

If you can try the trial release with an older Perl on macOS, I'd greatly appreciate it.

@bombsimon
Copy link
Author

Works fine both on my machine and in CI: https://github.com/personnummer/perl/actions/runs/6689612280/job/18173436632

Thank's a bunch!

@autarch
Copy link
Member

autarch commented Nov 6, 2023

Fixed in 1.65.

@autarch autarch closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants