jonathanstowe / TermReadKey

Character mode terminal access for Perl
12 stars 27 forks source link

Problem building with perl 5.24.0 #21

Closed jonathanstowe closed 7 years ago

jonathanstowe commented 7 years ago

It appears that the ReadKey_pm.PL is run in a context where it can't find the ReadKey.so that needs to be bootstrapped in order to find the constants.

Not sure why this doesn't fail in Travis CI though.

Moved from #7 where it was reported by @sillitoe :)

sillitoe commented 7 years ago

Just to confirm that this seems to be based on whether it is installed interactively or non-interactively through docker (as per original poster #7).

$ cat Dockerfile
# DOCKER-VERSION
FROM         perl:latest
RUN cpanm Term::ReadKey

Running non-interactively (via docker build) fails

$ sudo docker build .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM perl:latest
 ---> a9d757d1a33b
Step 2 : RUN cpanm Term::ReadKey
 ---> Running in 967dab729b16
--> Working on Term::ReadKey
Fetching http://www.cpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.33.tar.gz ... OK
Configuring TermReadKey-2.33 ... OK
Building and testing TermReadKey-2.33 ... ! Installing Term::ReadKey failed. See /root/.cpanm/work/1475776368.7/build.log for details. Retry with --force to force install it.
FAIL
The command '/bin/sh -c cpanm Term::ReadKey' returned a non-zero code: 1

Running interactively (starting a shell in docker prior to the fail and running manually) succeeds

$ sudo docker run -it a9d757d1a33b bash
root@0f5eb80b8b35:~# cpanm Term::ReadKey
--> Working on Term::ReadKey
Fetching http://www.cpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.33.tar.gz ... OK
root@eac1d1e413f0:~# cpanm Term::ReadKey                     
--> Working on Term::ReadKey
Fetching http://www.cpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.33.tar.gz ... OK
Configuring TermReadKey-2.33 ... OK
Building and testing TermReadKey-2.33 ... OK
Successfully installed TermReadKey-2.33
1 distribution installed

Changing the cpanm install to the 2.34 version...

RUN cpanm https://github.com/jonathanstowe/TermReadKey/archive/v2.34.tar.gz

...seems to fail in both cases (interactively and non-interactively)

...
Can't locate loadable object for module Term::ReadKey in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.24.0/x86_64-linux /usr/local/lib/perl5/site_perl/5.24.0 /usr/local/lib/perl5/5.24.0/x86_64-linux /usr/local/lib/perl5/5.24.0 .) at /usr/local/lib/perl5/5.24.0/x86_64-linux/DynaLoader.pm line 95.
        DynaLoader::croak("Can't locate loadable object for module Term::ReadKey in \@INC"...) called at /usr/local/lib/perl5/5.24.0/x86_64-linux/DynaLoader.pm line 159
        DynaLoader::bootstrap("Term::ReadKey") called at ReadKey_pm.PL line 507
Bootstrapping the XS for blockoptions: Makefile:530: recipe for target 'ReadKey.pm' failed
make: *** [ReadKey.pm] Error 255
FAIL
jonathanstowe commented 7 years ago

I'm not quite sure why it was working on the other versions of perl (or even with 5.24.0 on Travis CI) as the 2.34 generates the ReadKey.pm from the ReadKey_pm.PL which uses the built XS part to find the detected configuration values (which means we can avoid an eval of the subroutine at run time).

The reason it is failing is because it can't find the built ReadKey.so because it isn't looking in the blib.

I've fixed it, just testing (as I can't trust the Travis CI to tell me whether it will fail on any given version.)

jonathanstowe commented 7 years ago

https://travis-ci.org/jonathanstowe/TermReadKey/builds/165612896

pghmcfc commented 7 years ago

2.35 is failing for me the same way. It looks like a parallel build issue, where there's a race between building the XS and trying to use it. If I disable parallel make, it all works.

$ make -j4
"/usr/bin/perl" genchars.pl
Running Mkbootstrap for ReadKey ()
"/usr/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey_pm.PL ReadKey.pm
chmod 644 "ReadKey.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs 644
Can't locate loadable object for module Term::ReadKey in @INC (@INC contains: blib/arch blib/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/lib64/perl5/DynaLoader.pm line 95.
    DynaLoader::croak("Can't locate loadable object for module Term::ReadKey in \@INC"...) called at /usr/lib64/perl5/DynaLoader.pm line 159
    DynaLoader::bootstrap("Term::ReadKey") called at ReadKey_pm.PL line 507
Creating ReadKey.pm
Bootstrapping the XS for blockoptions: make: *** [Makefile:534: ReadKey.pm] Error 255
make: *** Waiting for unfinished jobs....

Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
    Sgtty NOT found.
Writing sgtty section of cchars.h... Done.

Disabling parallel make:

$ make
Running Mkbootstrap for ReadKey ()
chmod 644 "ReadKey.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs 644
"/usr/bin/perl" genchars.pl

Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
    Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
"/usr/bin/perl" "/usr/share/perl5/vendor_perl/ExtUtils/xsubpp" -noprototypes -typemap '/usr/share/perl5/ExtUtils/typemap'  ReadKey.xs > ReadKey.xsc
mv ReadKey.xsc ReadKey.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic   -DVERSION=\"2.35\" -DXS_VERSION=\"2.35\" -fPIC "-I/usr/lib64/perl5/CORE"   ReadKey.c
rm -f blib/arch/auto/Term/ReadKey/ReadKey.so
gcc  -shared -Wl,-z,relro  -L/usr/local/lib -fstack-protector-strong ReadKey.o  -o blib/arch/auto/Term/ReadKey/ReadKey.so  \
    -lperl   \

chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
"/usr/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey_pm.PL ReadKey.pm
Creating ReadKey.pm
Bootstrapping the XS for blockoptions: 5
Done
cp ReadKey.pm blib/arch/Term/ReadKey.pm
Manifying 1 pod document

There's also an issue with old EU::MM versions, circa 5.12 era:

$ perl Makefile.PL INSTALLDIRS=vendor
WARNING: AUTHOR takes a string/number not a ARRAY reference.
         Please inform the author.
Checking if your kit is complete...
Looks good
only nested arrays of non-refs are supported at /usr/share/perl5/ExtUtils/MakeMaker.pm line 684

I worked around this by patching Makefile.PL:

--- Makefile.PL
+++ Makefile.PL
@@ -12,7 +12,7 @@ if ( $mm_version < 3.5 ) {
     DISTNAME   => 'TermReadKey',
     LICENSE    => 'perl',
     ABSTRACT   => 'Change terminal modes, and perform non-blocking reads.',
-    AUTHOR     => ['Kenneth Albanowski','Jonathan Stowe'],
+    AUTHOR     => 'Kenneth Albanowski, Jonathan Stowe',
     META_MERGE => {
         no_index  => {
             file     => [ qw(Configure.pm) ],
jonathanstowe commented 7 years ago

@pghmcfc I've created a new issue (#23) for this as it is a different problem (just the same symptom.)

If you feel the part about the AUTHOR is important, please raise a separate issue for that too.

pghmcfc commented 7 years ago

The AUTHOR thing is easily patched around where necessary so it's not a big deal for me. It's broken with EU::MM 6.37_01 to 6.57_05 inclusive I believe, so you might consider just bumping the EU::MM version requirement to 6.58.

jonathanstowe commented 7 years ago

@pghmcfc I've created #24 - I'm minded to go with 6.42 as that is what shipped with 5.10.0