Making Reform squeak

Hello,

as I had succeeded at building the Squeak VM on Reform and was asked on Twitter to document the details, here goes. :slight_smile:

Some background: I wanted to run a contemporary Squeak on Reform, and since there’s no pre-built aarch64 download available, I needed to build the VM myself. The build was not entirely straightforward, because the Squeak headers could not be included before Linux’ features.h. This was the case at least on aarch64 Linux (i.e., Reform); building from the same sources on macOS worked just fine.

My “solution” is crude and brute-force; I simply rearranged the include orders in some files. This likely breaks the build elsewhere. There should be a better solution.

The build should work like so:

  • git clone https://github.com/OpenSmalltalk/opensmalltalk-vm.git

  • cd opensmalltalk-vm/build.linux64ARMv8/squeak.cog.spur/build

  • ./mvm (reply yes to do a clean build if asked, outwait the configure run and wait for the build error)

  • apply the diff given below (I’d suggest to do it at this stage because I’m not sure whether any generated files are affected)

  • ./mvm (reply no when asked for the clean)

I hope the build will succeed. If it dpesn’t, please let me know. I’d also love to work towards a better solution that works across platforms.

The most recent Squeak image loads just fine for me. (Place the image, changes, and sources in the same directory and start the VM, passing the image file name on the command line.)

Best,

Michael

diff --git a/platforms/Cross/plugins/B4DAcceleratorPlugin/sqOpenGLRenderer.c b/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c
index b58ed8bb7..cadd1323a 100644
--- a/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c
+++ b/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c
@@ -16,13 +16,14 @@
 # include <windows.h>
 # include <winerror.h>
 #endif
+#include "sqVirtualMachine.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <limits.h>
 
-#include "sqVirtualMachine.h"
+//#include "sqVirtualMachine.h"
 #include "sqConfig.h"
 #include "sqPlatformSpecific.h"
 #include "B3DAcceleratorPlugin.h"
diff --git a/platforms/Cross/plugins/IA32ABI/arm64abicc.c b/platforms/Cross/plugins/IA32ABI/arm64abicc.c
index 4d16db6e6..96801d118 100644
--- a/platforms/Cross/plugins/IA32ABI/arm64abicc.c
+++ b/platforms/Cross/plugins/IA32ABI/arm64abicc.c
@@ -11,6 +11,7 @@
  */
 #if defined(__ARM_ARCH_ISA_A64) || defined(__arm64__) || defined(__aarch64__) || defined(ARM64)
 
+#include "sqMemoryAccess.h"
 #include <unistd.h> /* for getpagesize/sysconf */
 #include <stdlib.h> /* for valloc */
 #include <sys/mman.h> /* for mprotect */
@@ -19,7 +20,7 @@
 #include <setjmp.h>
 #include <stdio.h> /* for fprintf(stderr,...) */
 
-#include "sqMemoryAccess.h"
+//#include "sqMemoryAccess.h"
 #include "vmCallback.h"
 #include "sqAssert.h"
 #include "sqVirtualMachine.h"
diff --git a/platforms/Cross/plugins/SoundCodecPrims/sqSoundCodecPluginBasicPrims.c b/platforms/Cross/plugins/SoundCodecPrims/sqSoundCodecPluginBasicPrims.c
index 8f2a2c438..2a3ff1973 100644
--- a/platforms/Cross/plugins/SoundCodecPrims/sqSoundCodecPluginBasicPrims.c
+++ b/platforms/Cross/plugins/SoundCodecPrims/sqSoundCodecPluginBasicPrims.c
@@ -9,11 +9,12 @@
    patch level 10. This was done to simplify Squeak source code maintenance.
  */
 
+#include "SoundCodecPrims.h"
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
-#include "SoundCodecPrims.h"
+//#include "SoundCodecPrims.h"
 
 /****** begin "gsm.h" *****/
 
diff --git a/platforms/Cross/plugins/Squeak3D/b3dInit.c b/platforms/Cross/plugins/Squeak3D/b3dInit.c
index 20531bdbd..629e4422d 100644
--- a/platforms/Cross/plugins/Squeak3D/b3dInit.c
+++ b/platforms/Cross/plugins/Squeak3D/b3dInit.c
@@ -12,10 +12,11 @@
 *
 *
 *****************************************************************************/
+#include "b3d.h"
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
-#include "b3d.h"
+//#include "b3d.h"
 
 #define b3dCompensateWindowPos 1
 
