Skip to content

Remove non-include paths from INC in pre-build checks#17

Merged
mohawk2 merged 2 commits intoPDLPorters:masterfrom
paultcochrane:remove-non-include-paths-from-inc-in-pre-build-checks
Apr 19, 2026
Merged

Remove non-include paths from INC in pre-build checks#17
mohawk2 merged 2 commits intoPDLPorters:masterfrom
paultcochrane:remove-non-include-paths-from-inc-in-pre-build-checks

Conversation

@paultcochrane
Copy link
Copy Markdown
Contributor

While trying to get PDL::Graphics::PLplot to install, I found it kept telling me that it needed a plplot library compiled with the --with-double option:

$ perl Makefile.PL
Use of uninitialized value $size in numeric eq (==) at Makefile.PL line 46.
Sizeof(PLFLT) must be 8.
PLplot must be compiled --with-double (IE ./configure --with-double).

Please either:
- Install PLplot using your package manager then reinstall Alien::PLplot
  or
- Reinstall Alien::PLplot from CPAN with environment variable
  ALIEN_INSTALL_TYPE=share.

After having tried the advice about reinstalling Alien::PLplot and failing, and having checked that libplplot had been installed using double precision, I happened to stumble upon the issue that the option -pthread was appearing in the $plplot_include_path variable. I noticed this by replacing the call to check_lib (from Devel::CheckLib) with check_lib_or_exit. When using this function, the error output was this instead:

$ perl Makefile.PL
INC argument badly-formed: -pthread

Upon reading the docs for Devel::CheckLib, it turns out that the INC option to both check_lib and check_lib_or_exit needs to be a space-delimited list of options, all of which start with -I. Since -pthread doesn't start with -I the argument was badly formed, hence the analyze_binary callback was never called. Thus no check code was compiled which then resulted in $size being set to undef. Because $size was undef, the uninitialized value warning mentioned in the first error message mentione above and the check for a double precision library failed. In other words, because -pthread was turning up in the $plplot_include_path string, the test for a library compiled with the --with-double option was failing and hence PDL::Graphics::PLplot failed to install.

By filtering only for include paths from the list of options originally found in $plplot_include_path (i.e. selecting only options starting with -I and hence excluding in this particular instance the -pthread option), one avoids the issue of a badly formed INC argument and thus the checks in Makefile.PL compile and run. Because all checks run, the Makefile is created as per normal and the test suite passes.

More background info: I found this issue on Debian version 11.11 with a perlbrewed perl, version 5.32.1.

This PR is submitted in the hope that it is useful. If you'd like anything changed, please let me know and I'll update and resubmit as necessary.

@mohawk2
Copy link
Copy Markdown
Member

mohawk2 commented Mar 23, 2026

Hi, thanks for submitting this! Some points I'll do as a "review".

Comment thread Makefile.PL Outdated
my ($code) = @_;
my $result;

my @inc = split " ", $plplot_include_path;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Text::ParseWords::shellwords for this, not a naive split

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. I'd have never have thought of using Text::ParseWords. Now I know about it. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested change applied in force-pushed (with lease) update of PR branch.

Comment thread Makefile.PL Outdated
my $result;

my @inc = split " ", $plplot_include_path;
@inc = grep {/^-I.*/ } @inc;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .* doesn't add anything, so you can get remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a bad habit on my part. Sorry!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested change applied in force-pushed (with lease) update of PR branch.

@paultcochrane
Copy link
Copy Markdown
Contributor Author

Hi! Sorry for my late reply. I'll update the code according to your suggestions and will force-push the changes to the branch.

@paultcochrane paultcochrane force-pushed the remove-non-include-paths-from-inc-in-pre-build-checks branch from 0d2c167 to 0b41006 Compare April 19, 2026 17:04
@paultcochrane paultcochrane requested a review from mohawk2 April 19, 2026 17:05
Comment thread Makefile.PL Outdated
Comment thread Makefile.PL Outdated
@mohawk2
Copy link
Copy Markdown
Member

mohawk2 commented Apr 19, 2026

Regarding the whole reason for this, that -pthread is rejected as a INC option, this was first reported in https://rt.cpan.org/Ticket/Display.html?id=82728 in 2013. It is extremely poor that it has never been fixed.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 19, 2026

Coverage Status

coverage: 75.761% (+0.5%) from 75.279% — paultcochrane:remove-non-include-paths-from-inc-in-pre-build-checks into PDLPorters:master

Comment thread Makefile.PL Outdated
@paultcochrane
Copy link
Copy Markdown
Contributor Author

Regarding the whole reason for this, that -pthread is rejected as a INC option, this was first reported in https://rt.cpan.org/Ticket/Display.html?id=82728 in 2013. It is extremely poor that it has never been fixed.

