Or, how to build a working perl with 4 commands.

Start with a fresh distribution of perl 5.16. Shove it somewhere out of the way and build & test it.

Now create another, simpler directory structure:

llperl \- dll \-src

Copy the 44 .c files required to build the perl516.dll into dll. Copy perlmain.c, 68 perlish header files and couple of other oddballs perly.act perly.tab. Copy 5 files with .c extensions that are use as include files and rename them .cinc. Modified the /includes appropriately. Rename perllib.c to perllib.cpp (it contains c++ code).

Now build the DLL (2 commmands):

C:\test\llperl\dll>cl /MT -c -DWIN32 -DWIN64 -DPERLDLL -DPERL_CORE -DP +ERL_IMPLICIT_SYS -I ..\src *.c *.cpp Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. av.c deb.c doio.c doop.c dump.c DynaLoader.c fcrypt.c globals.c gv.c h +v.c keywords.c locale.c mathoms.c mg.c mro.c numeric.c op.c op.c(10621) : warning C4028: formal paramete +r 2 different from declaration pad.c perl.c perlapi.c Generating Code... Compiling... perlio.c perly. +c pp.c pp_ctl.c pp_hot.c pp_pack.c pp_sort.c pp_sys.c reentr.c regcomp.c regexec.c run.c scope.c sv.c tai +nt.c toke.c universal.c utf8.c util.c win32.c Generating Code... Compiling... Win32CORE.c win32io.c w +in32sck.c win32thread.c Generating Code... Compiling... perllib.cpp Generating Code... C:\test\llperl\dll>link /dll /out:..\perl516.dll -def:..\perldll.def * +.obj ws2_32.lib user32.lib ComCtl32.Lib AdvAPI32.Lib Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. perlio.obj : warning LNK4197: export 'PerlIO_perlio' specified multipl +e times; using first specification perlio.obj : warning LNK4197: export 'PerlIO_pending' specified multip +le times; using first specification Creating library ..\perl516.lib and object ..\perl516.exp C:\test\llperl>dir 02/09/2012 09:53 <DIR> dll 02/09/2012 22:52 2,587,136 perl516.dll 02/09/2012 22:52 153,839 perl516.exp 02/09/2012 22:52 253,364 perl516.lib 02/09/2012 03:46 <DIR> src

Now build perl.exe with 2 more commands:

C:\test\llperl>cl /MT -c -DWIN32 -DWIN64 -DPERL_CORE -DPERL_IMPLICIT_ +SYS -I src src\*.c Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. perlmain.c C:\test\llperl>link /OUT:perllVm.exe *.obj perl516.lib ws2_32.lib user +32.lib ComCtl32.Lib AdvAPI32.Lib Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. C:\test\llperl>dir 02/09/2012 09:53 <DIR> dll 02/09/2012 22:52 2,587,136 perl516.dll 02/09/2012 22:52 153,839 perl516.exp 02/09/2012 22:52 253,364 perl516.lib 02/09/2012 03:29 23,359 perldll.def 02/09/2012 22:56 38,400 perllVm.exe 02/09/2012 22:56 1,015 perlmain.obj 02/09/2012 03:46 <DIR> src

And try it:

C:\test\llperl>perllVm -v This is perl 5, version 16, subversion 1 (v5.16.1) built for MSWin32-x +64-multi-thread Copyright 1987-2012, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. C:\test\llperl>perllVm -E"say 'Hello, world!'" Hello, world! C:\test\llperl>type Ack.pl #! perl -sw use strict; use 5.010; use Time::HiRes qw[ time ]; no warnings 'recursion'; sub Ack { my( $M, $N ) = @_; return $N + 1 if $M == 0; return Ack( $M - 1, 1 ) if $N == 0; return Ack( $M - 1, Ack( $M, $N - 1 ) ); } my $start = time; say Ack( @ARGV ); say 'Took: ', time() - $start; C:\test\llperl>perllVm Ack.pl 3 9 4093 Took: 15.6298589706421

