[Vm-dev] CMake patches for 32/64 bit VM installations,
and a VM selector utility
David T. Lewis
lewis at mail.msen.com
Mon Jan 3 01:33:27 UTC 2011
Hi Ian,
Attached are some platforms/unix changes that provide support for
selecting an appropriate VM based on image format, as well as for
building and installing the VM for 64-bit images in a separate
installation location. With these changes in place you can have
a 64-bit VM, a 32-bit VM, and a 32-bit Cog VM running side by side
without conflict. Building the 64-bit versus 32-bit interpreter is
controlled with a command line option passed to the cmake/configure
script.
The latest version of SqS/VMMaker is required to provide the
ckformat.c program and a hook in Interpreter for checking image
format from platform sources.
The changes are:
platforms/unix/cmake/vmrun.in:
New file, creates ${bindir}/vmrun script for selecting a VM
based on image file format. Use standard VM by default if Cog
or squeak64 are not present.
platforms/unix/cmake/configure:
If --SQ_VI_BYTES_PER_WORD=8 is specified on command line for the
configure script, then configure the build for a 64-bit VM (i.e.
a VM to run 64-bit images, whether compiled on a 32 or 64 bit
platform). Install executable files in ${plgdir}_64bit/ and
install executable script as ${bindir}/squeak64.
platforms/unix/vm/build.cmake:
Build the ckformat utility program and install it in ${bindir}.
The ckformat source code is generated by latest the VMMaker.
Support 64-bit VM build for --SQ_VI_BYTES_PER_WORD=8.
platforms/unix/vm/config.cmake
Support 64-bit VM build for --SQ_VI_BYTES_PER_WORD=8. Adds
the SQ_VI_BYTES_PER_WORD macro to config.h to produce a VM
for 64-bit images.
platforms/unix/cmake/config.in
Support 64-bit VM build for --SQ_VI_BYTES_PER_WORD=8.
platforms/unix/CMakeLists.txt
Support 64-bit VM build for --SQ_VI_BYTES_PER_WORD=8.
platforms/unix/vm/sqUnixMain.c:
Add "-imageversion" argument to cause the VM to read the
image format number for image file specified on command line,
print it to stdout and exit. With a 32-bit VM, this works
for 32-bit images only, so ckformat is probably the better
approach overall (but this is a trivial addition, so I'm adding
it here).
Cheers,
Dave
The patched files are attached in platforms-unix.tgz. For reference,
the diffs are:
===================================================================
RCS file: platforms/unix/vm/RCS/config.cmake,v
retrieving revision 1.1
diff -r1.1 platforms/unix/vm/config.cmake
247a248,252
>
> IF (DEFINED SQ_VI_BYTES_PER_WORD)
> CONFIG_DEFINE (SQ_VI_BYTES_PER_WORD)
> ENDIF (DEFINED SQ_VI_BYTES_PER_WORD)
>
===================================================================
RCS file: platforms/unix/vm/RCS/build.cmake,v
retrieving revision 1.1
diff -r1.1 platforms/unix/vm/build.cmake
17a18,21
> ADD_EXECUTABLE (ckformat
> ${src}/ckformat.c
> )
>
64,65c68,69
< COMMAND sh ${bld}/config ${config}/squeak.in ${bld}/squeak
< COMMAND chmod +x ${bld}/squeak
---
> COMMAND sh ${bld}/config ${config}/squeak.in ${bld}/squeak${scriptsuffix}
> COMMAND chmod +x ${bld}/squeak${scriptsuffix}
74c78,84
< ADD_DEPENDENCIES (squeakvm squeak squeak.sh)
---
> ADD_CUSTOM_TARGET (vmrun
> DEPENDS ${config}/vmrun.in
> COMMAND sh ${bld}/config ${config}/vmrun.in ${bld}/vmrun
> COMMAND chmod +x ${bld}/vmrun
> )
>
> ADD_DEPENDENCIES (squeakvm squeak squeak.sh ckformat vmrun)
76c86
< INSTALL (PROGRAMS ${bld}/squeak DESTINATION bin)
---
> INSTALL (PROGRAMS ${bld}/squeak${scriptsuffix} DESTINATION bin)
77a88,89
> INSTALL (PROGRAMS ${bld}/ckformat DESTINATION bin)
> INSTALL (PROGRAMS ${bld}/vmrun DESTINATION bin)
===================================================================
RCS file: platforms/unix/vm/RCS/sqUnixMain.c,v
retrieving revision 1.1
diff -r1.1 platforms/unix/vm/sqUnixMain.c
98a99,100
> static int showImageType= 0; /* print image format on stdout and exit */
>
1055a1058
> else if (!strcmp(argv[0], "-imageversion")) { showImageType = 1; return 1; }
1099a1103
> printf(" -imageversion print image format version, then exit\n");
1295a1300,1308
>
> if (showImageType) /* print image format on stdout and exit */
> {
> sqInt imageFormatVersion = readImageFormatFromFileStartingAt(f, 0);
> sqImageFileClose(f);
> printf("%d", imageFormatVersion);
> exit(0);
> }
>
===================================================================
RCS file: platforms/unix/cmake/RCS/vmrun.in,v
retrieving revision 1.1
diff -r1.1 platforms/unix/cmake/vmrun.in
0a1,81
> #!/bin/sh
> #
> # vmrun utility script, Jan 1, 2011 dtl
> #
> # Select a VM and run an image based on the image format number
> #
> # Assume that [bindir]/squeak runs the traditional VM,
> # [bindir]/cog runs Cog, and [bindir]/squeak64 runs
> # a traditional intepreter VM compiled for 64-bit images.
> #
> # Use ckformat to determine image requirements. See package
> # ImageFormat in the SqueakSource VMMaker repository. To
> # generate C source for the ckformat utility, evaluate
> # "ImageFormat createCkStatusProgram"
> #
>
> BIN=[bindir]
> CKFORMAT="$BIN/ckformat" # The ckformat utility
> INTERP="$BIN/squeak" # Standard 32-bit interpreter, all 32-bit images
> INTERP_64="$BIN/squeak64" # Standard interpreter for 64-bit images
> COG="$BIN/cog" # Cog VM for 32-bit images with closure support
>
> for arg in $*
> do
> case ${arg} in
> -*) #ignore
> ;;
> *) # either and option argument or the image name
> if test -f ${arg}
> then
> NUM=`$CKFORMAT ${arg} 2>/dev/null`
> if test $? -eq 0
> then
> IMAGENAME=${arg}
> break
> fi
> else
> if test -f ${arg}.image
> then
> NUM=`$CKFORMAT ${arg}.image 2>/dev/null`
> if test $? -eq 0
> then
> IMAGENAME=${arg}.image
> break
> fi
> fi
> fi
> ;;
> esac
> done
>
> if test ! ${IMAGENAME}
> then
> echo `basename $0`: image file not found for \"$0 $@\"
> exit 1
> fi
>
> case $NUM in
> 6502)
> VM=$INTERP
> ;;
> 6504 | 6505)
> VM=$COG
> ;;
> 68000 | 68002 | 68003)
> VM=$INTERP_64
> ;;
> *) echo image format $NUM not recognized;
> exit -1;;
> esac
>
> # Use standard VM as default if preferred VM not present
> if test ! -x ${VM}
> then
> echo ${VM} not found, using ${INTERP}
> VM="${INTERP}"
> fi
>
> #echo running ${IMAGENAME} with image format $NUM using $VM
> exec ${VM} $@
>
===================================================================
RCS file: platforms/unix/cmake/RCS/config.in,v
retrieving revision 1.1
diff -r1.1 platforms/unix/cmake/config.in
6c6
< s%\[version\]%@version@%g
---
> s%\[version\]%@version@@versionsuffix@%g
===================================================================
RCS file: platforms/unix/cmake/RCS/configure,v
retrieving revision 1.1
diff -r1.1 platforms/unix/cmake/configure
11,17c11,18
< --help print this message and then exit
< --src=<directory> look for generated interpreter sources in <directory>
< --prefix=<directory> install into <prefix>/{bin,lib,man}
< --CFLAGS=<flags> override default compiler flags
< --without-<plugin> do not build the named plugin
< --without-gl disable everything that depends on OpenGL
< --without-SUGAR disable support for SUGAR environment
---
> --help print this message and then exit
> --src=<directory> find generated interpreter sources in <directory>
> --prefix=<directory> install into <prefix>/{bin,lib,man}
> --CFLAGS=<flags> override default compiler flags
> --without-<plugin> do not build the named plugin
> --without-gl disable everything that depends on OpenGL
> --without-SUGAR disable support for SUGAR environment
> --SQ_VI_BYTES_PER_WORD=8 interpreter for 64-bit images
===================================================================
RCS file: platforms/unix/RCS/CMakeLists.txt,v
retrieving revision 1.1
diff -r1.1 platforms/unix/CMakeLists.txt
15a16,24
> # If the VM is for 64-bit images, install as squeak64
> IF (DEFINED OPT--SQ_VI_BYTES_PER_WORD)
> SET (SQ_VI_BYTES_PER_WORD "${OPT--SQ_VI_BYTES_PER_WORD}")
> IF (${SQ_VI_BYTES_PER_WORD} EQUAL 8)
> SET (versionsuffix "_64bit")
> SET (scriptsuffix "64")
> ENDIF (${SQ_VI_BYTES_PER_WORD} EQUAL 8)
> ENDIF (DEFINED OPT--SQ_VI_BYTES_PER_WORD)
>
22c31
< SET (plgdir lib/squeak/${version})
---
> SET (plgdir lib/squeak/${version}${versionsuffix})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: platforms-unix.tgz
Type: application/x-gtar
Size: 19629 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110102/6df47b4e/platforms-unix-0001.tgz
More information about the Vm-dev
mailing list