Hi,
On Thu, 2023-09-28 at 15:40 -0700, Eliot Miranda wrote:
Hi Jan,
On Thu, Sep 28, 2023 at 5:26 AM Jan Vrany jan@vrany.io wrote:
Hi Eliot and others,
I'm trying to build working VMMaker image in order to see what machine code Cog generates for some simple methods - without success so far. All this is on Linux on AMD64. Detailed report on what exactly I did and what errors I got is below.
In short: (i) does AArch64 sim plugin works on modern linuxes, does anyone use it there?
I don't know. I use macOS almost exclusively for development. I test and use other platforms occasionally. But as far as VMMaker development getting attention, I put my energy into making sure macOS supports all the simulators.
(ii) if so, what's the correct incantation to compile it.
In each platform build you'll find a directory for each of the sims: building/*/{bochsx64,bochsx86,gdbarm32,gdbarm64} and in each directory there is at least a conf.COG and a makeem script.l Most, but not all makeem scripts invoke conf.COG. You need to read to make sure.
Yes, I did all that.
So for each sim from bochsx64,bochsx86,gdbarm32,gdbarm64 on the platform you want to run VMMaker (in your case linux64x64) cd to the directory, run makeem. If there are errores report back here, or try and fix and submit a pull request.
This will build the support libraries (the guts of the sims) for the sim plugins src/plugins/{BochsIA32Plugin/BochsIA32Plugin.c,BochsX64Plugin/BochsX64Plugin.c,GdbARMPlugin/GdbARMPlugin.c,GdbARMv8Plugin/GdbARMv8Plugin.c}
The macos and linux VM makefiles make the plugins if the support directories contain teh sim libraries *and* the plugins.ext file in the VM build dir includes the plugin name. This is the case in squeak.cog.spur directories.
e.g. Aeolus.oscogvm$ head -9 building/linux64x64/squeak.cog.spur/plugins.ext # Copied, perhaps edited, from ../../../src/examplePlugins.ext EXTERNAL_PLUGINS = \ MIDIPlugin \ B3DAcceleratorPlugin \ ClipboardExtendedPlugin \ BochsIA32Plugin \ BochsX64Plugin \ GdbARMPlugin \ GdbARMv8Plugin \ Aeolus.oscogvm$
So once the support libs are built build a VM. It should end up with all the relevant plugins in products/sqcogspur64linuxht The destination i defined by the INSTALLDIR var in the mvm file, e.g. building/linux64x64/squeak.cog.spur/build/mvm
Sorry this is so messy.
(iii) using code in workspace labelled "In-Image Compilation Workspace", is it supposed to work for every method and every ISA or is it normal that it fails with DNU for some methods? I managed to compile but the trivial ones.
It is hoped that it works for all. But this isn't regularly tested. Changes elsewhere sometimes break in-image compilation. Bug reports and fixes gratefully received here. It would be great to add in-9mage compilation checks to a CI system near us, but I'm unable to put in that effort.
Thanks! Jan
HTH
^ ~~~~~~~ 1 warning and 2 errors generated.
This is using clang version 16.0.6 (which mvm script enforces on line 20)
This is a PITA. Findimng a declaration that works across all platforms is difficult but required. That may imply per-platform macros to define the signature.
Yeah, maybe not forcing clang on Linux would help at least to newcomers :-)
- Then I tried to build the VM again, this time with GCC (version 13.2.0 by editing mvm line 20):
cd opensmalltalk-vm/building/linux64x64/squeak.cog.spur/build ./mvm
This failed to compile too, though with different error:
libtool: compile: gcc -Wall -g -O2 -DNDEBUG -DDEBUGVM=0 -msse2 -DCOGMTVM=0 -pthread -DLSB_FIRST=1 -m64 -Wno-missing-braces -Wno-unknown-pragmas -Wno-unused- value -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -DHAVE_CONFIG_H -I.../opensmalltalk- vm/building/linux64x64/squeak.cog.spur/build -I.../opensmalltalk-vm/building/linux64x64/squeak.cog.spur/build -I.../opensmalltalk-vm/platforms/unix/vm - I.../opensmalltalk-vm/platforms/Cross/vm -I.../opensmalltalk-vm/src/spur64.cog -I/usr/local/include -I.../opensmalltalk- vm/platforms/Cross/plugins/GdbARMv8Plugin -I../../../../processors/ARM/gdb-8.3.1/include -I../../../../processors/ARM/gdb-8.3.1/sim/aarch64 -m64 -Wno-missing- braces -Wno-unknown-pragmas -Wno-unused-value -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -c .../opensmalltalk- vm/platforms/Cross/plugins/GdbARMv8Plugin/sqGdbARMv8Plugin.c -fPIC -DPIC -o .libs/sqGdbARMv8Plugin.o In file included from .../opensmalltalk-vm/platforms/Cross/vm/sqMemoryAccess.h:23, from .../opensmalltalk-vm/platforms/unix/vm/sqPlatformSpecific.h:35, from .../opensmalltalk-vm/platforms/Cross/vm/sqAssert.h:16, from .../opensmalltalk-vm/platforms/Cross/plugins/GdbARMv8Plugin/sqGdbARMv8Plugin.c:4: .../opensmalltalk-vm/building/linux64x64/squeak.cog.spur/build/config.h:40:2: error: #error This file was included too late. Please make sure it is included earlier 40 | #error This file was included too late. Please make sure it is included earlier | ^~~~~ .../opensmalltalk-vm/platforms/Cross/plugins/GdbARMv8Plugin/sqGdbARMv8Plugin.c:9:10: fatal error: aarch64/config.h: No such file or directory 9 | #include <aarch64/config.h> | ^~~~~~~~~~~~~~~~~~ compilation terminated. make[1]: *** [Makefile:197: sqGdbARMv8Plugin.lo] Error 1 make: *** [Makefile:557: GdbARMv8Plugin.la] Error 2
I got bitten by this recently too. Someone changed the way we include config.h and that fucked everything up. It was a house of cards, but there we are. I'm not sure how to fix this. It works on macos, and that's my need.
I see. I do not have access to macOS so I guess not AArch64 for me.
).
You're missing some secret sauce:
StackToRegisterMappingCogit genAndDis: SequenceableCollection>>#indexOf:startingAt:ifAbsent: options: #(ObjectMemory Spur64BitCoMemoryManager MULTIPLEBYTECODESETS true ISA X64).
Maybe this should be the default for in-image compilation. Sorry.
Perfect, the secret sauce helped! Thanks a lot!
Best, Jan