How's that compare with the standard build:

C:\test\llperl>\test\perl-5.16.1\perl.exe Ack.pl 3 9 4093 Took: 9.76109409332275

Slow, but then I never enabled any optimisation, but it did run the XS module TIme::HiRes without incident. Which is cool and a good sign.

So what's the point? Well now I copy the same start structure and files to another directory and do this:

C:\test\perllVm>dir 02/09/2012 04:04 331 Ack.pl 02/09/2012 22:10 1,863 build.cmd 02/09/2012 23:12 <DIR> dll 02/09/2012 03:29 23,359 perldll.def 02/09/2012 05:01 <DIR> src C:\test\perllVm>cd dll C:\test\perllVm\dll>set opts=-c -fno-caret-diagnostics -fno-color-diag +nostics C:\test\perllVm\dll>set warn=-Wno-unused-value -Wno-deprecated-declara +tions -Wno-parentheses -Wno-deprecated-writable-strings C:\test\perllVm\dll>set defs=-DWIN32 -DWIN64 -DPERLDLL -DPERL_CORE -DP +ERL_IMPLICIT_SYS C:\test\perllVm\dll>set srcs=av.c deb.c doio.c doop.c dump.c DynaLoade +r.c fcrypt.c globals.c gv.c hv.c keywords.c locale .c mathoms.c mg.c mro.c numeric.c op.c pad.c perl.c perlapi.c perlio.c + perllib.cpp perly.c pp.c pp_ctl.c pp_hot.c pp_pac k.c pp_sort.c pp_sys.c reentr.c regcomp.c regexec.c run.c scope.c sv.c + taint.c toke.c universal.c utf8.c util.c win32.c Win32CORE.c win32io.c win32sck.c win32thread.c C:\test\perllVm\dll>set libs=ws2_32.lib user32.lib ComCtl32.Lib AdvAPI +32.Lib C:\test\perllVm\dll>\llvm\clang.exe -m64 -I ..\src %opts% %warn% %defs +% %srcs% In file included from sv.c:41: ./stdint.h:197:9: warning: 'INT64_C' macro redefined ..\src/handy.h:204:28: note: previous definition is here In file included from sv.c:41: ./stdint.h:202:9: warning: 'UINT64_C' macro redefined ..\src/handy.h:205:28: note: previous definition is here win32.c:1925:30: warning: format specifies type 'int' but the argument + has type 'DWORD' (aka 'unsigned long') [-Wformat] win32.c:1925:33: warning: format specifies type 'int' but the argument + has type 'DWORD' (aka 'unsigned long') [-Wformat] win32.c:1929:36: warning: format specifies type 'int' but the argument + has type 'DWORD' (aka 'unsigned long') [-Wformat] win32.c:1977:41: warning: format specifies type 'unsigned int' but the + argument has type 'DWORD' (aka 'unsigned long') [-Wformat] C:\test\perllVm\dll>dir /b *.o av.o deb.o doio.o doop.o dump.o DynaLoader.o fcrypt.o globals.o gv.o h +v.o keywords.o locale.o mathoms.o mg.o mro.o numeric.o op.o pad.o perl.o perlapi.o perlio.o perllib.o perly.o pp.o +pp_ctl.o pp_hot.o pp_pack.o pp_sort.o pp_sys.o reentr.o regcomp.o regexec.o run.o scope.o sv.o taint.o toke.o univers +al.o utf8.o util.o win32.o Win32CORE.o win32io.o win32sck.o win32thread.o C:\test\perllVm\dll>link /verbose:lib /dll /noentry /out:..\perl516.dl +l -def:..\perldll.def *.obj /libpath %libs% | wc -l 1796

No surprise it didn't quite link yet -- still a lot to learn about the clang/llvm, toolset -- but now I've got a nice simple environment in which to play. (I like simple!)

Of course, I would have got there a lot sooner with some expert assistance.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong

Social

In reply to perllVm: A start. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.