Better late than never ;-)

@paultcochrane
Copy link
Copy Markdown
Contributor Author

Regarding the whole reason for this, that -pthread is rejected as a INC option, this was first reported in https://rt.cpan.org/Ticket/Display.html?id=82728 in 2013. It is extremely poor that it has never been fixed.

BTW: that ticket found a problem with LIBS. The issue I spotted here is definitely related, because Devel::CheckLib also doesn't like -pthreads turning up in the INC value. Interestingly enough, -pthreads still turns up in INC in the final Makefile and the C compiler has no problems with that. shrug.

@mohawk2
Copy link
Copy Markdown
Member

mohawk2 commented Apr 19, 2026

Regarding the whole reason for this, that -pthread is rejected as a INC option, this was first reported in https://rt.cpan.org/Ticket/Display.html?id=82728 in 2013. It is extremely poor that it has never been fixed.

BTW: that ticket found a problem with LIBS. The issue I spotted here is definitely related, because Devel::CheckLib also doesn't like -pthreads turning up in the INC value. Interestingly enough, -pthreads still turns up in INC in the final Makefile and the C compiler has no problems with that. shrug.

It was never about the C compiler; EUMM doesn't mind either. It's just an error in Devel::CheckLib.

paultcochrane and others added 2 commits April 19, 2026 21:10
While trying to get `PDL::Graphics::PLplot` to install, I found it kept
telling me that it needed a plplot library compiled with the
`--with-double` option:

```
$ perl Makefile.PL
Use of uninitialized value $size in numeric eq (==) at Makefile.PL line 46.
Sizeof(PLFLT) must be 8.
PLplot must be compiled --with-double (IE ./configure --with-double).

Please either:
- Install PLplot using your package manager then reinstall Alien::PLplot
  or
- Reinstall Alien::PLplot from CPAN with environment variable
  ALIEN_INSTALL_TYPE=share.
```

After having tried the advice about reinstalling `Alien::PLplot` and
failing, and having checked that `libplplot` had been installed using
double precision, I happened to stumble upon the issue that the option
`-pthread` was appearing in the `$plplot_include_path` variable.  I
noticed this by replacing the call to `check_lib` (from
`Devel::CheckLib`) with `check_lib_or_exit`.  When using this function,
the error output was this instead:

```
$ perl Makefile.PL
INC argument badly-formed: -pthread
```

Upon reading the docs for `Devel::CheckLib`, it turns out that the `INC`
option to both `check_lib` and `check_lib_or_exit` needs to be a
space-delimited list of options, all of which start with `-I`.  Since
`-pthread` doesn't start with `-I` the argument was badly formed, hence
the `analyze_binary` callback was never called.  Thus no check code was
compiled which then resulted in `$size` being set to `undef`.  Because
`$size` was `undef`, the uninitialized value warning mentioned in the
first error message mentione above and the check for a double precision
library failed.  In other words, because `-pthread` was turning up in
the `$plplot_include_path` string, the test for a library compiled with
the `--with-double` option was failing and hence `PDL::Graphics::PLplot`
failed to install.

By filtering only for include paths from the list of options originally
found in `$plplot_include_path` (i.e. selecting only options starting
with `-I` and hence excluding in this particular instance the `-pthread`
option), one avoids the issue of a badly formed INC argument and thus
the checks in `Makefile.PL` compile and run.  Because all checks run,
the `Makefile` is created as per normal and the test suite passes.

More background info: I found this issue on Debian version 11.11 with a
perlbrewed perl, version 5.32.1.
@paultcochrane paultcochrane force-pushed the remove-non-include-paths-from-inc-in-pre-build-checks branch from 5c0a937 to 0092c46 Compare April 19, 2026 19:10
@paultcochrane
Copy link
Copy Markdown
Contributor Author

Ok, have merged everything. I squashed your suggestion into my original commit so that the bug origin remains in the commit history. Hope that was ok! Anyway, I think this is good to go now. Many thanks for your help and time!

@mohawk2 mohawk2 merged commit a2d734a into PDLPorters:master Apr 19, 2026
@mohawk2
Copy link
Copy Markdown
Member

mohawk2 commented Apr 19, 2026

Thank you for your efforts! I'll be releasing an updated version in a few minutes.

@paultcochrane paultcochrane deleted the remove-non-include-paths-from-inc-in-pre-build-checks branch April 19, 2026 19:18
@mohawk2
Copy link
Copy Markdown
Member

mohawk2 commented Apr 19, 2026

Now released to CPAN as 0.842. Please give it a go and open a new issue (or comment here) if there are problems :-)

@paultcochrane
Copy link
Copy Markdown
Contributor Author

Sweet! If I find anything, I'll let you know :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants