[Vm-dev] Packaging 64-bit and 32-bit linux VMs

David T. Lewis lewis at mail.msen.com
Thu May 17 02:37:37 UTC 2018


I am thinking in terms of a Unix (Linux) installation as I write this, but here
is how it should work:

- For a 64 bit Spur VM, the VM is invoked by /usr/bin/spur64 or /usr/local/bin/spur64.

- There must be no name conflicts between /usr/local/bin and /usr/bin, and "spur64"
above means "run the 64 bit Spur VM for a 64 bit image" regardless of whether it is
in /usr/bin or /usr/local/bin or ~/bin.

- For a 32 bit Spur VM, the VM is invoked by /usr/bin/spur or /usr/local/bin/spur.

- For a 32 bit Cog (V3) VM, the VM is invoked by /usr/bin/cog or /usr/local/bin/cog.

- For all classic interpreter 32 and 64 bit VMs (V3), the VM is invoked by /usr/bin/squeak
or /usr/local/bin/squeak.

- For any flavor of VM that cannot share external plugins with other flavors,
it is the responsibility of the installation procedure to ensure that the
binaries are installed in a distictly named directory under /usr/lib/squeak
or /usr/local/lib/squeak (or /usr/local/lib/opensmalltalkvm, it does not
matter as long as it is a distictly named location).

- In particular, it must be possible for the same version of OpenSmalltalkVM for
Spur64, Spur, and Cog to coexist in distinctly named folders on a single machine.
As an example, the library directories for the 64 and 32 bit V3 interpreters have
names like 4.16.3-3748 for the 32 bit image and 4.16.3-3748_64bit for the 64 bit
image. A similar naming convention is needed to distinguish Spur 64, Spur 32,
and Cog 32 for the same version of the VM on a single machine installation.

- A run script to handle all of the above should be called /usr/bin/run, such
that the Unix command to run an image is "run image". The choice of the name
"run" results in no naming conflicts on Unix systems .

I am attaching a copy of the /usr/[local/]bin/run that I use on my own PC as
an ad-hoc solution to all of the above. Its restrictions are that it requires
an interpreter VM to be installed (not an issue for me but not good in the
general case), and it requires that I manually install the various Spur/Cog
VMs, then rename their run scripts as /usr/bin/spur64, /usr/bin/spur, and
/usr/bin/cog as described above.

With the above naming conventions in place, any Squeak/Pharo/Cuis image named
"myimage.image" can be run with the command "run myimage".

Dave



On Wed, May 16, 2018 at 11:25:00AM -0700, Eliot Miranda wrote:
>  
> Hi All,
> 
>     at today's board meeting we discussed the issue of packaging 32-bit and
> 64-bit linux VMs in the same directory hierarchy.
> 
> Right now a hierarchy looks like
> 
> Sisyphus.image$ ls -R ../products/sqcogspurlinux
> bin lib squeak
> 
> ../products/sqcogspurlinux/bin:
> squeak
> 
> ../products/sqcogspurlinux/lib:
> squeak
> 
> ../products/sqcogspurlinux/lib/squeak:
> 5.0-201705031421
> 
> ../products/sqcogspurlinux/lib/squeak/5.0-201705031421:
> B3DAcceleratorPlugin UnicodePlugin vm-display-null
> ImmX11Plugin UnixOSProcessPlugin vm-sound-ALSA
> LocalePlugin XDisplayControlPlugin vm-sound-OSS
> SqueakFFIPrims squeak vm-sound-null
> SqueakSSL vm-display-X11 vm-sound-pulse
> UUIDPlugin vm-display-fbdev
> 
> What we need is either the 32-bit VMs to use lib32 or the 64-bit VMs to use
> lib64, and then change the two squeak scripts to parse the command line to
> locate the image and then check the image format to launch the right VM.
> 
> I'd do it but I have other things on my plate right now. If anyone feels
> like volunteering I'm attaching some scripts.  sviver uses hexdump to print
> the image version number, and so something like
> 
> IMVER=`hexdump -n 4 -e '"%u\n"' "$IMAGE"`
> 
> can be used to set IMVER to 68021 for the 64-bit Spur image, 6251 for the
> 32-bit Spur image, etc.
> 
> spurcfvm launches the relevant VM depending on its name (spurcfvm is hard
> linked to spurcdvm spurcavm spur64cfvm et al to select a different VM).  It
> parses the command line to locate the image.
> 
> And I'm including svihdr that prints info from the image header on both
> 64-bit and 32-bit Spur images in case anyone finds it useful.
> 
> _,,,^..^,,,_
> best, Eliot




