threads / patch / 62835

patch, 2 partsCheck for Perl 5.26.0 from Meson build

Subject: [PATCH 1/2] Check for Perl 5.26.0 from Meson build

## tl;dr

16 messages between Jan 20, 2025 and Feb 25, 2025. Diffs are folded; open one to read it.

replies: 15people: 3as markdown or json

Peter Oliver· Jan 20, 2025, 16:03 UTC · lore

Commit 702d8c1 (which landed not long before Meson was added) dropped support for Perl versions back to 5.8.1.

Signed-off-by: Peter Oliver <git@mavit.org.uk>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to meson.build +1 −1
diff --git a/meson.build b/meson.build
index 0064eb64f5..f01d81b39f 100644
--- a/meson.build
+++ b/meson.build
@@ -755,7 +755,7 @@ endif
 
 # Note that we only set NO_PERL if the Perl features were disabled by the user.
 # It may not be set when we have found Perl, but only use it to run tests.
-perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
+perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
 perl_features_enabled = perl.found() and get_option('perl').allowed()
 if perl_features_enabled
   build_options_config.set('NO_PERL', '')
-- 
2.48.1
Peter Oliver· Jan 20, 2025, 16:03 UTC · re: Peter Oliver · lore

[PATCH 2/2] Fix Meson Perl version check

Command `perl --version` says, e.g., “This is perl 5, version 26, subversion 0 (v5.26.0)”, which Meson interprets as version 26.

Signed-off-by: Peter Oliver <git@mavit.org.uk>
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Show changes to meson.build +5 −1
diff --git a/meson.build b/meson.build
index f01d81b39f..bf129205ad 100644
--- a/meson.build
+++ b/meson.build
@@ -755,7 +755,11 @@ endif
 
 # Note that we only set NO_PERL if the Perl features were disabled by the user.
 # It may not be set when we have found Perl, but only use it to run tests.
-perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
+#
+# When checking here, it would be better to say,
+#   version: '>=5.26.0', version_argument: '-eprint "$^V"'
+# but that requires Meson 1.5.0, which at the time of writing is rather new.
+perl = find_program('perl', version: '>=26', dirs: program_path, required: perl_required)
 perl_features_enabled = perl.found() and get_option('perl').allowed()
 if perl_features_enabled
   build_options_config.set('NO_PERL', '')
-- 
2.48.1
Patrick Steinhardt· Jan 21, 2025, 06:44 UTC · re: Peter Oliver · lore

Re: [PATCH 2/2] Fix Meson Perl version check

On Mon, Jan 20, 2025 at 04:03:01PM +0000, Peter Oliver wrote:
> Command `perl --version` says, e.g., “This is perl 5, version 26,
> subversion 0 (v5.26.0)”, which Meson interprets as version 26.

Yeah, I've also discovered this issue, but decided to improve it upstream in Meson [1]. Meson now prefers version numbers with dots when scanning through the output, which makes it match the "v5.26.0" part instead of the "version 26" part. This will be released with Meson 1.7.0, which should be released soonish.

I'm a little torn whether it still makes sense to fix the issue in that light. If we do, we should use a fix that properly fixes the underlying issue instead of adapting to the misdetected version, as that will stop working once the mentioned fix is released.

One way would be to use `perl -V:version` instead of `perl --version`, which will print the following:

    version='5.40.0';

The support of overriding the version argument has only been added recently with Meson 1.5.0 though. We can still make it work though by making this conditional:

    diff --git a/meson.build b/meson.build
    index 07744c73b1..c452a79e37 100644
    --- a/meson.build
    +++ b/meson.build
    @@ -754,7 +754,11 @@ endif
     
     # Note that we only set NO_PERL if the Perl features were disabled by the user.
     # It may not be set when we have found Perl, but only use it to run tests.
    -perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
    +if meson.version().version_compare('>=1.5.0')
    +  perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required, version_argument: '-V:version')
    +else
    +  perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
    +endif
     perl_features_enabled = perl.found() and get_option('perl').allowed()
     if perl_features_enabled
       build_options_config.set('NO_PERL', '')

Is it worth it? I dunno. But also doesn't hurt if you want to go down that path.

Thanks!
Patrick
[1]: https://github.com/mesonbuild/meson/commit/a3679a64eec7c312c81d657880f34f015426c7db
Patrick Steinhardt· Jan 21, 2025, 06:44 UTC · re: Peter Oliver · lore

Re: [PATCH 1/2] Check for Perl 5.26.0 from Meson build

