cpanel / perl-compiler

cPanel's custom implementation of B::C
https://cpanel.net
Other
8 stars 3 forks source link

Error when compiling Template::Constants - Undefined subroutine &Template::Constants::DEBUG_UNDEF #70

Closed atoomic closed 7 years ago

atoomic commented 7 years ago
> perlcc -g -S -e 'use Template::Context; Template::Context::_init( {} ) '
--
> ./a.out
Undefined subroutine &Template::Constants::DEBUG_UNDEF called at /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Context.pm line 874.
atoomic commented 7 years ago

This is working when the two packages are in a single file

package myConstants;

use constant SOMETHING     =>    42;

my %h = (
    &SOMETHING  => 'used-as-hash-key',
);

package main;
BEGIN { unshift @INC, '.' }

sub ok {
    print qq[ok\n] if &myConstants::SOMETHING;
}

ok();

1;
> perl test.pl ; rm -f test test.c; perlcc -r -g -S -v4 test.pl ; echo =====; ./test
ok
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Using gcc '-g' compilation option.
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Writing C on test.c
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Calling /usr/local/cpanel/3rdparty/perl/524/bin/perl -MO=C,-otest.c test.pl
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Calling /usr/bin/gcc -g -DPERL_DISABLE_PMC -fPIC -DPIC -I/usr/local/cpanel/3rdparty/perl/524/include -L/usr/local/cpanel/3rdparty/perl/524/lib64 -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib64 -m64 -fwrapv -fno-strict-aliasing -fstack-protector-strong -I/usr/local/cpanel/3rdparty/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE -o ./test test.c -Wl,-E -Wl,-rpath,/usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE -Wl,-rpath -Wl,/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/lib64 -L/lib64 -lgdbm -fstack-protector-strong -L/usr/local/lib -L/usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE/libperl.so -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Running code ./test
ok
=====
ok

But when split in two files: myConstants.pm

package myConstants;

use constant SOMETHING     =>    42;

my %h = (
    &SOMETHING  => 'used-as-hash-key',
);

1;

test.pl

package main;
BEGIN { unshift @INC, '.' }
use myConstants;

sub ok {
    print qq[ok\n] if &myConstants::SOMETHING;
}

ok();

1;

then this is failing...

> perl test.pl ; rm -f test test.c; perlcc -r -g -S -v4 test.pl ; echo =====; ./test
ok
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Using gcc '-g' compilation option.
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Writing C on test.c
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Calling /usr/local/cpanel/3rdparty/perl/524/bin/perl -MO=C,-otest.c test.pl
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Calling /usr/bin/gcc -g -DPERL_DISABLE_PMC -fPIC -DPIC -I/usr/local/cpanel/3rdparty/perl/524/include -L/usr/local/cpanel/3rdparty/perl/524/lib64 -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib64 -m64 -fwrapv -fno-strict-aliasing -fstack-protector-strong -I/usr/local/cpanel/3rdparty/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE -o ./test test.c -Wl,-E -Wl,-rpath,/usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE -Wl,-rpath -Wl,/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/lib64 -L/lib64 -lgdbm -fstack-protector-strong -L/usr/local/lib -L/usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64int/CORE/libperl.so -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
/usr/local/cpanel/3rdparty/perl/524/bin/perlcc: Running code ./test
Undefined subroutine &myConstants::SOMETHING called at test.pl line 19.
=====
Undefined subroutine &myConstants::SOMETHING called at test.pl line 19.
atoomic commented 7 years ago

when using the constant as a hash key it's upgraded from IV to PVIV... and PVIV was not in the valid constant types :-) so the fix is easy there

atoomic commented 7 years ago

fixed by commit 00be6ec