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

Makefile.PL Fails for 246 when it works for 244 #93

Closed
jlpoolen opened this issue Dec 2, 2021 · 7 comments
Closed

Makefile.PL Fails for 246 when it works for 244 #93

jlpoolen opened this issue Dec 2, 2021 · 7 comments

Comments

@jlpoolen
Copy link

jlpoolen commented Dec 2, 2021

In Gentoo, the package dev-perl/XML-Parser-2.460.0 does not install XML::Parser. I've opened a bug regarding the false indication that XML::Parser installs when, in fact, it does not. The issue https://bugs.gentoo.org/827966

I downloaded and staged XML::Parser-2.44 and 2.46 under /usr/local/src. I then proceeded to run:

  perl Makefile.PL

in each staging area. The result is that 2.44 creates files when 2.46 does not:

Writing MYMETA.yml and MYMETA.json
Generating a Unix-style Makefile
Writing Makefile for XML::Parser
Writing MYMETA.yml and MYMETA.json

Both have the warning message. Here are my attempts:

janus /usr/local/src/XML-Parser-2.46 # perl Makefile.PL EXPATLIBPATH=/usr/lib64 EXPATINCPATH=/usr/include

Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' (or
'libexpat1-dev') package with your OS package manager. See 'README'.

Or you can download expat from:

http://sourceforge.net/projects/expat/

If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:

    EXPATLIBPATH=...  To set the directory in which to find libexpat

    EXPATINCPATH=...  To set the directory in which to find expat.h

For example:

    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include

Note that if you build against a shareable library in a non-standard location
you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
variable at run time for perl to find the library.

janus /usr/local/src/XML-Parser-2.46 # ls -la /usr/lib64/libexpat*
lrwxrwxrwx 1 root root     17 Nov 29 19:46 /usr/lib64/libexpat.so -> libexpat.so.1.8.1
lrwxrwxrwx 1 root root     17 Nov 29 19:46 /usr/lib64/libexpat.so.1 -> libexpat.so.1.8.1
-rwxr-xr-x 1 root root 194536 Nov 29 19:46 /usr/lib64/libexpat.so.1.8.1
lrwxrwxrwx 1 root root     18 Nov 29 19:46 /usr/lib64/libexpatw.so -> libexpatw.so.1.8.1
lrwxrwxrwx 1 root root     18 Nov 29 19:46 /usr/lib64/libexpatw.so.1 -> libexpatw.so.1.8.1
-rwxr-xr-x 1 root root 198632 Nov 29 19:46 /usr/lib64/libexpatw.so.1.8.1
janus /usr/local/src/XML-Parser-2.46 # ls -la /usr/include/exp*
-rw-r--r-- 1 root root 42636 Nov 29 19:46 /usr/include/expat.h
-rw-r--r-- 1 root root  3830 Nov 29 19:46 /usr/include/expat_config.h
-rw-r--r-- 1 root root  6029 Nov 29 19:46 /usr/include/expat_external.h
janus /usr/local/src/XML-Parser-2.46 # 

in 244, it works:

janus /usr/local/src/XML-Parser-2.44 #   perl Makefile.PL EXPATLIBPATH=/usr/lib64 EXPATINCPATH=/usr/include

Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' (or
'libexpat1-dev') package with your OS package manager. See 'README'.

Or you can download expat from:

http://sourceforge.net/projects/expat/

If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:

    EXPATLIBPATH=...  To set the directory in which to find libexpat

    EXPATINCPATH=...  To set the directory in which to find expat.h

For example:

    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include

Note that if you build against a shareable library in a non-standard location
you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
variable at run time for perl to find the library.

Writing MYMETA.yml and MYMETA.json
Generating a Unix-style Makefile
Writing Makefile for XML::Parser
Writing MYMETA.yml and MYMETA.json
janus /usr/local/src/XML-Parser-2.44 # 

It looks like the point of failure is occurring at the testing stage, lines 32 - 39, in Makefile.PL:

unless (
    check_lib(    # fill in what you prompted the user for here
	lib     => [qw(expat)],
	header  => ['expat.h'],
	incgentoopath => $expat_incpath,
	( $expat_libpath ? ( libpath => $expat_libpath ) : () ),
    )
) 

I have these areas waiting for any modified Makefile.PL scripts you would like me to try out. My guess is check_lib is failing.

@jlpoolen
Copy link
Author

jlpoolen commented Dec 2, 2021

I think I found the difference between 244 and 246.