On Mon, Jan 20, 2025 at 04:03:00PM +0000, Peter Oliver wrote:
> Commit 702d8c1 (which landed not long before Meson was added) dropped
> support for Perl versions back to 5.8.1.

Makes sense. This commit was another thing that landed in parallel to the Meson effort, so it's not surprising that Meson still requires the old version.

A couple remarks for the commit message:
  - The subject should typically start with the subsystem you're
    touching, followed by a short description of what you're doing to
    it.
  - We aim to make the commit message work standalone, wihtout reading
    the commit subject. So saying something along the lines that the
    minimum required version in MEson hasn't been bumped accordingly
    would make sense.
  - We use `git log -1 --format=reference` when mentioning commits.
So, my suggestion:
    meson: bump minimum required Perl version to 5.26.0
    Commit 702d8c1f3b (Require Perl 5.26.0, 2024-10-23) dropped support
    for Perl versions older than 5.28.0. The Meson build system, which
    has been developed in parallel to that commit, hasn't been bumped
    accordingly and thus still requires Perl 5.8.1 or newer.
    Fix this and require Perl 5.28.0 or newer in Meson, as well.
Patrick
Peter Oliver· Jan 24, 2025, 16:30 UTC · re: Peter Oliver · lore

[PATCH v2 0/2] Fix Meson Perl version check

As suggested, I have reworded the commit message of the first patch, and improved the second patch to work correctly with future versions of Meson.

Peter Oliver (2):
  meson: bump minimum required Perl version to 5.26.0
  meson: fix Perl version check for Meson versions before 1.7.0
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
-- 
2.48.1
Peter Oliver· Jan 24, 2025, 16:30 UTC · re: Peter Oliver · lore

[PATCH v2 1/2] meson: bump minimum required Perl version to 5.26.0

Commit 702d8c1f3b (Require Perl 5.26.0, 2024-10-23) dropped support for Perl versions older than 5.26.0. The Meson build system, which has been developed in parallel to that commit, hasn't been bumped accordingly and thus still requires Perl 5.8.1 or newer.

Fix this by requiring Perl 5.26.0 or newer with Meson.
Signed-off-by: Peter Oliver <git@mavit.org.uk>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to meson.build +1 −1
diff --git a/meson.build b/meson.build
index 0064eb64f5..f01d81b39f 100644
--- a/meson.build
+++ b/meson.build
@@ -755,7 +755,7 @@ endif
 
 # Note that we only set NO_PERL if the Perl features were disabled by the user.
 # It may not be set when we have found Perl, but only use it to run tests.
-perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
+perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
 perl_features_enabled = perl.found() and get_option('perl').allowed()
 if perl_features_enabled
   build_options_config.set('NO_PERL', '')
-- 
2.48.1
Peter Oliver· Jan 24, 2025, 16:30 UTC · re: Peter Oliver · lore

[PATCH v2 2/2] meson: fix Perl version check for Meson versions before 1.7.0

Command `perl --version` says, e.g., “This is perl 5, version 26, subversion 0 (v5.26.0)”, which older versions of Meson interpret as version 26.

This will be fixed in Meson 1.7.0, but at the time of writing that isn’t yet released.

If we run `perl -V:version` we get the unambiguous response “version='5.26.0';”, but we need at least Meson 1.5.0 to be able to do that.

Signed-off-by: Peter Oliver <git@mavit.org.uk>
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Show changes to meson.build +5 −1
diff --git a/meson.build b/meson.build
index f01d81b39f..80af578d36 100644
--- a/meson.build
+++ b/meson.build
@@ -755,7 +755,11 @@ endif
 
 # Note that we only set NO_PERL if the Perl features were disabled by the user.
 # It may not be set when we have found Perl, but only use it to run tests.
-perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
+if meson.version().version_compare('>=1.5.0')
+  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')
+else
+  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')
+endif
 perl_features_enabled = perl.found() and get_option('perl').allowed()
 if perl_features_enabled
   build_options_config.set('NO_PERL', '')
-- 
2.48.1
Patrick Steinhardt· Jan 27, 2025, 07:39 UTC · re: Peter Oliver · lore

Re: [PATCH v2 2/2] meson: fix Perl version check for Meson versions before 1.7.0