diff --git a/platforms/Cross/plugins/Squeak3D/b3dMain.c b/platforms/Cross/plugins/Squeak3D/b3dMain.c
index 96819243d..211541d84 100644
--- a/platforms/Cross/plugins/Squeak3D/b3dMain.c
+++ b/platforms/Cross/plugins/Squeak3D/b3dMain.c
@@ -12,11 +12,12 @@
 *
 *
 *****************************************************************************/
+#include "b3d.h"
 #include <stdio.h>  /* printf() */
 #include <stdlib.h> /* exit()   */
 #include <limits.h> /* INT_MIN INT_MAX */
 
-#include "b3d.h"
+//#include "b3d.h"
 #include "b3dAlloc.h"
 
 #ifndef NULL
diff --git a/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c b/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c
index e25220277..1461da3c3 100644
--- a/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c
+++ b/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c
@@ -19,6 +19,7 @@ eem 3/15/2017	Allow functions registered with ioGetSurfaceFormat,
                avoid installing two null callbacks for unlock & show.
 */
 
+#include "sqVirtualMachine.h"
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -28,7 +29,7 @@ eem 3/15/2017	Allow functions registered with ioGetSurfaceFormat,
 /* Default EXPORT macro that does nothing (see comment in sq.h): */
 #define EXPORT(returnType) returnType
 
-#include "sqVirtualMachine.h"
+//#include "sqVirtualMachine.h"
 #include "sqConfig.h"
 #include "sqPlatformSpecific.h"
 #include "SurfacePlugin.h"
diff --git a/platforms/Cross/vm/sq.h b/platforms/Cross/vm/sq.h
index d06c84119..af58552d4 100755
--- a/platforms/Cross/vm/sq.h
+++ b/platforms/Cross/vm/sq.h
@@ -27,6 +27,7 @@
 #endif
 
 
+#include "sqMemoryAccess.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -38,7 +39,7 @@
 #include <math.h>
 #include "sqMathShim.h"
 
-#include "sqMemoryAccess.h"
+//#include "sqMemoryAccess.h"
 #include "sqVirtualMachine.h"
 
 #define true	1
diff --git a/platforms/Cross/vm/sqHeapMap.c b/platforms/Cross/vm/sqHeapMap.c
index 3d18dc00e..48e0d96c9 100644
--- a/platforms/Cross/vm/sqHeapMap.c
+++ b/platforms/Cross/vm/sqHeapMap.c
@@ -19,11 +19,12 @@
  *
  ****************************************************************************/
 
+#include "sqMemoryAccess.h"
 #include <stdlib.h>
 #include <string.h> /* for memset */
 #include <stdio.h> /* for perror */
 
-#include "sqMemoryAccess.h" 
+//#include "sqMemoryAccess.h" 
 #include "sqAssert.h" /* for error */
 
 #define ulong usqIntptr_t   /* enough for holding a pointer - unsigned long does not fit in LLP64 */
diff --git a/platforms/Cross/vm/sqSCCSVersion.h b/platforms/Cross/vm/sqSCCSVersion.h
index e224fed69..e0688a53e 100644
--- a/platforms/Cross/vm/sqSCCSVersion.h
+++ b/platforms/Cross/vm/sqSCCSVersion.h
@@ -21,6 +21,10 @@
 #define MERCURIAL 0
 #define GIT 1
 
+#if VERSION_PROGRAM
+#include "sq.h"
+#endif
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -171,7 +175,7 @@ sourceVersionString(char separator)
 
 
 #if VERSION_PROGRAM
-# include "sq.h"
+//# include "sq.h"
 
 #if SistaVM
 # define NICKNAME "Sista"
diff --git a/platforms/Cross/vm/sqVirtualMachine.c b/platforms/Cross/vm/sqVirtualMachine.c
index a86c9be0c..6837a4bad 100755
--- a/platforms/Cross/vm/sqVirtualMachine.c
+++ b/platforms/Cross/vm/sqVirtualMachine.c
@@ -1,3 +1,5 @@
+#define FOR_SVM_C
+#include "sqVirtualMachine.h"
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -5,8 +7,8 @@
 #include <time.h>
 #include <setjmp.h>
 
-#define FOR_SVM_C
-#include "sqVirtualMachine.h"
+//#define FOR_SVM_C
+//#include "sqVirtualMachine.h"
 #include "sqAssert.h"
 
 
diff --git a/platforms/unix/plugins/FileAttributesPlugin/faSupport.c b/platforms/unix/plugins/FileAttributesPlugin/faSupport.c
index 2d73af10e..3cc99f849 100644
--- a/platforms/unix/plugins/FileAttributesPlugin/faSupport.c
+++ b/platforms/unix/plugins/FileAttributesPlugin/faSupport.c
@@ -2,12 +2,13 @@
  * faSupport.c - Unix support routines for the FileAttributesPlugin
  *
  */
+#include "sq.h"
 #include <errno.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <assert.h>
 
-#include "sq.h"
+//#include "sq.h"
 #include "faCommon.h"
 
 extern struct VirtualMachine * interpreterProxy;
diff --git a/platforms/unix/vm/sqPlatformSpecific.h b/platforms/unix/vm/sqPlatformSpecific.h
index 2a854cb44..334e4671d 100644
--- a/platforms/unix/vm/sqPlatformSpecific.h
+++ b/platforms/unix/vm/sqPlatformSpecific.h
@@ -31,8 +31,9 @@
 #ifndef _SQ_PLATFORM_SPECIFIC_H
 #define _SQ_PLATFORM_SPECIFIC_H
 
-#include <stdio.h>
 #include "sqMemoryAccess.h"
+#include <stdio.h>
+//#include "sqMemoryAccess.h"
 
 #undef sqAllocateMemory
 #undef sqGrowMemoryBy
diff --git a/platforms/unix/vm/sqUnixVMProfile.c b/platforms/unix/vm/sqUnixVMProfile.c
index 442488e1c..501eaa2e0 100644
--- a/platforms/unix/vm/sqUnixVMProfile.c
+++ b/platforms/unix/vm/sqUnixVMProfile.c
@@ -43,6 +43,7 @@ ioClearProfile(void)
 {
 }
 #else /* NO_VM_PROFILE */
+#include "sq.h"
 #include <pthread.h>
 #include "include_ucontext.h"
 #include <signal.h>
@@ -57,7 +58,7 @@ extern unsigned long _etext;
 
 #include <errno.h>
 
-#include "sq.h"
+//#include "sq.h"
 
 /*
  * The pc collection scheme is an event buffer into which are written pcs.  The
diff --git a/spur64src/vm/cogitARMv8.c b/spur64src/vm/cogitARMv8.c
index a3d3a0481..7f8c2c3ab 100644
--- a/spur64src/vm/cogitARMv8.c
+++ b/spur64src/vm/cogitARMv8.c
@@ -8,11 +8,12 @@ char *__cogitBuildInfo = __buildInfo;
 
 
 
+#include "sqConfig.h"
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "sqConfig.h"
+//#include "sqConfig.h"
 #include "sqPlatformSpecific.h"
 #include "sqMemoryAccess.h"
 #include "sqCogStackAlignment.h"
diff --git a/spur64src/vm/gcc3x-cointerp.c b/spur64src/vm/gcc3x-cointerp.c
index c856e3c59..cf505bb0d 100644
--- a/spur64src/vm/gcc3x-cointerp.c
+++ b/spur64src/vm/gcc3x-cointerp.c
@@ -22,11 +22,12 @@ char *__interpBuildInfo = __buildInfo;
 # define SQ_USE_GLOBAL_STRUCT_REG 0
 #endif
 
+#include "sqGnu.h"
 #include <stdio.h> /* for printf */
 #include <stdlib.h> /* for e.g. alloca */
 #include <setjmp.h>
 #include <wchar.h> /* for wint_t */
-#include "sqGnu.h"
+//#include "sqGnu.h"
 #include "vmCallback.h"
 #include "sqMemoryFence.h"
 #include "sqImageFileAccess.h"
4 Likes

Thanks for posting this Michael, and for making the effort. I’m very excited to try out Squeak on my Reform and will report back with my attempt once my unit arrives.

If we continue to have trouble at that point I can post on the squeak-dev mailing list and see what people think.

Thanks for this!

It seems that I have to disable the CameraPlugin, as it does not seem to be up to date. (I need to revisit this). To disable it add this patch to the previous one:

diff --git a/build.linux64ARMv8/squeak.cog.spur/plugins.ext     b/build.linux64ARMv8/squeak.cog.spur/plugins.ext
index 5a62e9ac5..14afb2152 100755
--- a/build.linux64ARMv8/squeak.cog.spur/plugins.ext
+++ b/build.linux64ARMv8/squeak.cog.spur/plugins.ext
@@ -3,7 +3,6 @@ EXTERNAL_PLUGINS = \
 B3DAcceleratorPlugin \
 BochsIA32Plugin \
 BochsX64Plugin \
-CameraPlugin \
 FileAttributesPlugin \
 MIDIPlugin \
 Squeak3D \
1 Like