-------------- next part --------------
#!/bin/sh
# dtl Wed May 20 19:49:25 EDT 2015
# Mon Apr 10 19:18:47 EDT 2017
#
# VM run utility script, typicially installed as /usr/local/bin/run
# usage: run <myimage>
#
# Select a VM and run an image based on the image format number
#
# Assume that /usr/local/bin/squeak runs the traditional VM for 32-bit
# and 64-bit images in the traditional image formats. Assume that
# /usr/local/bin/cog runs Cog, /usr/local/bin/spur runs the VM for 32-bit
# Spur images, and /usr/local/bin/spur64 runs the VM for 64-bit Spur
# images.
#
# Use ckformat to determine image requirements. See package ImageFormat
# in the SqueakSource VMMaker repository. The executable is distributed
# with the standard interpreter VM. To generate C source for the ckformat
# utility, evaluate:
#    "ImageFormat createCkStatusProgram"
#

# VMs look for this default name if an image has not been
# specified. Use the same default for this script.
DEFAULT_IMAGENAME="squeak.image"

# Scripts for running various interpreters
INTERP_SCRIPT="squeak"       # Context VM for 32 and 64 bit images
COG_SCRIPT="cog"             # Cog VM
SPUR_SCRIPT="spur"           # Spur VM for 32-bit Spur image
SPUR64_SCRIPT="spur64"       # Spur VM for 64-bit Spur image

# Assume scripts are in the same directory, e.g. /usr/local/bin
BIN=`dirname "$0"`

# The ckformat utility is distributed with interpreter VM builds.
# Find it in the lib directory for the interpreter VM.
CKFORMAT=`squeak -version | grep 'plugin path' | sed 's/^.*default: //' | sed 's/]$//'`ckformat

# Paths to the run scripts
INTERP="$BIN/$INTERP_SCRIPT" # Context interpreter VM
COG="$BIN/$COG_SCRIPT"       # Cog VM for 32-bit images with closure support
SPUR="$BIN/$SPUR_SCRIPT"     # Spur VM for Spur 32-bit image format 6521
SPUR64="$BIN/$SPUR64_SCRIPT" # Spur VM for Spur 64-bit image format 68109

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 no image name specified on command line, try the default
if test ! ${IMAGENAME}
then
  if test -f ${DEFAULT_IMAGENAME}
  then
    IMAGENAME=${DEFAULT_IMAGENAME}
    NUM=`${CKFORMAT} ${IMAGENAME} 2>/dev/null`
    if test $? -ne 0
    then
      echo image format ${NUM} not recognized for ${IMAGENAME}
      exit 1
    fi
  else
    echo `basename $0` $@: image file not found
    exit 1
  fi
fi

case $NUM in
  6502)
    VM=$INTERP
    ;;
  6504 | 6505)
    VM=$COG
    ;;
  6521)
    VM=$SPUR
    ;;
  68000 | 68002 | 68003)
    VM=$INTERP
    ;;
  68019)
    VM=$SPUR64 # early spur 64
    ;;
  68021)
    VM=$SPUR64
    ;;
  *)  echo image format ${NUM} not recognized for ${IMAGENAME}
    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} $@



More information about the Vm-dev mailing list