On Fri, Jan 24, 2025 at 04:30:49PM +0000, Peter Oliver wrote:
Show 13 quoted lines
> diff --git a/meson.build b/meson.build
> index f01d81b39f..80af578d36 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -755,7 +755,11 @@ endif
>  
>  # Note that we only set NO_PERL if the Perl features were disabled by the user.
>  # It may not be set when we have found Perl, but only use it to run tests.
> -perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
> +if meson.version().version_compare('>=1.5.0')
> +  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')
> +else
> +  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')

I'm still a bit sceptical whether we should adapt this second line to match against `>=26`. I guess as long as it doesn't break anything out there it's okayish, and if we do see breakage we can in the worst case revert it.

In any case, it deserves a comment why we're matching against the minor version and not the whole version. E.g. something like this:

    # Executing `perl --version` results in a string similar to the
    # following output:
    #
    #     This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux-thread-multi
    #
    # Meson picks up the "40" as version number instead of using "v5.40.0"
    # due to the regular expression it uses. This got fixed in Meson 1.7.0,
    # but meanwhile we have to either use `-V:version` instead of `--version`,
    # which we can do starting with Meson 1.5.0 and newer, or we have to
    # match against the minor version.
Thanks!
Patrick
Peter Oliver· Feb 18, 2025, 15:30 UTC · re: Patrick Steinhardt · lore

[PATCH v3 0/2] Fix Meson Perl version check

Suggested comments added.
Peter Oliver (2):
  meson: bump minimum required Perl version to 5.26.0
  meson: fix Perl version check for Meson versions before 1.7.0
 meson.build | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
-- 
2.48.1
Peter Oliver· Feb 18, 2025, 15:30 UTC · re: Peter Oliver · lore

[PATCH v3 1/2] meson: bump minimum required Perl version to 5.26.0

Commit 702d8c1f3b (Require Perl 5.26.0, 2024-10-23) dropped support for Perl versions older than 5.26.0. The Meson build system, which has been developed in parallel to that commit, hasn't been bumped accordingly and thus still requires Perl 5.8.1 or newer.

Fix this by requiring Perl 5.26.0 or newer with Meson.
Signed-off-by: Peter Oliver <git@mavit.org.uk>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to meson.build +1 −1
diff --git a/meson.build b/meson.build
index 0064eb64f5..f01d81b39f 100644
--- a/meson.build
+++ b/meson.build
@@ -755,7 +755,7 @@ endif
 
 # Note that we only set NO_PERL if the Perl features were disabled by the user.
 # It may not be set when we have found Perl, but only use it to run tests.
-perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
+perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
 perl_features_enabled = perl.found() and get_option('perl').allowed()
 if perl_features_enabled
   build_options_config.set('NO_PERL', '')
-- 
2.48.1
Peter Oliver· Feb 18, 2025, 15:30 UTC · re: Peter Oliver · lore

[PATCH v3 2/2] meson: fix Perl version check for Meson versions before 1.7.0

Command `perl --version` says, e.g., “This is perl 5, version 26, subversion 0 (v5.26.0)”, which older versions of Meson interpret as version 26.

This will be fixed in Meson 1.7.0, but at the time of writing that isn’t yet released.

If we run `perl -V:version` we get the unambiguous response “version='5.26.0';”, but we need at least Meson 1.5.0 to be able to do that.

Note that Perl are seriously considering dropping the leading 5 entirely in the near future (https://perl.github.io/PPCs/ppc0025-perl-version/), but that shouldn’t affect us.

Signed-off-by: Peter Oliver <git@mavit.org.uk>
Co-authored-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
Show changes to meson.build +16 −1
diff --git a/meson.build b/meson.build
index f01d81b39f..fd19d348c6 100644
--- a/meson.build
+++ b/meson.build
@@ -755,7 +755,22 @@ endif
 
 # Note that we only set NO_PERL if the Perl features were disabled by the user.
 # It may not be set when we have found Perl, but only use it to run tests.
-perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
+#
+# At the time of writing, executing `perl --version` results in a string
+# similar to the following output:
+#
+#     This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux-thread-multi
+#
+# Meson picks up the "40" as version number instead of using "v5.40.0"
+# due to the regular expression it uses. This got fixed in Meson 1.7.0,
+# but meanwhile we have to either use `-V:version` instead of `--version`,
+# which we can do starting with Meson 1.5.0 and newer, or we have to
+# match against the minor version.
+if meson.version().version_compare('>=1.5.0')
+  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')
+else
+  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')
+endif
 perl_features_enabled = perl.found() and get_option('perl').allowed()
 if perl_features_enabled
   build_options_config.set('NO_PERL', '')
-- 
2.48.1
Junio C Hamano· Feb 18, 2025, 19:12 UTC · re: Peter Oliver · lore

Re: [PATCH v3 0/2] Fix Meson Perl version check

Peter Oliver <p.d.oliver@mavit.org.uk> writes:
Show 8 quoted lines
> Suggested comments added.
>
> Peter Oliver (2):
>   meson: bump minimum required Perl version to 5.26.0
>   meson: fix Perl version check for Meson versions before 1.7.0
>
>  meson.build | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)

