<div dir="ltr">It's a bit outdated and aimed for newbies but you can see my posts about the VM:<div><br></div><div><a href="https://marianopeck.wordpress.com/2011/04/28/the-first-part-of-the-journey-is-over/">https://marianopeck.wordpress.com/2011/04/28/the-first-part-of-the-journey-is-over/</a><br></div><div><a href="https://marianopeck.wordpress.com/2011/07/18/the-second-part-of-the-journey-is-over/">https://marianopeck.wordpress.com/2011/07/18/the-second-part-of-the-journey-is-over/</a><br></div><div><br></div><div>Cheers,</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 18, 2017 at 3:11 AM,  <span dir="ltr"><<a href="mailto:raffaello.giulietti@lifeware.ch" target="_blank">raffaello.giulietti@lifeware.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Clément and Nicolas,<br>
<br>
thanks for the useful hints and background information.<br>
<br>
<br>
<br>
<br>
On 17/10/17 19:22, Nicolas Cellier wrote:<br>
><br>
><br>
><br>
><br>
><br>
><br>
> 2017-10-17 19:03 GMT+02:00 Nicolas Cellier<br>
> <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@<wbr>gmail.com</a><br>
> <mailto:<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.<wbr>nice@gmail.com</a>>>:<br>
><br>
><br>
><br>
>     2017-10-17 16:00 GMT+02:00 Clément Bera <<a href="mailto:bera.clement@gmail.com">bera.clement@gmail.com</a><br>
>     <mailto:<a href="mailto:bera.clement@gmail.com">bera.clement@gmail.com</a><wbr>>>:<br>
><br>
>          <br>
>         Hi Raffaello,<br>
><br>
>         Answers inlined...<br>
><br>
>         On Tue, Oct 17, 2017 at 3:07 PM, Raffaello Giulietti<br>
>         <<a href="mailto:raffaello.giulietti@lifeware.ch">raffaello.giulietti@lifeware.<wbr>ch</a><br>
<span class="">>         <mailto:<a href="mailto:raffaello.giulietti@lifeware.ch">raffaello.giulietti@<wbr>lifeware.ch</a>>> wrote:<br>
><br>
><br>
>             Hi,<br>
><br>
>             I'm interested in understanding the overall OpenSmalltalk VM<br>
>             structure and design and its build process.<br>
><br>
>             I read [1] and [2] to get a high level picture of the vm and<br>
>             its interesting strategy to development (Slang, VMMaker, etc.)<br>
><br>
>             Apart from these, are there other useful<br>
>             documents/sites/tutorials on the vm development process in<br>
>             general and about the underlying ideas in the build process?<br>
>             I'm aware that vm construction is a rather special topic but<br>
>             any useful reference or hint is welcome.<br>
><br>
>             I'm already familiar with the interesting [3] and [4]<br>
>             websites and their authors papers, talks and slides, but<br>
>             these do not seem to help much in clarifying the development<br>
>             process itself.<br>
><br>
>             In particular, I'm targeting Pharo 64 bit/Win 64 bit<br>
>             (x64-86). I hope to be able someday to actively participate<br>
>             in bringing Cog/Spur/Sista to a more mature status on this<br>
>             platform.<br>
><br>
>             The questions I would like to find an answer to are of the<br>
>             following kind:<br>
>             * Where should I start?<br>
><br>
><br>
</span>>         A good start would be to load the Squeak VMMaker dev image (See<br>
>         here: <a href="http://www.mirandabanda.org/cogblog/build-image/" rel="noreferrer" target="_blank">http://www.mirandabanda.org/<wbr>cogblog/build-image/</a><br>
>         <<a href="http://www.mirandabanda.org/cogblog/build-image/" rel="noreferrer" target="_blank">http://www.mirandabanda.org/<wbr>cogblog/build-image/</a>>) and read the<br>
>         different opened workspaces. In addition, ... <br>
><br>
>         *Compilation toolchain*<br>
><br>
>         To check you have everything installed to compile, you can go to<br>
>         the one of the build folder (One of the windows build folder if<br>
>         you're on windows, for example build.Win64x64, in most case we<br>
>         don't recommend cross compilation), read the HowToBuild file,<br>
>         then go to one of the inner folder and use the mvm script to<br>
>         compile a VM from pre-generated C sources.<br>
><br>
><br>
>     See below though, on windows, we target mingw so it's kind of<br>
>     cross-compilation anyway.<br>
><br>
><br>
>         If it does not work, check on the openSmalltalk-VM repo how the<br>
>         VM is built using Travis CI and set-up your machine similarly to<br>
>         the Travis slaves.<br>
><br>
>         *Changes in Slang (GC/Interpreter/JIT/...)*<br>
><br>
>         In general when you want to change something in the GC /<br>
>         Interpreter the process is as follow:<br>
><br>
>         1) Make your changes work with the StackVM (interpreter-only)<br>
>         simulator<br>
>         2) Make your changes work with the compiled StackVM<br>
>         (interpreter-only) <br>
>         3) Make your changes work with the CogVM simulator<br>
>         4) Make your changes work with the compiled CogVM<br>
><br>
>         In general when you want to change something in the JIT the<br>
>         process is as follow:<br>
><br>
>         1) Make your changes generate correct in-image machine code<br>
>         2) Make your changes work with the CogVM simulator<br>
>         3) Make your changes work with the compiled CogVM<br>
><br>
>         So a good place to start is to have the simulators working. You<br>
>         could use this to help:<br>
>         <a href="https://clementbera.wordpress.com/2016/05/30/simulating-the-cog-vm/" rel="noreferrer" target="_blank">https://clementbera.wordpress.<wbr>com/2016/05/30/simulating-the-<wbr>cog-vm/</a><br>
>         <<a href="https://clementbera.wordpress.com/2016/05/30/simulating-the-cog-vm/" rel="noreferrer" target="_blank">https://clementbera.<wbr>wordpress.com/2016/05/30/<wbr>simulating-the-cog-vm/</a>><br>
><br>
>         Once the simulator works with your changes, you can generate C<br>
>         sources with something like "VMMaker generateConfiguration"<br>
><br>
>         *Changes in Platform code*<br>
>         *<br>
>         *<br>
>         Go to the platform folder at the root and change the C files<br>
>         with a text editor<br>
<span class="">>          <br>
><br>
>             * Should I use Squaek or can I use Pharo for vm development<br>
>             purposes?<br>
><br>
><br>
</span>>         Currently I still use Squeak but I plan to migrate to Pharo. I'd<br>
>         say it's still a bit easier from Squeak due to package<br>
>         compatibility making it hard to commit from Pharo without<br>
>         uncommitting something else, some scripts are also present by<br>
>         default in the Squeak dev image, but everything should work on<br>
>         both environments. No big deal in using one of the other.<br>
<span class="">>          <br>
><br>
>             * What are the restrictions of Slang?<br>
><br>
><br>
</span>>         ...<br>
>         As long as the VM compiles and run, this is correct Slang code,<br>
>         else it's not.<br>
>         In general you should just think in C and write Smalltalk instead. <br>
>         I don't know what to say. This is not dynamic at all. No<br>
>         dictionaries, no look-up, no nothing. Even arrays look like<br>
>         Smalltalk arrays but like C arrays you don't have the actual size.<br>
>         Blocks work as long as they're inlined and removed when<br>
>         performing inlining in the Slang to C compiler.<br>
<span class="">><br>
>             * Where does VMMaker live?<br>
><br>
><br>
</span>>         Half there:<br>
>         <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm" rel="noreferrer" target="_blank">https://github.com/<wbr>OpenSmalltalk/opensmalltalk-vm</a><br>
>         <<a href="https://github.com/OpenSmalltalk/opensmalltalk-vm" rel="noreferrer" target="_blank">https://github.com/<wbr>OpenSmalltalk/opensmalltalk-vm</a><wbr>><br>
>         Accessible from git<br>
><br>
>         Half there:<br>
>         <a href="http://source.squeak.org/VMMaker/" rel="noreferrer" target="_blank">http://source.squeak.org/<wbr>VMMaker/</a><br>
>         <<a href="http://source.squeak.org/VMMaker/" rel="noreferrer" target="_blank">http://source.squeak.org/<wbr>VMMaker/</a>><br>
>         Accessible from Monticello<br>
<span class="">><br>
>             * Which C toolchain shall I use? <br>
><br>
>             * Which release of gcc, ld, make are known to work?<br>
>             * What about clang?<br>
><br>
><br>
</span>>         Depends on the platform. The mvm script normally chooses for you. <br>
><br>
>         All VMs are built from Travis CI so you can check how to set up<br>
>         your machine from the Travis set-up.<br>
><br>
>         On linux it's gcc by default. All recent gcc versions should<br>
>         work since 4.4<br>
>         On Mac, gcc is not supported anymore, so clang is used. I've<br>
>         used many different versions of clang and they all worked.<br>
><br>
>         Specific compiler versions that don't work are mentioned in the<br>
>         HowToBuild file in the platform folders (if any).<br>
<span class="">>          <br>
><br>
>             * Which version of cygwin64 or mingw64 are OK?<br>
><br>
><br>
</span>>         Arf. Both worked at some point, I don't know what the default<br>
>         script use right now I would start with the version used by the<br>
>         mvm script / the Travis build.<br>
><br>
><br>
>     gcc is broken for win64 (or at least not satisfying our expectations<br>
>     about stack management)<br>
>     So we have to use clang.<br>
>     For this reason, we prefer to compile thru cygwin which has prebuilt<br>
>     (downlodable) clang modules.<br>
>     It's much more difficult to get a working clang in a mingw<br>
>     environment, so this brand is not maintained anymore.<br>
><br>
><br>
> Ah, and there was another grief with mingw...<br>
> Currently the VM still uses DirectX-9.<br>
> cygwin provides support for this (maybe it's not very future proof now...)<br>
> mingw status is unclear, and it seems that recent distributions lack<br>
> this support...<br>
><br>
><br>
>     But the target is a mingw target, not a cygwin target (we don't want<br>
>     VM to depend on cygwin layer, we want to stay minimal).<br>
>     So we use a cross compiler. See the line<br>
><br>
>     TOOLPREFIX:=x86_64-w64-<wbr>mingw32-<br>
><br>
>     in<br>
>     <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/build.win64x64/common/Makefile.tools" rel="noreferrer" target="_blank">https://github.com/<wbr>OpenSmalltalk/opensmalltalk-<wbr>vm/blob/Cog/build.win64x64/<wbr>common/Makefile.tools</a><br>
>     <<a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/build.win64x64/common/Makefile.tools" rel="noreferrer" target="_blank">https://github.com/<wbr>OpenSmalltalk/opensmalltalk-<wbr>vm/blob/Cog/build.win64x64/<wbr>common/Makefile.tools</a>><br>
><br>
>     Using cross-compiler means that we can eventually build a x86_64<br>
>     .exe from a cygwin32.<br>
>     But cygwin32 does not provide a debugger (gdb) for x86_64, that's<br>
>     why we prefer developing from a cygwin64 environment.<br>
><br>
>     Eventually, I have a hand-assembled visual studio project for<br>
>     compiling the vm with MSVC (2015 if I remember...)<br>
>     Of course that kind of project should better be generated (as was<br>
>     possible via cmake) rather than hand-assembled...<br>
>     It's absolutely cumbersome to maintain such .vc(x)proj across<br>
>     several versions of MSVC.<br>
>     Anyway, it does not produce working VM yet.<br>
>     I retried with 2017 but encountered a code generation bug.<br>
><br>
>     We could try to adapt the gnu makefiles to use MSVC thru command<br>
>     line, but IMO the main interest of MSVC is to perform complementary<br>
>     analysis thru IDE.<br>
<span class="">><br>
>          <br>
><br>
>             * etc.<br>
><br>
><br>
><br>
>             Greetings<br>
>             Raffaello<br>
><br>
>             ---<br>
><br>
>             [1] <a href="http://www.vpri.org/pdf/tr1997001_backto.pdf" rel="noreferrer" target="_blank">http://www.vpri.org/pdf/<wbr>tr1997001_backto.pdf</a><br>
>             <<a href="http://www.vpri.org/pdf/tr1997001_backto.pdf" rel="noreferrer" target="_blank">http://www.vpri.org/pdf/<wbr>tr1997001_backto.pdf</a>><br>
>             [2]<br>
</span>>             <a href="http://design.cs.iastate.edu/vmil/2011/papers/p03-miranda.pdf" rel="noreferrer" target="_blank">http://design.cs.iastate.edu/<wbr>vmil/2011/papers/p03-miranda.<wbr>pdf</a> <<a href="http://design.cs.iastate.edu/vmil/2011/papers/p03-miranda.pdf" rel="noreferrer" target="_blank">http://design.cs.iastate.edu/<wbr>vmil/2011/papers/p03-miranda.<wbr>pdf</a>><br>
<span class="">>             [3] <a href="http://www.mirandabanda.org/cogblog/" rel="noreferrer" target="_blank">http://www.mirandabanda.org/<wbr>cogblog/</a><br>
>             <<a href="http://www.mirandabanda.org/cogblog/" rel="noreferrer" target="_blank">http://www.mirandabanda.org/<wbr>cogblog/</a>><br>
>             [4] <a href="https://clementbera.wordpress.com/" rel="noreferrer" target="_blank">https://clementbera.wordpress.<wbr>com/</a><br>
</span>>             <<a href="https://clementbera.wordpress.com/" rel="noreferrer" target="_blank">https://clementbera.<wbr>wordpress.com/</a>><br>
><br>
><br>
><br>
><br>
>         --<br>
>         Clément Béra<br>
>         Pharo consortium engineer<br>
>         <a href="https://clementbera.wordpress.com/" rel="noreferrer" target="_blank">https://clementbera.wordpress.<wbr>com/</a><br>
>         <<a href="https://clementbera.wordpress.com/" rel="noreferrer" target="_blank">https://clementbera.<wbr>wordpress.com/</a>><br>
>         Bâtiment B 40, avenue Halley 59650 Villeneuve d'Ascq<br>
><br>
><br>
><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br></div>
</div>