Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to build traditional Perl interpreters.

AnaTofuZ
August 08, 2019

How to build traditional Perl interpreters.

AnaTofuZ

August 08, 2019
Tweet

More Decks by AnaTofuZ

Other Decks in Programming

Transcript

  1. How to build
    traditional Perl
    interpreters
    Takahiro Shimizu (id:AnaTofuZ)
    Perlcon 2019

    View Slide

  2. my $self = shift;
    • Takahiro SHIMIZU (id:ANATOFUZ)
    • a.k.a “anagra”
    • I’m from Okinawa in Japan.
    • I belong to Okinawa.pm
    • A graduate student in Ryukyu-Univ.
    • My graduate study was MoarVM.

    View Slide

  3. This photo in Japan
    • This mean “You don't touch the camel"
    • … I was heading to PerlCon ...

    View Slide

  4. Sponsors
    + many people
    Thanks!!!

    View Slide

  5. Perl

    View Slide

  6. Perl5

    View Slide

  7. Perl1
    Perl2
    Perl3
    Perl4

    View Slide

  8. This talk is…
    .PTU
    1SPHSBNNFST
    4PGUXBSFBSDI
    FDPMPHZ
    time
    perl versions

    View Slide

  9. This talk is…
    • We usually use plenv, perlbrew, homebrew, apt and yum

    when install perl5.
    • These commands automatically execute shell scripts and
    execute make command.

    View Slide

  10. This talk is…
    • What if you have to install Perl 

    without using package manager commands?
    • I think to get Perl Source Code, do compile and 

    execute install. (copy to contain PATH directory)
    • These processes are called “builds".

    View Slide

  11. Install Perl
    “Install is also interesting
    when it comes to Perl”
    by Introduction Perl 

    (1994 Shinji Kono)

    View Slide

  12. This talk is…
    • Let’s try to install historical Perl Versions!!!

    View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. Contents
    • How to build Perl
    • How to build and run Perl1.0
    • Perl2.0
    • Perl3.0
    • Perl4.0
    • Perl5.0
    • How to build Perl6

    View Slide

  18. This talk is Perl
    • I will deal with Perl written by Larry in this talk.
    • Perl is written by C language.

    View Slide

  19. the historical Perl version is located
    • At the beginning of this talk, let’s think about

    where the source code of the

    historical Perl version is located.

    View Slide

  20. the historical Perl version is located
    • At the beginning of this talk, let’s think about

    where the source code of the

    historical Perl version is located.

    View Slide

  21. the historical Perl version is located
    • At the beginning of this talk, let’s think about

    where the source code of the

    historical Perl version is located.

    View Slide

  22. the historical Perl version is located
    Old commits are also

    tightly tagged

    View Slide

  23. $git tag
    if-0.0603
    if-0.0604
    if-0.0605
    perl-1.0
    perl-1.0.15
    perl-1.0.16
    perl-2.0
    perl-2.001
    perl-3.000
    perl-3.044
    perl-4.0.00
    perl-4.0.36
    perl-5.000
    perl-5.000o

    View Slide

  24. How to get a traditional Perl Source Code
    • Easy to download from GitHub.

    • If you want to get commit logs.

    • If you do not want to get commit logs.

    git clone -b perl-1.0 —single-branch [email protected]:Perl/perl5.git
    wget https://github.com/Perl/perl5/archive/perl-1.0.tar.gz

    View Slide

  25. the tarball is feel the history.
    ~/w/p/o/p/t/perl5-perl-1.0 » ls -la
    total 816
    drwxr-xr-x 44 anatofuz staff 1408 Dec 18 1987 ./
    drwxr-xr-x 6 anatofuz staff 192 Jan 26 05:35 ../
    -rwxr-xr-x 1 anatofuz staff 27329 Dec 18 1987 Configure*
    -rw-r--r-- 1 anatofuz staff 226 Dec 18 1987 EXTERN.h
    -rw-r--r-- 1 anatofuz staff 224 Dec 18 1987 INTERN.h
    -rw-r--r-- 1 anatofuz staff 5872 Dec 18 1987 MANIFEST
    -rw-r--r-- 1 anatofuz staff 3522 Dec 18 1987 Makefile.SH
    -rw-r--r-- 1 anatofuz staff 3386 Dec 18 1987 README
    -rw-r--r-- 1 anatofuz staff 84 Dec 18 1987 Wishlist
    -rw-r--r-- 1 anatofuz staff 47964 Dec 18 1987 arg.c
    -rw-r--r-- 1 anatofuz staff 5478 Dec 18 1987 arg.h
    -rw-r--r-- 1 anatofuz staff 3366 Dec 18 1987 array.c

    View Slide

  26. the tarball is feel the history.
    ~/w/p/o/p/t/perl5-perl-1.0 » ls -la
    total 816
    drwxr-xr-x 44 anatofuz staff 1408 Dec 18 1987 ./
    drwxr-xr-x 6 anatofuz staff 192 Jan 26 05:35 ../
    -rwxr-xr-x 1 anatofuz staff 27329 Dec 18 1987 Configure*
    -rw-r--r-- 1 anatofuz staff 226 Dec 18 1987 EXTERN.h
    -rw-r--r-- 1 anatofuz staff 224 Dec 18 1987 INTERN.h
    -rw-r--r-- 1 anatofuz staff 5872 Dec 18 1987 MANIFEST
    -rw-r--r-- 1 anatofuz staff 3522 Dec 18 1987 Makefile.SH
    -rw-r--r-- 1 anatofuz staff 3386 Dec 18 1987 README
    -rw-r--r-- 1 anatofuz staff 84 Dec 18 1987 Wishlist
    -rw-r--r-- 1 anatofuz staff 47964 Dec 18 1987 arg.c
    -rw-r--r-- 1 anatofuz staff 5478 Dec 18 1987 arg.h
    -rw-r--r-- 1 anatofuz staff 3366 Dec 18 1987 array.c

    View Slide

  27. degree of difficulty
    1FSM
    1FSM
    1FSM
    1FSM
    1FSM
    di cult
    easy

    View Slide

  28. degree of difficulty
    1FSM
    1FSM
    1FSM
    1FSM
    1FSM
    di cult
    easy
    easy
    di cult

    View Slide

  29. How to build latest Perl
    • These manual methods may not be aware of so much
    because brew, apt, and perlbrew etc. are convenient and
    usable these days.

    View Slide

  30. How to build latest Perl
    $POpHVSF

    View Slide

  31. How to build latest Perl
    $POpHVSF
    $POpHVSFJT

    4IFMM4DSJQU
    *UDSFBUFT.BLFpMFJO
    FBDIFOWJSPONFOU

    View Slide

  32. How to build latest Perl
    $POpHVSF
    NBLF

    View Slide

  33. How to build latest Perl
    $POpHVSF
    NBLF
    &YFDVUFNBLFDPNNBOE
    CBTFEPO.BLFpMF

    View Slide

  34. How to build latest Perl
    $POpHVSF
    NBLF
    NBLFJOTUBMM

    View Slide

  35. How to build latest Perl
    $POpHVSF
    NBLF
    NBLFJOTUBMM
    1VUUIFCVJMESFTVMUJOUIF
    BQQSPQSJBUFEJSFDUPSZ

    View Slide

  36. How to build Historical Perl
    $POpHVSF
    NBLFEFQFOE
    NBLFJOTUBMM
    NBLF

    View Slide

  37. How to build Historical Perl
    $POpHVSF
    NBLFEFQFOE
    NBLFJOTUBMM
    *OWFTUJHBUFXIFSFUIF
    JODMVEFIFBEFSpMFJTMPDBUFE
    NBLF

    View Slide

  38. Traditional Perl build flow.
    • makedpened is actually executed at also perl5

    (it is executed automatically)
    • Basically it is almost the same as modern perl5!!
    • old perl (strictly around Perl3) depends manually on make

    View Slide

  39. Confgiure
    $POpHVSF
    $POpHVSFJT

    4IFMM4DSJQU
    *UDSFBUFT.BLFpMFJO
    FBDIFOWJSPONFOU

    View Slide

  40. Configure flow
    $POpHVSF

    View Slide

  41. create config.sh
    $POpHVSF DPOpHTI

    View Slide

  42. creates config.h and Makefile
    $POpHVSF DPOpHTI
    .BLFpMF4)
    DQI4)
    NBLFEFQFOE
    4)

    View Slide

  43. create config.h and Makefile
    $POpHVSF DPOpHTI
    .BLFpMF4)
    DQI4)
    NBLFEFQFOE
    4)
    DPOpH .BLFpMF

    View Slide

  44. How to create Configure
    • Handwriting✍

    (we must follow update OS)

    • Not use Configure

    (using Cmake, using other build tools)
    • create Configure from Some tools.

    View Slide

  45. How to create Configure
    • I think people often use so-called GNU tools such as autoconf
    and automake.
    • autoconf commands, create Configure using setting file called
    configure.in.

    • Created Configure create Makefile using makefile.in.

    (It is automake to automatically generate makefile.in)

    View Slide

  46. Other Languages
    • Ruby and Python have configure.in

    (using autoconf)

    • C compiler LLVM / clang does not rely on Configure

    because it uses cmake.

    View Slide

  47. Configure in Perl
    • Perl does not have a configure.in at from 1.0
    • First of all, autoconf was not released in Perl 1.0 era.
    (Autoconf 1991 release, Perl 1987 release)

    • I wondered how Larry was creating the settings.

    View Slide

  48. A.「He creates dist toolkit by himself」
    • Larry creates dist toolkit by himself.
    • dist is create Configure using setting files.
    • —> create package from codes.
    • —> sent the package to email.
    • Also, the maintenance right was handed over to other
    people immediately after publication.

    View Slide

  49. metaconfig
    • Perl script named metaconfig to generate configure.

    • Older brother of autoconf (also written in wikipedia)
    • Not metaconfig in the current GitHub Perl 5 repository.

    View Slide

  50. metaconfig process
    NFUBDPOpH
    Run packinit to put
    together the
    information of the
    program to be
    distributed
    QBDLBHF
    QBDLJOJU

    View Slide

  51. metaconfig process
    NFUBDPOpH
    Load MANIFEST (a
    list of source code
    Perl intend to use).
    Load .package
    QBDLBHF
    ."/*'&45
    QBDLJOJU

    View Slide

  52. metaconfig process
    NFUBDPOpH
    Generate a file that
    arranges programs
    such as cp required
    at build time, 

    called wanted.
    QBDLBHF
    ."/*'&45
    QBDLJOJU
    8BOUFE

    View Slide

  53. metaconfig process
    NFUBDPOpH
    Create a file called
    Obsolete that
    summarizes the file
    changes
    QBDLBHF
    ."/*'&45
    QBDLJOJU
    8BOUFE 0CTPMFUF

    View Slide

  54. metaconfig process
    NFUBDPOpH
    Generate Desired
    “Configure”
    QBDLBHF
    ."/*'&45
    QBDLJOJU
    8BOUFE 0CTPMFUF $POpHVSF

    View Slide

  55. present day dist/metaconfig
    • The dist toolkit's metaconfig is plainly maintained.
    • But, Perl 4 flavored source code that can run on Perl 5.
    • Some dist toolkits are not maintained as Perl 5 

    (eg there is code left requiring getopts.pl)

    View Slide

  56. present day dist/metaconfig
    • metaconfig ins in the dist toolkit.
    • They are continuously maintained.
    • metaconfig can execute by Perl5!

    But, It is Perl4 flavor source code.

    View Slide

  57. a part of metaconfig source code
    sub main'profile { &auto_main'profile; }
    sub auto_main'profile { &main'dataload; }
    # Load the calling function from DATA segment and call it. This function is
    # called only once per routine to be loaded.
    sub main'dataload {
    local($__packname__) = (caller(1))[3];
    $__packname__ =~ s/::/'/;
    local($__rpackname__) = $__packname__;
    local($__at__) = $@;
    $__rpackname__ =~ s/^auto_//;
    &perload'load_from_data($__rpackname__);
    local($__fun__) = "$__rpackname__";
    $__fun__ =~ s/'/'load_/;
    eval "*$__packname__ = *$__fun__;"; # Change symbol table entry
    die $@ if $@; # Should not happen
    $@ = $__at__; # Restore value $@ had on entrance
    &$__fun__; # Call newly loaded function

    View Slide

  58. present-day dist/metaconfig
    • For historical Perl, Perl's configuration file (* .SH) required
    to run metaconfig can be used at that time, which is
    convenient.

    • Perl5's Configure is not just using dist's metaconfig, but it
    is becoming more and more often direct rewriting itself.

    View Slide

  59. Historical Perl rough structure
    • Written in C and yacc, there is no big difference between
    Perl 5 and other Perls.
    • perly.c have main function.
    • perl.c is a parsing phase generated by perl.y (YACC)
    • The names of perl.c and perly.c are replaced from Perl 5.

    View Slide

  60. Perl1.0

    View Slide

  61. Perl1.0
    • 1987 release. The oldest existing Perl.
    • Older than IRC at historical.
    • Published at comp.sources.misc newsgroups.
    • Grammar definitions are done by yacc, 

    others are written in C

    View Slide

  62. the features of Perl1.0
    • Perl1.0 has about two and a half data types
    • strings ( not scalar!)
    • arrays of strings
    • associative arrays [experimental]

    View Slide

  63. Perl1.0 has not…
    • range operator (..)
    • foreach
    • modules
    • use
    • my, our , local

    View Slide

  64. Perl1.0 has …
    • Replace
    • Basic regular expression
    • List operations (shift, unsift, pop, push)
    • @_
    • String operators
    • chop
    • each
    • subroutine

    View Slide

  65. In Perl man page
    • Perl is a interpreted language optimized for scanning
    arbitrary text files, extracting information from those
    text files, and printing reports based on that information.
    It's also a good language for many system management tasks.
    •It combines (in the author's opinion, anyway) some of the
    best features of C, sed, awk, and sh, so people familiar
    with those languages should have little difficulty with it.
    — by Perl1 man page

    View Slide

  66. example Perl1 Scripts
    • can for loop!!!
    #!/usr/bin/env perl
    @array = (1,2,3,4,5,6,7,8,9,10);
    for ( $i = 0; $i < $#array; $i++){
    print $array[$i] ."\n";
    }

    View Slide

  67. example Perl1 Scripts (subroutine)
    sub MAX {
    $max = pop(@_);
    while ($foo = pop(@_)) {
    $max = $foo if $max < $foo;
    }
    $max;
    }
    ...
    $bestday = do MAX($mon,$tue,$wed,$thu,$fri);

    View Slide

  68. in Perl1 subrotuine call
    do hello();
    hello();

    View Slide

  69. measure the processing time with fizzbuzz example
    for ($i = 0; $i < 10000_000; $i++){
    if ($i % 3 == 0 ){
    print "Fizz";
    if ($i % 5 == 0){
    print "Buzz";
    }
    print "\n";
    next;
    }
    if ($i % 5 == 0){
    print "Buzz\n";
    }
    print "$i\n";
    }

    View Slide

  70. 100 order fizzbuzz
    • Perl1 is faster with calculate fizzbuzz for 0 to 100 than
    Perl5
    1FSM
    1FSM



    View Slide

  71. 10 million order fizzbuzz
    • But, Perl5 is faster with 10 million fizzbuzz than Perl1!!!
    1FSM
    1FSM



    View Slide

  72. today Perl1.0
    • PerlMonger has the habit of writing Perl 1.0 patches
    regularly (100% test passing version exists)
    • I was implementation Perl1.0 Docker Images.
    • You can easy execute Perl1.0 when using Docker.

    View Slide

  73. Perl1.0 structure characteristics.
    • SV type advance, STR type is a simple configuration that
    only has char *
    • Naturally depends on the machine environment because it
    depends on the char type

    View Slide

  74. Perl1.0 structure Source Code
    • Written in C before published K&R C second edition

    (Perl1.0 is written in C before ANSI-C)
    • Since C at that time did not have a standard, the return type
    of the library function was different depending on the
    processing system.
    • These are controlled by the macro.

    View Slide

  75. Perl1.0 main function in C
    main(argc,argv,env)
    register int argc;
    register char **argv;
    register char **env;
    {
    register STR *str;
    register char *s;
    char *index();
    linestr = str_new(80);
    str = str_make("-I/usr/lib/perl "); /* first

    View Slide

  76. Perl1.0 main function in C
    main(argc,argv,env)
    register int argc;
    register char **argv;
    register char **env;
    {
    register STR *str;
    register char *s;
    char *index();
    linestr = str_new(80);
    str = str_make("-I/usr/lib/perl "); /* first
    There is no type in the main function.
    Receive environment in env.
    The keyword register hints to compiler
    that a given variable can be
    put in a register.

    View Slide

  77. Perl1.0 main function in C
    main(argc,argv,env)
    register int argc;
    register char **argv;
    register char **env;
    {
    register STR *str;
    register char *s;
    char *index();
    linestr = str_new(80);
    str = str_make("-I/usr/lib/perl "); /* first
    In the first place,
    the declaration of arguments is
    so-called K & R style

    View Slide

  78. K&R style in Perl
    • It is rewritten in 1997 by Nick Ing-Simmons, focusing on
    the miniperl part.
    • He corrected by protoize and handwriting.

    View Slide

  79. today Perl5
    #ifdef NO_ENV_ARRAY_IN_MAIN
    extern char **environ;
    int
    main(int argc, char **argv)
    #else
    int
    main(int argc, char **argv, char **env)
    #endif
    {
    int exitstatus, i;
    #ifdef PERL_GLOBAL_STRUCT
    struct perl_vars *my_vars = init_global_struct();
    # ifdef PERL_GLOBAL_STRUCT_PRIVATE
    int veto;
    main function is int type,
    written in perlmain.c

    View Slide

  80. View Slide

  81. View Slide

  82. Perl 1.0 process flow
    • First of all analyze the option
    • Load one file at a time with the files entered
    • YACC parsing while lexical analysis
    • I will just continue to run !!

    View Slide

  83. Structure in Perl1
    TUSJOH 453
    1FSM
    *OTUSVDUJPO
    "3(
    6TFXIFOJO
    USPVCMF
    45"#

    View Slide

  84. Structure in Perl1
    TUS@QUS
    TUSJOH
    453
    TUS@MJOL
    SFNPWFTUSJOH

    TUS@MFO
    TUSJOHMFOHUI

    TUS@QPL
    qBHHFEQPJOUFSUP
    TUSJOH

    View Slide

  85. Perl2.0

    View Slide

  86. Perl2.0 is difficult…
    • The included Configure can be used as it is
    • but when make depend it is destroyed in relation to the
    header file of mac os
    ./config.h:172:19: warning: '/*' within block comment [-Wcomment]
    #/*undef TMINSYS /**/
    ^
    /usr/include/AvailabilityInternal.h:38846:2: error: #else after #else
    #else
    ^
    /usr/include/AvailabilityInternal.h:38203:10: error: unterminated conditional
    directive
    #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13
    ^
    /usr/include/AvailabilityInternal.h:38116:10: error: unterminated conditional

    View Slide

  87. VS Configure<1>
    • Remake Configure itself using metaconfig that is
    maintained.
    • The newly created Configure will export files according to
    your environment, which will allow you to make.
    • You can execute make.

    View Slide

  88. In mac os
    I am

    View Slide

  89. In mac os
    I am
    NBD\HDD^OFHDD

    View Slide

  90. In mac os
    I am
    NBD\HDD^OFHDD
    NBD\HDD^FRDMBOH

    JONBDPT

    View Slide

  91. VS Configure<2>
    • We try install gcc or llvm/clang.
    • If you try to build gcc from source code, 

    I think you need to use llvm / clang installed with brew.
    brew install gcc
    brew install llvm #should include PATH (at /usr/libexec/bin)

    View Slide

  92. fix Makefile
    • The Makefile was successfully generated, but it is in a
    situation where it can not be built subtly.

    View Slide

  93. fix Makefile
    • and suddenly appear in Makefile
    • It can not be built because it does not exist as a header
    file….
    arg.o: /usr/include/time.h
    arg.o:
    arg.o:

    View Slide

  94. How to fix Makefile
    • The header file to be used is written to the Makefile after
    makedpend
    • So We want to change do not generate command-line etc. in
    makedepend's configuration file makedepend.SH

    View Slide

  95. makedepend.SH
    $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
    $echo "Updating Makefile..."
    <.clist $sed -n \
    -e '/\//{' \
    -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
    -e d \
    -e '}' \
    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
    $sed 's|^[^;]*/||' | \
    $sed -f .hsed >> Makefile.new
    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
    >> Makefile.new
    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
    $sed -f .hsed >> Makefile.new

    View Slide

  96. makedepend.SH
    $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
    $echo "Updating Makefile..."
    <.clist $sed -n \
    -e '/\//{' \
    -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
    -e d \
    -e '}' \
    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
    $sed 's|^[^;]*/||' | \
    $sed -f .hsed >> Makefile.new
    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
    >> Makefile.new
    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
    $sed -f .hsed >> Makefile.new
    I’m give up fixing it here?

    View Slide

  97. makedepend.SH
    $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
    $echo "Updating Makefile..."
    <.clist $sed -n \
    -e '/\//{' \
    -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
    -e d \
    -e '}' \
    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
    $sed 's|^[^;]*/||' | \
    $sed -f .hsed >> Makefile.new
    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
    >> Makefile.new
    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
    $sed -f .hsed >> Makefile.new
    This code is sed…

    View Slide

  98. I remember
    •It combines (in the author's opinion, anyway) some of
    the best features of C, sed, awk, and sh, so people
    familiar with those languages should have little
    difficulty with it. — by Perl1 man page

    View Slide

  99. I remember
    •It combines (in the author's opinion, anyway) some of
    the best features of C, sed, awk, and sh, so people
    familiar with those languages should have little
    difficulty with it. — by Perl1 man page

    View Slide

  100. makedepend.SH
    $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
    $echo "Updating Makefile..."
    <.clist $sed -n \
    -e '/\//{' \
    -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
    -e d \
    -e '}' \
    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
    $sed 's|^[^;]*/||' | \
    $sed -f .hsed >> Makefile.new
    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
    >> Makefile.new
    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
    $sed -f .hsed >> Makefile.new
    !!!!!!!!!!!!!!!!!!!!!!!!!!!

    View Slide

  101. makedepend.SH
    $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
    $echo "Updating Makefile..."
    <.clist $sed -n \
    -e '/\//{' \
    -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
    -e d \
    -e '}' \
    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
    $sed 's|^[^;]*/||' | \
    $sed -f .hsed >> Makefile.new
    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
    >> Makefile.new
    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
    $sed -f .hsed >> Makefile.new
    We have a Perl1!!!!!!!!

    View Slide

  102. Forced resolution
    • But, We have a Per1!!!!
    • I use Perl1 “one liner”!!!
    • Of course you can do it with Perl5 !!!
    $./perl -ni -e 'print unless /(built-in)|(command
    line)/;’ Makefile

    View Slide

  103. Forced resolution
    • But, We have a Per1!!!!
    • I use Perl1 “one liner”!!!
    • Of course you can do it with Perl5 !!!
    $./perl -ni -e 'print unless /(built-in)|(command
    line)/;’ Makefile

    View Slide

  104. fix YACC
    • An error is generated by stabval for which nothing is
    described in YACC
    %type prog decl format
    %type
    %type block lineseq line loop cond
    sideff nexpr else

    View Slide

  105. fix YACC
    • Comment out!!!!!!!
    %type prog decl format
    /*%type */
    %type block lineseq line loop cond
    sideff nexpr else

    View Slide

  106. fix YACC
    • sprintf separates char pointer or int ...
    • Currently int type
    • It is not necessary because sprintf includes header files in
    the first place
    #ifdef CHARSPRINTF
    char *sprintf();
    #else
    int sprintf();
    #endif

    View Slide

  107. fix YACC
    • remove !!!!!!!!
    undef;

    View Slide

  108. correct C language Source
    • unkown type name UIDTYPE…!? Really…!?
    ./perl.h:235:1: error: unknown type name 'UIDTYPE'
    UIDTYPE getuid();
    ^
    ./perl.h:236:1: error: unknown type name 'UIDTYPE'
    UIDTYPE geteuid();
    ^
    ./perl.h:237:1: error: unknown type name 'GIDTYPE'
    GIDTYPE getgid();
    ^
    ./perl.h:238:1: error: unknown type name 'GIDTYPE'
    GIDTYPE getegid();

    View Slide

  109. correct C language Source
    • Modified typed!!!!!!!!
    NAME
    geteuid, getuid -- get user identification
    SYNOPSIS
    #include
    uid_t
    geteuid(void);
    uid_t
    getuid(void);

    View Slide

  110. correct C language Source
    • modify all typed to uid_t
    uid_t getuid();
    uid_t geteuid();
    uid_t getgid();
    uid_t getegid();

    View Slide

  111. correct C language Source
    • conflicting types …!!!
    In file included from arg.c:10:
    ./perl.h:275:14: error: conflicting types for 'times'
    long time(), times();
    ^

    View Slide

  112. correct C language Source
    • modify only times function to long type
    long times();

    View Slide

  113. correct C language Source
    • It is heartbreaking that errors increase....
    arg.c:934:43: error: incomplete definition of type 'struct tms'
    apush(ary,str_nmake(((double)timesbuf.tms_utime)/HZ));
    ~~~~~~~~^
    ./perl.h:226:12: note: forward declaration of 'struct tms'
    EXT struct tms timesbuf;
    ^
    arg.c:935:43: error: incomplete definition of type 'struct tms'
    apush(ary,str_nmake(((double)timesbuf.tms_stime)/HZ));
    ~~~~~~~~^
    ./perl.h:226:12: note: forward declaration of 'struct tms'
    EXT struct tms timesbuf;
    ^
    arg.c:936:43: error: incomplete definition of type 'struct tms'
    apush(ary,str_nmake(((double)timesbuf.tms_cutime)/HZ));

    View Slide

  114. correct C language Source
    • morecoer is not defined as static, etc…
    malloc.c:155:1: error: static declaration of 'morecore' follows non-static
    declaration
    malloc.c:126:5: note: previous implicit declaration is here
    morecore(bucket);
    ^
    malloc.c:164:5: error: non-void function 'morecore' should return a value [-
    Wreturn-type]
    return;
    ^
    malloc.c:181:5: error: non-void function 'morecore' should return a value [-
    Wreturn-type]
    return;
    ^

    View Slide

  115. correct C language Source
    • I will put a word of magic!
    • If you do something with Gcc, it will automatically enter
    but not clang
    static
    morecore(register);
    static
    findbucket(union overhead*, int);

    View Slide

  116. Summary up to here
    In gcc, it is possible to build
    with the correction point
    introduced just now!
    (Let’s try!!)

    View Slide

  117. Perl4.0
    • There is a problem of conflict with C library that function
    name includes
    • We have Perl 5 so replace to other function's name with
    using one-liner.

    View Slide

  118. Perl5.0
    • Perl5.0 is most difficult build to historical Perl versions.
    • Even if Configure is recreated with metaconfig, 

    Makefile cannot be created.

    View Slide

  119. about Perl6
    • The current Perl 6 is mainstream Rakudo
    • Rakudo is a three-stage configuration of VM + NQP
    (NotQuitPerl) + Perl 6 (made by NQP)
    • Traditional Perl 6 is probably like Pugs and Parrot

    View Slide

  120. How to build Perl6
    $POpHVSFQM NBLF NBLFJOTUBMM
    MoarVM/

    NQP/

    Rakudo

    View Slide

  121. dependency
    Perl2
    Perl5

    (git clone)
    Perl6

    View Slide

  122. dependency
    Perl2
    Perl5

    (git clone)
    Perl6

    View Slide

  123. dependency
    Perl2
    Perl5

    (git clone)
    Perl6

    View Slide

  124. dependency
    Perl2
    Perl5

    (git clone)
    Perl6

    View Slide

  125. So, I think…
    Perl2
    Perl5

    (git clone)
    Perl6
    8FOFFEB1FSM
    CJOBSZUPCVJME1FSM

    View Slide

  126. Next
    • I have 3 projects related to traditional Perl.
    • rewrite Perl1 sourcecode C to Rust.
    • Implementing Inline::Perl1 as Perl5 CPAN.
    • Implementing scripts to run all Perl versions with one liner

    (PERL-ALL?)

    View Slide

  127. Conclusion
    • Perl5 is greatness.
    • We can build all Perl versions.
    • Let’s try build old Perl versions!

    View Slide

  128. Thank you for
    Listening!

    View Slide

  129. How to build Perl6
    $POpHVSFQM
    NPBS
    NQP
    +7.
    Set which VM to use
    as an option

    View Slide

  130. How to build Perl6
    .PBS#ZUF$PEF
    /21
    NQP NBLF
    NPBS
    Pass the pre-
    bytecoded NQP
    interpreter to the
    MoarVM binary

    View Slide

  131. How to build Perl6
    .PBS#ZUF$PEF
    /21
    NQP NBLF
    NPBS
    aORQ
    Provide as input
    NQP source code
    describing the NQP
    interpreter

    View Slide

  132. How to build Perl6
    .PBS#ZUF$PEF
    /21
    NQP NBLF
    NPBS
    aORQ
    ORQ

    TUBHF

    View Slide

  133. How to build Perl6
    NQP NBLF
    NPBS
    aORQ
    ORQ

    TUBHF

    ORQ

    TUBHF

    This is often called nqp

    View Slide

  134. How to build Perl6
    Rakudo $POpHVSFQM
    ORQ

    TUBHF

    NPBS

    View Slide

  135. How to build Perl6
    Rakudo
    ORQ

    TUBHF

    NPBS
    aORQ aQN

    View Slide

  136. How to build Perl6
    Rakudo
    ORQ

    TUBHF

    NPBS
    aORQ aQN
    QFSM

    View Slide