I wasn't involved in the review of the previous rounds (so it was a bit of surprise for me to be listed on the To: line), but it seems that Patrick and you polished these two together, so I'll see if I can add Patrick's acked-by/reviewed-by while queuing by waiting for the earth to turn one rotation.

Thanks.
Patrick Steinhardt· Feb 19, 2025, 07:17 UTC · re: Junio C Hamano · lore

Re: [PATCH v3 0/2] Fix Meson Perl version check

On Tue, Feb 18, 2025 at 11:12:03AM -0800, Junio C Hamano wrote:
Show 16 quoted lines
> Peter Oliver <p.d.oliver@mavit.org.uk> writes:
> 
> > Suggested comments added.
> >
> > Peter Oliver (2):
> >   meson: bump minimum required Perl version to 5.26.0
> >   meson: fix Perl version check for Meson versions before 1.7.0
> >
> >  meson.build | 17 ++++++++++++++++-
> >  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> I wasn't involved in the review of the previous rounds (so it was a
> bit of surprise for me to be listed on the To: line), but it seems
> that Patrick and you polished these two together, so I'll see if I
> can add Patrick's acked-by/reviewed-by while queuing by waiting for
> the earth to turn one rotation.

Yup, this version looks good to me, thanks Peter. So please feel free to add either my Acked-by or Reviewed-by, I'd be fine with either.

Patrick
Junio C Hamano· Feb 19, 2025, 16:05 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v3 0/2] Fix Meson Perl version check

Patrick Steinhardt <ps@pks.im> writes:
Show 20 quoted lines
> On Tue, Feb 18, 2025 at 11:12:03AM -0800, Junio C Hamano wrote:
>> Peter Oliver <p.d.oliver@mavit.org.uk> writes:
>> 
>> > Suggested comments added.
>> >
>> > Peter Oliver (2):
>> >   meson: bump minimum required Perl version to 5.26.0
>> >   meson: fix Perl version check for Meson versions before 1.7.0
>> >
>> >  meson.build | 17 ++++++++++++++++-
>> >  1 file changed, 16 insertions(+), 1 deletion(-)
>> 
>> I wasn't involved in the review of the previous rounds (so it was a
>> bit of surprise for me to be listed on the To: line), but it seems
>> that Patrick and you polished these two together, so I'll see if I
>> can add Patrick's acked-by/reviewed-by while queuing by waiting for
>> the earth to turn one rotation.
>
> Yup, this version looks good to me, thanks Peter. So please feel free to
> add either my Acked-by or Reviewed-by, I'd be fine with either.
Thanks for working well together.  Let me mark the topic for 'next'.
Peter Oliver· Feb 25, 2025, 12:28 UTC · re: Junio C Hamano · lore

Re: [PATCH v3 0/2] Fix Meson Perl version check

On Tue, 18 Feb 2025, Junio C Hamano wrote:
> I wasn't involved in the review of the previous rounds (so it was a
> bit of surprise for me to be listed on the To: line)
Apologies if that wasn’t the correct process.  I am not a regular contributor, and was trying to follow the process described at https://git-scm.com/docs/SubmittingPatches#_choosing_your_reviewers, “After the list reached a consensus…”.
-- 
Peter Oliver
Junio C Hamano· Feb 25, 2025, 18:20 UTC · re: Peter Oliver · lore

Re: [PATCH v3 0/2] Fix Meson Perl version check

Peter Oliver <p.d.oliver@mavit.org.uk> writes:
Show 9 quoted lines
> On Tue, 18 Feb 2025, Junio C Hamano wrote:
>
>> I wasn't involved in the review of the previous rounds (so it was a
>> bit of surprise for me to be listed on the To: line)
>
> Apologies if that wasn’t the correct process.  I am not a regular
> contributor, and was trying to follow the process described at
> https://git-scm.com/docs/SubmittingPatches#_choosing_your_reviewers,
> “After the list reached a consensus…”.
No apology needed.  Thanks for the update.

← back to recent threads