In 244 and 246 on my janus VM, both return "0" in the call
However, in 244, the "exit" is rem'd out with a hashtag, "#":

     #exit;
 }

so the 244 script does not exit as perhaps it should have? In 246, there is an an exit command that is duly executed.

# exiting before Makefile generation silences CPANTesters reports
# when expat is not available.
exit 0;

The above explains the inconsistent behavior of version 244 and 246 on the same machine. But Gentoo's ebuild doesn't seem to read the exit correctly and proceeds with what appears to be a successful installation when there is nothing to install.

Now, I'll add a wrinkle. On another Gentoo instance, taurus, the call to subroutine check_lib() returns 1 whereas on janus it returns 0. What is odd is that I have the same expat files on taurus and janus and the same package Devel::CheckLibs.

I'll have to scratch around some more and will update with my findings.

@jlpoolen
Copy link
Author

jlpoolen commented Dec 2, 2021

I think there is another issue apart from the failure of the test subroutine check_lib(). That is the value provided by the call to exit. In 266, the exit returns "0" to signify a failure. In Perl, returns of "0" can be a signal of: FAILED, and a return of "1" can be: SUCCESS. However, in bash scripting, the opposite is true -- a call to a script which returns "0" means the sub component was successful, and you flag an error by exiting with "1". On the topic of exit codes for bash, see: https://codefather.tech/blog/exit-bash-script/

So, at this point I'm concluding that version 244 was broken because the failure of check_lib() should have had an "exit 1", but instead the exit line was rem'd out and processing proceeded. If your system had the expat libraries, then no harm, no foul and in Gentoo the installation of perl-lang/XML-Parser would succeed because in the later steps of Makefile.PL files for compilation where created and expat was found. So I think this package's Makefile.pl should have at line 69:

 exit 1;

Then, investigation needs to determine why the subroutine check_lib() fails when it should not. When check_lib() successfully finds the expat library and header file, then line 69 will not be called and the build will continue as it should.

@jlpoolen
Copy link
Author

jlpoolen commented Dec 2, 2021

Of course, my suggestion that Makefile.PL's line 69 have "exit 1;" comes from a perspective of a Gentoo bash script. It may be that within Perl's realm, the Makefile.PL's return should be "exit 0", in which case the maintainter of the Gentoo package perl-lang/XML-Parser should check for a value of "1" instead of "0" to determine success.

@jlpoolen
Copy link
Author

jlpoolen commented Dec 2, 2021

See https://metacpan.org/pod/Devel::CheckLib#check_lib_or_exit

I created this test script which produces the desired result on my machines "janus" and "taurus":

use strict;
use warnings;

use Devel::CheckLib;

print "Test for library 'expat':\n";
my $rc1 = check_lib_or_exit( lib => 'expat');
print "rc1 = $rc1\n";

print "Test for header file 'expat.h':\n";
my $rc2 = check_lib_or_exit( header => "expat.h");
print "rc2 = $rc2\n";

if (0){
	eval {
		print "Test with error lib 'bogus':\n";
		my $rc3 = check_lib_or_exit( lib => 'bogus');
		print "rc3 = $rc3\n";
	};
	print "Error from eval: $@" if defined $@;
}

if (0){
	eval { 
		print "Test with error 'bogus.h':\n";
		my $rc3 = check_lib_or_exit( header => "bogus.h");
		print "rc3 = $rc3\n";
	};
	print "Error from eval: $@" if defined $@;
}


print "Completed $0 at ".localtime."\n";

If you engage either of the "if" clauses (replacing 0 with 1) then the desired result will occur: the Perl script will exit with a warning.

Perhaps using the function check_lib_or_exit() instead of check_lib() would be the approach to take?

@thesamesam
Copy link

thesamesam commented Dec 14, 2021

As more people upgrade to 246 in Gentoo, larger numbers of users are hitting this. Anything we can do to help (any more information about the installed libexpat, for example)?

Interestingly, I can't hit this.

@thesamesam
Copy link

This looks related to #86.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Dec 14, 2021
…arch)

The bundled, rather old copy of Devel::CheckLib seems to sometimes cause
errors when trying to find Expat.

Bug: cpan-authors/XML-Parser#93
Bug: https://bugs.gentoo.org/827966
Bug: cpan-authors/XML-Parser#86
Signed-off-by: Sam James <sam@gentoo.org>
@toddr
Copy link
Member

toddr commented Dec 28, 2023

I believe this has been resolved by #89

@toddr toddr closed this as completed Dec 28, 2023
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

No branches or pull requests

3 participants