develooper Front page | perl.perl5.porters | Postings from September 2000

[ID 20000928.002] perlcc & ByteCode.pm option mismatch

From:
Nicholas Clark
Date:
September 28, 2000 04:19
Subject:
[ID 20000928.002] perlcc & ByteCode.pm option mismatch
Message ID:
E13ebha-0004IV-00@fruitbat.babyhippo.co.uk

This is a bug report for perl from nick@talking.bollo.cx,
generated with the help of perlbug 1.32 running under perl v5.7.0.


-----------------------------------------------------------------
[Please enter your report here]

perlcc, Stash and the C backends use -u to list packages to use
When Benjamin Stuhl improved Bytecode.pm so that it would only compile
named packages he used -P as his option.

As perlcc also eats all backend diagnostics if the backend exit code is
success, this hasn't been noticed.

Patches

1: Make perlcc for bytecode display "unexpected" output (ie anything other
   than "foo syntax OK"
2: Change Bytecode.pm to use -u instead of -P

With (1) not (2) the output looks like this:

nick@fruitbat [bleadperl]$ ./perl -Ilib utils/perlcc -B -vvvv test.pl 
utils/perlcc: Compiling test.pl
utils/perlcc: Calling ./perl -Ilib -I/usr/local/lib/perl5/5.7.0/i586-linux -I/usr/local/lib/perl5/5.7.0 -I/usr/local/lib/perl5/site_perl/5.7.0/i586-linux -I/usr/local/lib/perl5/site_perl/5.7.0 -I/usr/local/lib/perl5/site_perl -I.  -MB::Stash -c test.pl
utils/perlcc: Stash:   main GDBM_File Devel Devel::Peek Devel::DProf SDBM_File attrs Opcode attributes DB Data Data::Dumper IPC IPC::SysV re Fcntl ODBM_File subs ByteLoader DB_File Storable File File::Glob POSIX Sys Sys::Hostname Sys::Syslog Socket
utils/perlcc: Writing on a.out
utils/perlcc: Compiling...
utils/perlcc: Calling ./perl -Ilib -I/usr/local/lib/perl5/5.7.0/i586-linux -I/usr/local/lib/perl5/5.7.0 -I/usr/local/lib/perl5/site_perl/5.7.0/i586-linux -I/usr/local/lib/perl5/site_perl/5.7.0 -I/usr/local/lib/perl5/site_perl -I.  -MO=Bytecode,-umain,-uGDBM_File,-uDevel,-uDevel::Peek,-uDevel::DProf,-uSDBM_File,-uattrs,-uOpcode,-uattributes,-uDB,-uData,-uData::Dumper,-uIPC,-uIPC::SysV,-ure,-uFcntl,-uODBM_File,-usubs,-uByteLoader,-uDB_File,-uStorable,-uFile,-uFile::Glob,-uPOSIX,-uSys,-uSys::Hostname,-uSys::Syslog,-uSocket test.pl
utils/perlcc: Unexpected compiler output:
ignoring unknown option "umain"
 ignoring unknown option "uGDBM_File"
 ignoring unknown option "uDevel"
 ignoring unknown option "uDevel::Peek"
 ignoring unknown option "uDevel::DProf"
 ignoring unknown option "uSDBM_File"
 ignoring unknown option "uattrs"
 ignoring unknown option "uOpcode"
 ignoring unknown option "uattributes"
 ignoring unknown option "uDB"
 ignoring unknown option "uData"
 ignoring unknown option "uData::Dumper"
 ignoring unknown option "uIPC"
 ignoring unknown option "uIPC::SysV"
 ignoring unknown option "ure"
 ignoring unknown option "uFcntl"
 ignoring unknown option "uODBM_File"
 ignoring unknown option "usubs"
 ignoring unknown option "uByteLoader"
 ignoring unknown option "uDB_File"
 ignoring unknown option "uStorable"
 ignoring unknown option "uFile"
 ignoring unknown option "uFile::Glob"
 ignoring unknown option "uPOSIX"
 ignoring unknown option "uSys"
 ignoring unknown option "uSys::Hostname"
 ignoring unknown option "uSys::Syslog"
 ignoring unknown option "uSocket"
 No package specified for compilation, assuming main::

--- utils/perlcc.PL.orig  Fri Aug  4 13:35:21 2000
+++ utils/perlcc.PL   Thu Sep 28 11:34:48 2000
@@ -232,16 +232,17 @@
     vprint 3, "Calling $command";
 
        my ($output_r, $error_r) = spawnit($command);
-       my @output = @$output_r;
-       my @error = @$error_r;
 
-    if (@error && $? != 0) {
-        die "$0: $Input did not compile, which can't happen:\n@error\n";
+    if (@$error_r && $? != 0) {
+        die "$0: $Input did not compile, which can't happen:\n@$error_r\n";
+    } else {
+      my @error = grep { !/^$Input syntax OK$/o } @$error_r;
+      warn "$0: Unexpected compiler output:\n@error" if @error;
     }
 
     # Write it and leave.
-    print OUT @output               or die "can't write $Output: $!";
-    close OUT                       or die "can't close $Output: $!";
+    print OUT @$output_r               or die "can't write $Output: $!";
+    close OUT                          or die "can't close $Output: $!";
 
     # wait, how could it be anything but what you see next?
     chmod 0777 & ~umask, $Output    or die "can't chmod $Output: $!";
--- ext/B/B/Bytecode.pm.orig  Tue Aug 22 17:15:13 2000
+++ ext/B/B/Bytecode.pm Thu Sep 28 11:25:59 2000
@@ -850,7 +850,7 @@
                $compress_nullops = 1;
                $omit_seq = 1;
            }
-       } elsif ($opt eq "P") {
+       } elsif ($opt eq "u") {
            $arg ||= shift @options;
            push @packages, $arg;
        } else {
@@ -975,7 +975,7 @@
 Output (bytecode) assembler source rather than piping it
 through the assembler and outputting bytecode.
 
-=item B<-Ppackage>
+=item B<-upackage>
   
 Stores package in the output.
   
@@ -983,16 +983,16 @@
 
 =head1 EXAMPLES
 
-    perl -MO=Bytecode,-O6,-ofoo.plc,-Pmain foo.pl
+    perl -MO=Bytecode,-O6,-ofoo.plc,-umain foo.pl
 
-    perl -MO=Bytecode,-S,-Pmain foo.pl > foo.S
+    perl -MO=Bytecode,-S,-umain foo.pl > foo.S
     assemble foo.S > foo.plc
 
 Note that C<assemble> lives in the C<B> subdirectory of your perl
 library directory. The utility called perlcc may also be used to 
 help make use of this compiler.
 
-    perl -MO=Bytecode,-PFoo,-oFoo.pmc Foo.pm
+    perl -MO=Bytecode,-uFoo,-oFoo.pmc Foo.pm
 
 =head1 BUGS
 


Interesting, bytecode for package main only for perlcc is about 161,000
bytes and works enough to compile more bytecode. (But not enough to
give the -help message)
Whereas with the fixes above bytecode for all packages pulled in by perlcc
is 1398952 bytes and doesn't work:

nick@fruitbat [bleadperl]$ ./a.out   
Constant subroutine MAX_TRIES redefined at /usr/local/lib/perl5/5.7.0/constant.pm line 91.
Constant subroutine MINX redefined at /usr/local/lib/perl5/5.7.0/constant.pm line 91.
Constant subroutine TEMPXXX redefined at /usr/local/lib/perl5/5.7.0/constant.pm line 91.
Constant subroutine STANDARD redefined at /usr/local/lib/perl5/5.7.0/constant.pm line 91.
Constant subroutine MEDIUM redefined at /usr/local/lib/perl5/5.7.0/constant.pm line 91.
Constant subroutine HIGH redefined at /usr/local/lib/perl5/5.7.0/constant.pm line 91.
Can't upgrade that kind of scalar at ./a.out line 2.


Inspiration for what to do next?

Nicholas Clark

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=utilities
    severity=low
---
Site configuration information for perl v5.7.0:

Configured by nick at Fri Sep 15 16:17:09 BST 2000.

Summary of my perl5 (revision 5.0 version 7 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.16, archname=i586-linux
    uname='linux fruitbat 2.2.16 #6 tue aug 1 12:35:02 bst 2000 i586 unknown '
    config_args=''
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=define uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.2 20000220 (Debian GNU/Linux)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lpthread -lc -lposix -lcrypt -lutil -lsfio
    libc=/lib/libc-2.1.3.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    DEVEL7093

---
@INC for perl v5.7.0:
    /usr/local/lib/perl5/5.7.0/i586-linux
    /usr/local/lib/perl5/5.7.0
    /usr/local/lib/perl5/site_perl/5.7.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.7.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.7.0:
    HOME=/home/nick
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About