Skip to content

Fix issue where the incorrect version of the library#18

Open
timlegge wants to merge 2 commits intocpan-authors:masterfrom
timlegge:libs
Open

Fix issue where the incorrect version of the library#18
timlegge wants to merge 2 commits intocpan-authors:masterfrom
timlegge:libs

Conversation

@timlegge
Copy link
Member

Fix issue where the incorrect version of the library
or headers could be found either by the Devel::CheckLib
or by the Module itself.

Devel::CheckLib uses $Config{ccflags} which has the -I from Perl
which is not wanted when attempting to Compile the test check_lib
function against libsodium.  Since /usr/local/include was first on
the command line the non-alien header files were found.
https://rt.cpan.org/Ticket/Display.html?id=173214

In addition we need to set the MakeMaker INC and LIBS explicitly
to ensure the Alien version is used.

Being explicit will also be needed for the option to use a non-Alien
version of the Library

or headers could be found either by the Devel::CheckLib
or by the Module itself.

Devel::CheckLib uses $Config{ccflags} which has the -I from Perl
which is not wanted when attempting to Compile the test check_lib
function against libsodium.  Since /usr/local/include was first on
the command line the non-alien header files were found.
https://rt.cpan.org/Ticket/Display.html?id=173214

In addition we need to set the MakeMaker INC and LIBS explicitly
to ensure the Alien version is used.

Being explicit will also be needed for the option to use a non-Alien
version of the Library
@timlegge timlegge requested a review from genio February 16, 2026 21:46
@genio
Copy link
Collaborator

genio commented Feb 18, 2026

@plicease Any chance you could take a look at this?

Makefile.PL Outdated
Comment on lines +58 to +60
$xsbuild{"LIBS"} = [ $alien_libs ];
$xsbuild{"CCFLAGS"} = $alien_cflags;
$xsbuild{"INC"} = $alien_include;

Choose a reason for hiding this comment

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

This shouldn't be necessary, and will in fact probably break some configurations. mm_args2 should correctly order the includes so that the Alien include directories preceed the ones that are configured during Perl build time (like -I/usr/local/include). Setting CCFLAGS without the configured $Config{ccflags} will break any Perl that rely on them.

Copy link
Member Author

Choose a reason for hiding this comment

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

@plicease That makes sense and I can change. Do you have any thoughts on the need to use use Mock::Config ccflags because of the way Devel::CheckLib uses $Config{ccflags} ?

Copy link

@plicease plicease Feb 18, 2026

Choose a reason for hiding this comment

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

I'm not 100% sure, I think you want to pass the include path in as incpath and remove -I from the cflags passed into ccflags (both as passed into Devel::CheckLib), that I think should get the correct ordering of flags, but maybe it would be good for ABW to have a method to generate the correct arguments for Devel::CheckLib similar to what it does for EUMM since it is complicated, and difficult to get right.

Choose a reason for hiding this comment

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

If we can reproduce the error (maybe in a docker container) I might be able to enhance ABW to do this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have a VM that has the issue. FreeBSD and an older version of libsodium installed. I will look at how to duplicate the issue on something easier to deal with...

Copy link
Member Author

Choose a reason for hiding this comment

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

@plicease So, it took some time but I was able to create a Docker image that can reproduce the issue. I assume pushing it to docker hub would be the best way to get it to you?

Copy link
Member Author

@timlegge timlegge Feb 20, 2026

Choose a reason for hiding this comment

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

I pushed it to Docker hub: It is available as

timlegge/crypt-nacl-sodium

Essentially it is a custom build Alpine 3.0 32-bit image with perlbrew perl 5.16.3 and libsodium 0.4.5 which replicates the versions that were present in the free BSD smoker where I saw the issue.

The only custom item was the option passed to perbrew to add the same -I as FreeBSD:

perlbrew install perl-5.16.3 -A ccflags=\"-I/usr/local/include\" --notest --thread --multi

The image has a clone of https://github.com/timlegge/crypt-nacl-sodium.git with the libs branch checked out. So this works:

cd /root/crypt-nacl-sodium
perl Makefile.PL
make test

and this fails:

cd /root/crypt-nacl-sodium
git checkout master
perl Makefile.PL
make realclean
perl Makefile.PL
make test

@timlegge timlegge requested a review from plicease February 22, 2026 15:42
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