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

[ID 20000324.028] one more time

Thread Previous
From:
Tom Christiansen
Date:
March 24, 2000 06:36
Subject:
[ID 20000324.028] one more time
Message ID:
12899.953908596@chthon

------- Forwarded Message

Date:          Fri, 24 Mar 2000 07:21:18 MST
From:          Tom Christiansen <tchrist@chthon>
Subject:       [BUG] perlcc 
To:            perl5-porters@perl.org
Resent:        Fri, 24 Mar 2000 07:35:07 -0700
Resent:        perlbug

First, it ignores "use warnings" in the source, whether you're
making C code or bytecode.  

Next, it doesn't respect switches that were on the #! line.
If you use -w, it isn't preserved.  If you use -l, it won't
even compile!

    PROMPT% cat > /tmp/test
    #!/usr/bin/perl -l
    print "hello world";
    ^D

    PROMPT% chmod +x /tmp/test

    PROMPT% /tmp/test
    hello world

    PROMPT% perlcc /tmp/test

    --------------------------------------------------------------------------------
    Compiling /tmp/test:
    --------------------------------------------------------------------------------

Goodness, that's noisy!

    ERROR: '/tmp/test' does not have a proper extension! Proper extensions are:

	PROGRAM:       .p,.pl,.bat 
	SHARED OBJECT: .pm

    Use the '-prog' flag to force your files to be interpreted as programs.
    Use the '-mod' flag to force your files to be interpreted as modules.
    PROMPT% perlcc -prog /tmp/test

What is this "proper extension" crud?  Looks like a Perl program to me.
And I am not alone:

    PROMPT% file /tmp/test
    /tmp/test: perl commands text

    PROMPT% ls -l /tmp/test
    -rwxr-xr-x  1 tchrist  wheel  40 Mar 24 07:05 /tmp/test

It's executable.  It's got a pound-bang line.  I can't understand
what more the thing wants.  I don't even understand why it wants
that much.  And a .pl is not a program, and shouldn't not be encouraged
to be so.  What if I want to compile chat2.pl (just as a slow form of
suicide)?  Bah.

    PROMPT% perlcc -prog /tmp/test

    --------------------------------------------------------------------------------
    Compiling /tmp/test:
    --------------------------------------------------------------------------------
    ERROR: The object file '/tmp/test' does not generate a legitimate executable file! Ski
pping!

For Pete's sake, *now* what more do I have to do here?  Tell it
where to put its output?  That's stupid.  It should of course use
"a.out" (or, alright, maybe "p.out" or "perl.out") if the output
file name isn't given.

    PROMPT% perlcc -prog -o /tmp/test.out /tmp/test

    --------------------------------------------------------------------------------
    Compiling /tmp/test:
    --------------------------------------------------------------------------------
    Making C(/tmp/test.c) for /tmp/test!
    /usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib
/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib/
perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. -MB::Stash -c  /tmp/test
    /usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib
/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib/
perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. -MO=C, /tmp/test
    Warning: Use of "-o" without parens is ambiguous at (eval 4) line 1.
    Bareword found where operator expected at (eval 4) line 1, near "/tmp/test"
	    (Missing operator before test?)
    /tmp/test syntax OK

    #ifdef BROKEN_STATIC_REDECL
    #define Static extern
    #else
    #define Static static
    #endif /* BROKEN_STATIC_REDECL */

    #ifdef BROKEN_UNION_INIT
    /*
     * Cribbed from cv.h with ANY (a union) replaced by void*.
     * Some pre-Standard compilers can't cope with initialising unions. Ho hum.
     */
    typedef struct {
	char *      xpv_pv;         /* pointer to malloced string */
	STRLEN      xpv_cur;        /* length of xp_pv as a C string */
	STRLEN      xpv_len;        /* allocated size */
	IV          xof_off;        /* integer value */
	double      xnv_nv;         /* numeric value, if any */
	MAGIC*      xmg_magic;      /* magic for scalar array */
	HV*         xmg_stash;      /* class package */

	HV *        xcv_stash;
	OP *        xcv_start;
	OP *        xcv_root;
	void      (*xcv_xsub) (CV*);
	void *      xcv_xsubany;
	GV *        xcv_gv;
	char *      xcv_file;
	long        xcv_depth;      /* >= 2 indicates recursive call */
	AV *        xcv_padlist;
	CV *        xcv_outside;
    #ifdef USE_THREADS
	perl_mutex *xcv_mutexp;
	struct perl_thread *xcv_owner;      /* current owner thread */
    #endif /* USE_THREADS */
	cv_flags_t  xcv_flags;
    } XPVCV_or_similar;
    #define ANYINIT(i) i
    #else
    #define XPVCV_or_similar XPVCV
    #define ANYINIT(i) {i}
    #endif /* BROKEN_UNION_INIT */
    #define Nullany ANYINIT(0)

    #define UNUSED 0
    #define sym_0 0

    static int ()
    {
	    dTHR;
	    dTARG;
	    djSP;

	    return 0;
    }

    Compiling C(/tmp/test.out) for /tmp/test!
    /usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib
/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib/
perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. /tmp/test.tst
    cc -fno-strict-aliasing -I/usr/local/include  -I/usr/local/lib/perl5/5.6.0/OpenBSD.i38
6-openbsd/CORE -o /tmp/test.out /tmp/test.c   -L/usr/local/lib -L/usr/local/lib/perl5/5.6.
0/OpenBSD.i386-openbsd/CORE -lperl -lm -lc /usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd
/auto/DynaLoader/DynaLoader.a /usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/auto/IO/IO.s
o /usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/auto/Fcntl/Fcntl.so
    cc: /tmp/test.c: No such file or directory
    ERROR: In compiling code for /tmp/test.c !

Now that's lovely.  Let's try again:

    PROMPT% cat > /tmp/test
    #!/usr/bin/perl 
    print "hello world";
    ^D

    PROMPT% perlcc -prog -o /tmp/test.out /tmp/test

    --------------------------------------------------------------------------------
    Compiling /tmp/test:
    --------------------------------------------------------------------------------
    Making C(/tmp/test.c) for /tmp/test!
    /usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib
/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib/
perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. -MB::Stash -c  /tmp/test
    /usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib
/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib/
perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. -MO=C,-umain,-uattributes,-uDB 
/tmp/test
    Starting compile
    Walking tree
    Prescan
    Saving methods
    Bootstrap attributes /tmp/test
    Writing output
    Loaded B
    Loaded IO
    Loaded Fcntl

Whoa there!  What's it loading IO for, or Fcntl?  Loading IO!?
What, are you mad?

    /tmp/test syntax OK
    Compiling C(/tmp/test.out) for /tmp/test!
    /usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib
/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/OpenBSD.i386-openbsd -I/usr/local/lib/
perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. /tmp/test.tst
    cc -fno-strict-aliasing -I/usr/local/include  -I/usr/local/lib/perl5/5.6.0/OpenBSD.i38
6-openbsd/CORE -o /tmp/test.out /tmp/test.c   -L/usr/local/lib -L/usr/local/lib/perl5/5.6.
0/OpenBSD.i386-openbsd/CORE -lperl -lm -lc /usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd
/auto/DynaLoader/DynaLoader.a /usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/auto/IO/IO.s
o /usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/auto/Fcntl/Fcntl.so
    PROMPT% /tmp/test.out
    hello worldPROMPT% 

    PROMPT% /tmp/test.out -l
    hello worldPROMPT% 

Not very pretty.  Where am I supposed to have put the -l flag?  If
using the #! is wrong, why is it wrong?

I note that the byteloaded stuff isn't any better at this.

Also, the options and naming conventions are very bizarre in this
program.  It should use -S (or, I suppose maybe, -c) to save the
intermediate "assembler", that is, the C code.  And I wonder what
the -g flag should do?

I can see it's going to take some work to get this crazy program
into a tolerable shape.  

- --tom

------- End of Forwarded Message


Thread Previous


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