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