[Vm-dev] [commit][3613] Update the VM build instructions for Mac OS X.

commits at squeakvm.org commits at squeakvm.org
Thu Feb 18 19:54:25 UTC 2016


Revision: 3613
Author:   eliot
Date:     2016-02-18 11:54:22 -0800 (Thu, 18 Feb 2016)
Log Message:
-----------
Update the VM build instructions for Mac OS X.
Update the Mac OS X makefiles to not fail if the Bochs and GdbARM support
libraries are unavailable.  Fix a complaint about an empty object file in the
RePlugin.

Modified Paths:
--------------
    branches/Cog/README
    branches/Cog/build.macos32x86/HowToBuild
    branches/Cog/build.macos32x86/common/Makefile.app
    branches/Cog/build.macos32x86/common/Makefile.plugin
    branches/Cog/build.macos32x86/common/Makefile.vm
    branches/Cog/build.macos64x64/HowToBuild
    branches/Cog/build.macos64x64/common/Makefile.app
    branches/Cog/build.macos64x64/common/Makefile.plugin
    branches/Cog/build.macos64x64/common/Makefile.vm
    branches/Cog/platforms/iOS/plugins/BochsIA32Plugin/Makefile
    branches/Cog/platforms/iOS/plugins/BochsX64Plugin/Makefile
    branches/Cog/platforms/iOS/plugins/GdbARMPlugin/Makefile

Added Paths:
-----------
    branches/Cog/platforms/iOS/plugins/RePlugin/
    branches/Cog/platforms/iOS/plugins/RePlugin/Makefile

Modified: branches/Cog/README
===================================================================
--- branches/Cog/README	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/README	2016-02-18 19:54:22 UTC (rev 3613)
@@ -75,21 +75,17 @@
 	sistasrc/vm			- Smalltalk Sista V3
 	spursistasrc/vm		- Smalltalk Sista Spur
 	spursrc/vm			- Smalltalk Cog Spur
+	spur64src/vm		- Smalltalk Cog Spur 64-bit
 	spurstacksrc/vm		- Smalltalk Stack Spur
+	spurstack64src/vm	- Smalltalk Stack Spur 64-bit
 	src/vm				- Smalltalk Cog V3
 	stacksrc/vm			- Smalltalk Stack V3
 
-There are two plugin directories
-	nscogsrc/plugins
+All plugins are in the directory
 	src/plugins
 
 These contain many, but not all, of the plugins available for the VM.  Others
 can be found in Cog, or in various Monticello packages in various repositories.
-The two directories include essentially the same material exept for the
-IA32ABI/IA32ABI.c plugin, the core plugin for the Alien FFI on x86 platforms.
-In Newspeak this plgin has support for per-object immutability, a feature
-as-yet-unimplemented in Cog but that was available on the old context-based
-Newspeak interpreter VM.
 
 Each vm source directory contains several files, a subset of the following:
 	cogit.c				- the JIT; a Cogit cooperates with a CoInterpreter
@@ -114,7 +110,8 @@
 before the end of 2014.  The current "official" buikd directories are of the
 form build.OS_WordSize_Processor, and include
 	build.linux32x86	- uses autoconf, gcc and make
-	build.macos32x86	- uses XCode and gcc (currently for 10.6 or earlier)
+	build.macos32x86	- 32-bit Mac OS X using XCode and clang
+	build.macos64x64	- 64-bit Mac OS X using XCode and clang
 	build.win32x86		- uses cygwin, gcc and make
 More can be added as required.  In each there is a HowToBuild that describes
 the necessary steps to produce a VM.
@@ -164,7 +161,8 @@
 Finally the image directory contains scripts that will build a "VMMaker" image,
 a Squeak Smalltalk image containing all the packages that comprise the Cog
 system, suitable for developing the VM and for generating (or updating) the
-sources in the vm source directories.
+sources in the vm source directories. There is also a script for generating a
+64-bit Spur image from a 32-bit Spur image.
 
 Eliot Miranda
-June 2014
+Frebruary 2016

Modified: branches/Cog/build.macos32x86/HowToBuild
===================================================================
--- branches/Cog/build.macos32x86/HowToBuild	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos32x86/HowToBuild	2016-02-18 19:54:22 UTC (rev 3613)
@@ -1,13 +1,17 @@
 How To Build On Mac OS X
----------------------
+------------------------
+This file (build.macos32x86/HowToBuild) describes how to build VMs that run
+32-bit images.  build.macos64x64/HowToBuild describes how to build VMs that
+run 64-bit images.
 
 
 Contents:
 	- Overview
 	- Checking out sources to build out-of-the-box
 	- Building out of the box
-	- Building the Bochs Support Libraries
-	- Optimization level and gcc version (please read!)
+	- The Structure of the Makefiles
+	- Building the VM Simulator Support Libraries
+	- Using Different Compilers
 
 
 Overview
@@ -30,6 +34,7 @@
 Spur, as described on the www.mirandabanda.org blog, is a faster object
 representation which uses generation scavenging, lazy forwarding for fast
 become, and a single object header format common to 32 and 64 bit versions.
+Newspeak, Squeak 5 and the upcoming release of Pharo all use Spur.
 
 Another distinction is between normal single-threaded VMs that schedule "green"
 Smalltalk processes above a single-threaded VM, and "multi-threaded" VMs that
@@ -60,113 +65,120 @@
 processor sources and the relevant build directories
      svn co http://www.squeakvm.org/svn/squeak/branches/Cog/platforms
      svn co http://www.squeakvm.org/svn/squeak/branches/Cog/processors
+     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/{spursrc,src} etc
+		(see section "VM source directories" in the root README)
+     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/sources
+		(this is needed only to install Smalltalk source files)
      svn co http://www.squeakvm.org/svn/squeak/branches/Cog/build.macos32x86
-     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/src etc
-		(see section "VM source directories" in the root README)
 
 
 Building out of the box
 -----------------------
-0. As of this writing (December 2015) only the squeak.cog.spur builds build
-on 10.9 and later, using John McIntosh's Cocoa platform support files.  The
-rest of the builds build only on 10.6.x (and probably 10.5.x) using the old
-Carbon libraries.  We are transitioning as fast as possible to Cocoa.
-Volunteers welcome.
+0. The build system is based on Gnu Make for makefiles, and Xcode.app for
+compilers and libraries.  You will need a Mac OS X machine running at least
+10.7.x (the author is currently using 10.9) and Xcode v6 or later.  The system
+builds only the new Cocoa based VMs that use the platforms/iOS tree.  The old
+Carbon-based VMs using platforms/Mac OS are unsupported.
 
-Carbon Builds:
-1. Install the tools (Xcode etc);  the CoreVM.xcodeproj is set-up to build
-   using gcc 4.2 but you can optionally install the Intel C++ compiler 11.1
-   and change the compilerSpec in CoreVM.xcodeproj/project.pbxproj to get
-   better performance.
+1. Install the tools (Xcode etc).  If you want to sign the application make sure
+you have installed a suitable certificate via Keychain Access and that the
+signing identity is in the SIGNING_IDENTITY environment variable, e.g. in the
+author's .profile is the line
+export SIGNING_IDENTITY="Developer ID Application: Eliot Miranda"
 
-2. Either disable the building of the Bochs plugin (see each makevm file,
-disabling the lines beginning "# Build the BochsIA32Plugin") or build the
-Bochs support libraries (see Building the Bochs Support Libraries below).
-
-3. cd to the VM configuration of your choice and execute
+2. cd to the VM configuration of your choice and run the mvm script, e.g.
+	cd buiild.macos32x86/squeak.cog.spur
 	./mvm -A
-This will build Fast.app, Debug.app and Assert.app applications containing the
-three basic VM configurations.  If the configuration includes the multi-threaded
+This will build CocoaFast.app, CocoaDebug.app and CocoaAssert.app applications
+containing the three basic VM configurations.  If the configuration includes
+the multi-threaded
 VM you can use mvm -AS to make the single-threaded VMs, mvm -AT to make the
 multi-threadeds in FastMT.app et al, and mvm -A to make them all.  mvm -d will
 make the Debug.app VM, etc.  mvm -? provides the gory details.
 
-Cocoa Builds:
-1. Install the tools (Xcode etc);  the SqueakCogSpur32x86.xcodeproj is set-up to
-build using clang 6.x or clang 7.x.
-
-2. Either disable the building of the Bochs plugins (see each makeiosvm file,
-disabling the lines beginning "# Build the BochsIA32Plugin") or build the
-Bochs support libraries (see Building the Bochs Support Libraries below).
-
-3. cd to the VM configuration of your choice and execute
-	./miosvm -A
-This will build CocoaFast.app, CocoaDebug.app and CocoaAssert.app applications
-containing the three basic VM configurations.  If the configuration includes
-the multi-threaded VM you can use miosvm -AS to make the single-threaded VMs,
-miosvm -AT to make the multi-threadeds in FastMT.app et al, and miosvm -A to make
-them all.  miosvm -d will make the CocoaDebug.app VM, etc.  miosvm -? provides the
-gory details.
-
-
-
 Each build directory contains three files
 	plugins.int
 	plugins.ext
-On other platforms editing these and making is all one needs to do to change the
-set of plugins.  Alas on Xcode one also has to edit the relevant Xcode projects
-to add and remove source files.  If you're brave enough to contemplate this
-you're brave enough to figure out how to do this yourself.
+Editing these and making is all one needs to do to change the set of plugins.
+But see The Structure of the Makefiles below for "complicated" plugins.
 
 
-Building the Bochs Support Libraries
-------------------------------------
-If you want to get the Cog VM simulator working you'll need to build the
-BochsIA32Plugin and/or the BochsX64Plugin to build that you'll need to first
-build bochs.  First check-out the processor simulator source tree containing
-Bochs:
-     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/processors
-Then build the libraries.  cd to e.g. build.macos32x86/bochsx86, run
+The Structure of the Makefiles
+------------------------------
+Each VM build directory contains the mvm script, a root Makefile that selects
+the VM source to build, plugins.int to specify the internal plugins to build,
+and plugins.ext to specify the external plugins (if any) to build.  The root
+Makefile then includes a full Makefile from the common directory.  For example,
+squeak.cog.spur's Makefile (minus commentary) reads
+	----8<-----build.macos32x86/squeak.cog.spur/Makefile----8<---------------
+	VMSRCDIR:= ../../spursrc/vm
+	SOURCEFILE:=SqueakV50.sources
 
-  $ cd build.macos32x86/bochsx86
-  $ ./conf.COG
-  $ ../../processors/IA32/bochs/makeem
+	include ../common/Makefile.app.squeak.cog
+	----8<-----build.macos32x86/squeak.cog.spur/Makefile----8<---------------
+Some external plugins require spport libraries.  In particular, the processor
+simulators used by VMMaker.oscog to develop the VM JITs, depend on C or C++
+code that implements a processor simulator.  See below.  Plugins that require
+extra support or special compilation have makefiles under
+platforms/iOS/plugins/, for example plugins/iOS/plugins/RePlugin/Makefile.
+This Makefile sets some values and then includes common/Makefile.plugin to do
+the dirty work.  If you add an exotic plugin that requires such source please
+read the plugin makefile build.macos32x86/common/Makefile.plugin and the
+makefiles under plugins/iOS/plugins for examples of the facilities available.
 
+The files in build.macos32x86/common are
+	Makefile.app
+		The top-level makefile for CocoaFast.app et al.
+		It includes Makefile.vm to build the vm and plugins and then constructs
+		and optionally signs the .app bundle.  It may also install a Smalltalk
+		source file.
+	Makefile.app.newspeak
+		Modifies Makefile.app to rename the executable and install sources
+	Makefile.app.squeak.cog
+		Modifies Makefile.app to use the green VM icon that implies Cog
+	Makefile.flags
+		Defines the compilation flags and SDK to use in building the VM
+	Makefile.plugin
+		Makes either an internal FooPlugin.lib or an external FooPlugin.bundle.
+		If platforms/iOS/plugins/FooPlugin/Makefile exists Makefile.vm will
+		use it, and it should include Makefile.plugin to do the dirty work.
+	Makefile.rules
+		Defines the rules for compiling c, c++ and objective-c source files,
+		including maintaining dependency information.
+	Makefile.vm
+		Makes the VM executable in the chosen configuration from product,
+		assert or debug.  Decodes plugins.int and plugins.ext and invokes
+		make with the relevant makefile, either a special one such as
+		platforms/iOS/plugins/RePlugin/Makefile or Makefile.plugin, for each
+		internal or external plugin.
+	mkNamedPrims.sh
+		This script makes sqNamedPrims.h which defines the exports from the set
+		of internal plugins that the VM uses to access the primitives in
+		internal plugins.
 
-Using gcc with Xcode 6.x, Mac OS X > 10.6
------------------------------------------
-We're in the process of transitioning from a Carbon/Mac OS X 10.6/Xcode
-3.1.x build system to a Cocoa/Mac OS X 10.9 or above/Xcode 6.x/7.x build
-system.  We're still building a VM that should run on 10.6.  By default
-Xcode uses the clang compiler.
-You may want to use a different compiler.  For example, to install gcc 5.2
-see http://hamelot.co.uk/programming/add-gcc-compiler-to-xcode-6/
-(Thanks Hammad!).
-Essentially
-- install brew
-	ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-- get all available versions of gcc
-	brew tap homebrew/versions
-- build gcc 5.2 (Eliot: my first attempt failed with some library
-		incompatibility during the bootstrap, I then installed 4.8 successfully
-		and retried installing 5.2 and miraculously this time it worked)
-	brew install gcc5
-- get the GCC 5.2 plugin for Xcode:
-	git clone https://github.com/hmazhar/xcode-gcc.git
-- install the Xcode plugin for the gcc 5.2 compiler
-	open /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/
-	open xcode-gcc
- and use the finder to copy the plugin into the Xcode app bundle.
 
-Optimization level and gcc version
-----------------------------------
-There are issues with gcc version > 4.2.1.  Any of the following flags may break the build at -O2:
--ftree-pre
--fpartial-inlining
--fcaller-saves
+Building the VM Simulator Support Libraries
+-------------------------------------------
+As of this writing there are three processors with three sets of support
+libraries.  If you want to build these they are in
+	build.macos32x86/{bochsx86,bochsx64,gdbarm32}
+In each directory there is a conf.COG script.  Cd to the directory, run the
+script, and in the case of the bochs directories also run makeem.  e.g.
+	$ cd build.macos32x86/bochsx86
+	$ ./conf.COG
+	$ ../../processors/IA32/bochs/makeem
+Then cd to the VM build directoruy of your choice and build.
 
-They're turned off in the Xcode files provided.
 
+Using Different Compilers
+-----------------------------------------
+The build system uses Xcode's default compiler, clang by default.
+You may want to use a different compiler.  Users claim this is possible.
+For example, to install gcc 5.2 see
+	http://hamelot.co.uk/programming/add-gcc-compiler-to-xcode-6/
+(Thanks Hammad!).  There are no guarantees that this will work, but that's the
+best pointer I've found.
 
+
 Eliot Miranda
-December 2015
+February 2016

Modified: branches/Cog/build.macos32x86/common/Makefile.app
===================================================================
--- branches/Cog/build.macos32x86/common/Makefile.app	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos32x86/common/Makefile.app	2016-02-18 19:54:22 UTC (rev 3613)
@@ -62,16 +62,30 @@
 endif
 
 
-$(APP):	$(VMEXE) $(VMBUNDLES) $(VMPLIST) $(VMMENUNIB) $(VMICONS) $(SOURCES) \
-		$(APPPOST) signapp touchapp
+$(APP):	cleanbundles $(VMEXE) $(VMBUNDLES) $(VMPLIST) $(VMMENUNIB) $(VMICONS) \
+ 		$(SOURCES) $(APPPOST) signapp touchapp
 
+# Bundles with missing prerequisites won't be built. But we need to force the
+# attempt to make them every time in case the prerequisites /have/ been built.
+# to do this we must both delete the bundles and touch any ignore files, upon
+# which the bundle build depends.
+cleanbundles:
+	-rm -rf $(APP)/Contents/Resources/*.bundle
+	-touch $(OBJDIR)/*.ignore
+
 $(VMEXE): $(OBJDIR)/$(VM)
 	mkdir -p $(APP)/Contents/MacOS
 	cp -p $(OBJDIR)/$(VM) $(APP)/Contents/MacOS
 
 $(APP)/Contents/Resources/%.bundle: $(BLDDIR)/vm/%.bundle
-	mkdir -p $(APP)/Contents/Resources
-	cp -pR $< $(APP)/Contents/Resources
+	@mkdir -p $(APP)/Contents/Resources
+	@if [ -f $(basename $<).ignore ]; then \
+		echo $(notdir $<) is being ignored; \
+		rm -rf $^; \
+	else \
+		echo cp -pR $< $(APP)/Contents/Resources; \
+		cp -pR $< $(APP)/Contents/Resources; \
+	fi
 
 $(VMPLIST): $(OSXDIR)/$(SYSTEM)-Info.plist getversion
 	mkdir -p $(APP)/Contents

Modified: branches/Cog/build.macos32x86/common/Makefile.plugin
===================================================================
--- branches/Cog/build.macos32x86/common/Makefile.plugin	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos32x86/common/Makefile.plugin	2016-02-18 19:54:22 UTC (rev 3613)
@@ -13,6 +13,7 @@
 # LIBSRC     overrides the set of files to compile (if EXCLUDESRC inconvenient)
 # LINK_WITH_CPP set to non-empty to link external plugin bundle with c++ runtime
 # SRCDIRS    supplies additional directories containing files to compile.
+# PREREQUISITES supplies names of files that must exist to make lib or bundle
 
 # VM config flags.
 ifeq ($(CONFIGURATION),product)
@@ -139,6 +140,9 @@
 $(VMDIR):
 	mkdir -p $(VMDIR)
 
+# If any prerequisites are declared all must exist to continue
+ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES)))
+
 $(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ)
 	-rm $(PLUGINLIB)
 	ar -rc $(PLUGINLIB) $(LIBOBJ)
@@ -169,3 +173,21 @@
 	mkdir -p $(PLUGINBUNDLE)/Contents
 	sed "s/\$$(VERSION)/`getversion VERSION_TAG`/" $< | \
 	sed "s/\$(LIBNAME)/$(LIBNAME)/" > $(PLUGINPLIST)
+
+else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES))
+# If any prerequisites are missing simply create a .ignore file
+
+#$(info $$(PREREQUISITES): $(abspath $(PREREQUISITES)))
+#$(info $$(realpath $$(PREREQUISITES)): $(realpath $(PREREQUISITES)))
+
+$(PLUGINLIB): FORCE
+	$(warning $(PLUGINLIB) has missing prerequisites. Not building.)
+	echo >$(basename $(PLUGINLIB)).ignore
+
+$(PLUGINBUNDLE):	FORCE
+	$(warning $(PLUGINBUNDLE) has missing prerequisites. Not building.)
+	echo >$(basename $(PLUGINBUNDLE)).ignore
+
+FORCE:
+
+endif

Modified: branches/Cog/build.macos32x86/common/Makefile.vm
===================================================================
--- branches/Cog/build.macos32x86/common/Makefile.vm	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos32x86/common/Makefile.vm	2016-02-18 19:54:22 UTC (rev 3613)
@@ -132,8 +132,8 @@
 	$(POSTCOMPILE)
 
 -include deps/version.d
-	
-product:;
+
+product:
 	$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product $(@,product=) default
 
 assert:
@@ -183,12 +183,12 @@
 	@echo VMOBJ=$(VMOBJ)
 	@echo -----------------------------------------------------
 
-#vm:	$(OBJDIR)/$(VM)
+ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore)))
 
 $(OBJDIR)/$(VM): $(OBJDIR) $(VMOBJ) $(LIBS)
 	$(CC) -arch $(TARGET_ARCH) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(OSXCOMMONDIR)/version.c
 	$(CC) -arch $(TARGET_ARCH) -isysroot $(SDK) $(LDFLAGS) $(FRAMEWORKS) \
-			-o $(OBJDIR)/$(VM) $(VMOBJ) $(LIBS)
+			-o $(OBJDIR)/$(VM) $(VMOBJ) $(filter-out $(call ignore), $(LIBS))
 
 $(OBJDIR):
 	@-mkdir -p $(BLDDIR)
@@ -205,15 +205,15 @@
 #
 .PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle
 
-#plugin-makefile = $(shell test -f $(OSXPLUGINSDIR)/$(1)/Makefile && echo $(OSXPLUGINSDIR)/$(1)/Makefile || echo ../common/Makefile.plugin)
-plugin-makefile = $(realpath $(OSXPLUGINSDIR)/$(1)/Makefile ../common/Makefile.plugin)
+plugin-makefile = $(firstword $(realpath $(OSXPLUGINSDIR)/$(1)/Makefile ../common/Makefile.plugin))
 
 # Internal plugin.  Build as lib then link in lib
 # Check for Makefile in iOS plugins directory otherwise use default Makefile
 # N.B.  PLATDIR *must* be a relative path for this to work
-$(OBJDIR)/%.lib: getversion $(call plugin-makefile,$(*F))
+$(OBJDIR)/%.lib: getversion $(call plugin-makefile,$(*F)) $(wildcard $(*F).ignore)
 	@-mkdir -p $(BLDDIR)/$(*F)
-	test $@ -ot $(call plugin-makefile,$(*F)) && rm $(OBJDIR)/$(*F).lib || true
+	test $@ -ot $(call plugin-makefile,$(*F)) && rm $(BUILD)/vm/$(*F).lib || true
+	rm -f $(BUILD)/vm/$(*F).ignore
 	$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
 		-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
 		CONFIGURATION=$(CONFIGURATION) ARCH=$(TARGET_ARCH) \
@@ -228,9 +228,10 @@
 
 # External plugin.  Build as bundle and copy to vm dir ($(OBJDIR)).
 # Check for Makefile in iOS plugins directory otherwise use default Makefile
-$(OBJDIR)/%.bundle:	getversion $(call plugin-makefile,$(*F))
+$(OBJDIR)/%.bundle:	getversion $(call plugin-makefile,$(*F)) $(wildcard $(*F).ignore)
 	@-mkdir -p $(BLDDIR)/$(*F)
-	test $@ -ot $(call plugin-makefile,$(*F)) && rm $(OBJDIR)/$(*F).lib || true
+	test $@ -ot $(call plugin-makefile,$(*F)) && rm -rf $(BUILD)/vm/$(*F).bundle || true
+	rm -f $(BUILD)/vm/$(*F).ignore
 	$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
 		-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
 		CONFIGURATION=$(CONFIGURATION) ARCH=$(TARGET_ARCH) \

Modified: branches/Cog/build.macos64x64/HowToBuild
===================================================================
--- branches/Cog/build.macos64x64/HowToBuild	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos64x64/HowToBuild	2016-02-18 19:54:22 UTC (rev 3613)
@@ -1,13 +1,17 @@
 How To Build On Mac OS X
----------------------
+------------------------
+This file (build.macos64x64/HowToBuild) describes how to build VMs that run
+64-bit images.  build.macos32x86/HowToBuild describes how to build VMs that
+run 32-bit images.
 
 
 Contents:
 	- Overview
 	- Checking out sources to build out-of-the-box
 	- Building out of the box
-	- Building the Bochs Support Libraries
-	- Optimization level and gcc version (please read!)
+	- The Structure of the Makefiles
+	- Building the VM Simulator Support Libraries
+	- Using Different Compilers
 
 
 Overview
@@ -25,10 +29,12 @@
 adaptive optimization that does speculative inlining at the bytecode-to-bytecode
 level.  These are targeted for release in 2015.
 
-Another distinction is between 32-bit and 64-bit Spur VMs.  While Spur
-has a common object header format common to 32 and 64 bit versions, the 32-bit
-version uses 32-bit pointers and immediates, whereas the 64-bit version uses
-64-bit pointers and immediates and will only run on 64-bit machines.
+Another distinction is between "v3" VMs and Spur VMs.  "v3" is the original
+object representation for Squeak as described in the back-to-the-future paper.
+Spur, as described on the www.mirandabanda.org blog, is a faster object
+representation which uses generation scavenging, lazy forwarding for fast
+become, and a single object header format common to 32 and 64 bit versions.
+Newspeak, Squeak 5 and the upcoming release of Pharo all use Spur.
 
 Another distinction is between normal single-threaded VMs that schedule "green"
 Smalltalk processes above a single-threaded VM, and "multi-threaded" VMs that
@@ -59,58 +65,120 @@
 processor sources and the relevant build directories
      svn co http://www.squeakvm.org/svn/squeak/branches/Cog/platforms
      svn co http://www.squeakvm.org/svn/squeak/branches/Cog/processors
+     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/{spursrc,src} etc
+		(see section "VM source directories" in the root README)
+     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/sources
+		(this is needed only to install Smalltalk source files)
      svn co http://www.squeakvm.org/svn/squeak/branches/Cog/build.macos64x64
-     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/src etc
-		(see section "VM source directories" in the root README)
 
 
 Building out of the box
 -----------------------
-0. As of this writing (December 2015) only the squeak.cog.spur builds build
-on 10.9 and later, using John McIntosh's Cocoa platform support files.  The
-rest of the builds don't work yet.  We are transitioning as fast as possible
-to Cocoa.  Volunteers welcome.
+0. The build system is based on Gnu Make for makefiles, and Xcode.app for
+compilers and libraries.  You will need a Mac OS X machine running at least
+10.7.x (the author is currently using 10.9) and Xcode v6 or later.  The system
+builds only the new Cocoa based VMs that use the platforms/iOS tree.  The old
+Carbon-based VMs using platforms/Mac OS are unsupported.
 
-1. Install the tools (Xcode etc);  the SqueakCogSpur32x86.xcodeproj is set-up to
-build using clang 6.x or clang 7.x.
+1. Install the tools (Xcode etc).  If you want to sign the application make sure
+you have installed a suitable certificate via Keychain Access and that the
+signing identity is in the SIGNING_IDENTITY environment variable, e.g. in the
+author's .profile is the line
+export SIGNING_IDENTITY="Developer ID Application: Eliot Miranda"
 
-2. Either disable the building of the Bochs plugins (see each makeiosvm file,
-disabling the lines beginning "# Build the BochsIA32Plugin") or build the
-Bochs support libraries (see Building the Bochs Support Libraries below).
-
-3. cd to the VM configuration of your choice and execute
-	./miosvm -A
+2. cd to the VM configuration of your choice and run the mvm script, e.g.
+	cd buiild.macos64x64/squeak.cog.spur
+	./mvm -A
 This will build CocoaFast.app, CocoaDebug.app and CocoaAssert.app applications
 containing the three basic VM configurations.  If the configuration includes
-the multi-threaded VM you can use miosvm -AS to make the single-threaded VMs,
-miosvm -AT to make the multi-threadeds in FastMT.app et al, and miosvm -A to make
-them all.  miosvm -d will make the CocoaDebug.app VM, etc.  miosvm -? provides the
-gory details.
+the multi-threaded
+VM you can use mvm -AS to make the single-threaded VMs, mvm -AT to make the
+multi-threadeds in FastMT.app et al, and mvm -A to make them all.  mvm -d will
+make the Debug.app VM, etc.  mvm -? provides the gory details.
 
-
-
 Each build directory contains three files
 	plugins.int
 	plugins.ext
-On other platforms editing these and making is all one needs to do to change the
-set of plugins.  Alas on Xcode one also has to edit the relevant Xcode projects
-to add and remove source files.  If you're brave enough to contemplate this
-you're brave enough to figure out how to do this yourself.
+Editing these and making is all one needs to do to change the set of plugins.
+But see The Structure of the Makefiles below for "complicated" plugins.
 
 
-Building the Bochs Support Libraries
-------------------------------------
-If you want to get the Cog VM simulator working you'll need to build the
-BochsIA32Plugin and/or the BochsX64Plugin to build that you'll need to first
-build bochs.  First check-out the processor simulator source tree containing
-Bochs:
-     svn co http://www.squeakvm.org/svn/squeak/branches/Cog/processors
-Then build the libraries.  cd to e.g. build.macos32x86/bochsx86, run
+The Structure of the Makefiles
+------------------------------
+Each VM build directory contains the mvm script, a root Makefile that selects
+the VM source to build, plugins.int to specify the internal plugins to build,
+and plugins.ext to specify the external plugins (if any) to build.  The root
+Makefile then includes a full Makefile from the common directory.  For example,
+squeak.cog.spur's Makefile (minus commentary) reads
+	----8<-----build.macos64x64/squeak.cog.spur/Makefile----8<---------------
+	VMSRCDIR:= ../../spursrc/vm
+	SOURCEFILE:=SqueakV50.sources
 
-  $ cd build.macos32x86/bochsx86
-  $ ./conf.COG
-  $ ../../processors/IA32/bochs/makeem
+	include ../common/Makefile.app.squeak.cog
+	----8<-----build.macos64x64/squeak.cog.spur/Makefile----8<---------------
+Some external plugins require spport libraries.  In particular, the processor
+simulators used by VMMaker.oscog to develop the VM JITs, depend on C or C++
+code that implements a processor simulator.  See below.  Plugins that require
+extra support or special compilation have makefiles under
+platforms/iOS/plugins/, for example plugins/iOS/plugins/RePlugin/Makefile.
+This Makefile sets some values and then includes common/Makefile.plugin to do
+the dirty work.  If you add an exotic plugin that requires such source please
+read the plugin makefile build.macos64x64/common/Makefile.plugin and the
+makefiles under plugins/iOS/plugins for examples of the facilities available.
 
+The files in build.macos64x64/common are
+	Makefile.app
+		The top-level makefile for CocoaFast.app et al.
+		It includes Makefile.vm to build the vm and plugins and then constructs
+		and optionally signs the .app bundle.  It may also install a Smalltalk
+		source file.
+	Makefile.app.newspeak
+		Modifies Makefile.app to rename the executable and install sources
+	Makefile.app.squeak.cog
+		Modifies Makefile.app to use the green VM icon that implies Cog
+	Makefile.flags
+		Defines the compilation flags and SDK to use in building the VM
+	Makefile.plugin
+		Makes either an internal FooPlugin.lib or an external FooPlugin.bundle.
+		If platforms/iOS/plugins/FooPlugin/Makefile exists Makefile.vm will
+		use it, and it should include Makefile.plugin to do the dirty work.
+	Makefile.rules
+		Defines the rules for compiling c, c++ and objective-c source files,
+		including maintaining dependency information.
+	Makefile.vm
+		Makes the VM executable in the chosen configuration from product,
+		assert or debug.  Decodes plugins.int and plugins.ext and invokes
+		make with the relevant makefile, either a special one such as
+		platforms/iOS/plugins/RePlugin/Makefile or Makefile.plugin, for each
+		internal or external plugin.
+	mkNamedPrims.sh
+		This script makes sqNamedPrims.h which defines the exports from the set
+		of internal plugins that the VM uses to access the primitives in
+		internal plugins.
 
+
+Building the VM Simulator Support Libraries
+-------------------------------------------
+As of this writing there are three processors with three sets of support
+libraries.  If you want to build these they are in
+	build.macos64x64/{bochsx86,bochsx64,gdbarm32}
+In each directory there is a conf.COG script.  Cd to the directory, run the
+script, and in the case of the bochs directories also run makeem.  e.g.
+	$ cd build.macos64x64/bochsx86
+	$ ./conf.COG
+	$ ../../processors/IA32/bochs/makeem
+Then cd to the VM build directoruy of your choice and build.
+
+
+Using Different Compilers
+-----------------------------------------
+The build system uses Xcode's default compiler, clang by default.
+You may want to use a different compiler.  Users claim this is possible.
+For example, to install gcc 5.2 see
+	http://hamelot.co.uk/programming/add-gcc-compiler-to-xcode-6/
+(Thanks Hammad!).  There are no guarantees that this will work, but that's the
+best pointer I've found.
+
+
 Eliot Miranda
-December 2015
+February 2016

Modified: branches/Cog/build.macos64x64/common/Makefile.app
===================================================================
--- branches/Cog/build.macos64x64/common/Makefile.app	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos64x64/common/Makefile.app	2016-02-18 19:54:22 UTC (rev 3613)
@@ -62,16 +62,30 @@
 endif
 
 
-$(APP):	$(VMEXE) $(VMBUNDLES) $(VMPLIST) $(VMMENUNIB) $(VMICONS) $(SOURCES) \
-		$(APPPOST) signapp touchapp
+$(APP):	cleanbundles $(VMEXE) $(VMBUNDLES) $(VMPLIST) $(VMMENUNIB) $(VMICONS) \
+ 		$(SOURCES) $(APPPOST) signapp touchapp
 
+# Bundles with missing prerequisites won't be built. But we need to force the
+# attempt to make them every time in case the prerequisites /have/ been built.
+# to do this we must both delete the bundles and touch any ignore files, upon
+# which the bundle build depends.
+cleanbundles:
+	-rm -rf $(APP)/Contents/Resources/*.bundle
+	-touch $(OBJDIR)/*.ignore
+
 $(VMEXE): $(OBJDIR)/$(VM)
 	mkdir -p $(APP)/Contents/MacOS
 	cp -p $(OBJDIR)/$(VM) $(APP)/Contents/MacOS
 
 $(APP)/Contents/Resources/%.bundle: $(BLDDIR)/vm/%.bundle
-	mkdir -p $(APP)/Contents/Resources
-	cp -pR $< $(APP)/Contents/Resources
+	@mkdir -p $(APP)/Contents/Resources
+	@if [ -f $(basename $<).ignore ]; then \
+		echo $(notdir $<) is being ignored; \
+		rm -rf $^; \
+	else \
+		echo cp -pR $< $(APP)/Contents/Resources; \
+		cp -pR $< $(APP)/Contents/Resources; \
+	fi
 
 $(VMPLIST): $(OSXDIR)/$(SYSTEM)-Info.plist getversion
 	mkdir -p $(APP)/Contents

Modified: branches/Cog/build.macos64x64/common/Makefile.plugin
===================================================================
--- branches/Cog/build.macos64x64/common/Makefile.plugin	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos64x64/common/Makefile.plugin	2016-02-18 19:54:22 UTC (rev 3613)
@@ -13,6 +13,7 @@
 # LIBSRC     overrides the set of files to compile (if EXCLUDESRC inconvenient)
 # LINK_WITH_CPP set to non-empty to link external plugin bundle with c++ runtime
 # SRCDIRS    supplies additional directories containing files to compile.
+# PREREQUISITES supplies names of files that must exist to make lib or bundle
 
 # VM config flags.
 ifeq ($(CONFIGURATION),product)
@@ -139,6 +140,9 @@
 $(VMDIR):
 	mkdir -p $(VMDIR)
 
+# If any prerequisites are declared all must exist to continue
+ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES)))
+
 $(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ)
 	-rm $(PLUGINLIB)
 	ar -rc $(PLUGINLIB) $(LIBOBJ)
@@ -169,3 +173,21 @@
 	mkdir -p $(PLUGINBUNDLE)/Contents
 	sed "s/\$$(VERSION)/`getversion VERSION_TAG`/" $< | \
 	sed "s/\$(LIBNAME)/$(LIBNAME)/" > $(PLUGINPLIST)
+
+else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES))
+# If any prerequisites are missing simply create a .ignore file
+
+#$(info $$(PREREQUISITES): $(abspath $(PREREQUISITES)))
+#$(info $$(realpath $$(PREREQUISITES)): $(realpath $(PREREQUISITES)))
+
+$(PLUGINLIB): FORCE
+	$(warning $(PLUGINLIB) has missing prerequisites. Not building.)
+	echo >$(basename $(PLUGINLIB)).ignore
+
+$(PLUGINBUNDLE):	FORCE
+	$(warning $(PLUGINBUNDLE) has missing prerequisites. Not building.)
+	echo >$(basename $(PLUGINBUNDLE)).ignore
+
+FORCE:
+
+endif

Modified: branches/Cog/build.macos64x64/common/Makefile.vm
===================================================================
--- branches/Cog/build.macos64x64/common/Makefile.vm	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/build.macos64x64/common/Makefile.vm	2016-02-18 19:54:22 UTC (rev 3613)
@@ -132,8 +132,8 @@
 	$(POSTCOMPILE)
 
 -include deps/version.d
-	
-product:;
+
+product:
 	$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product $(@,product=) default
 
 assert:
@@ -183,12 +183,12 @@
 	@echo VMOBJ=$(VMOBJ)
 	@echo -----------------------------------------------------
 
-#vm:	$(OBJDIR)/$(VM)
+ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore)))
 
 $(OBJDIR)/$(VM): $(OBJDIR) $(VMOBJ) $(LIBS)
 	$(CC) -arch $(TARGET_ARCH) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(OSXCOMMONDIR)/version.c
 	$(CC) -arch $(TARGET_ARCH) -isysroot $(SDK) $(LDFLAGS) $(FRAMEWORKS) \
-			-o $(OBJDIR)/$(VM) $(VMOBJ) $(LIBS)
+			-o $(OBJDIR)/$(VM) $(VMOBJ) $(filter-out $(call ignore), $(LIBS))
 
 $(OBJDIR):
 	@-mkdir -p $(BLDDIR)
@@ -205,15 +205,15 @@
 #
 .PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle
 
-#plugin-makefile = $(shell test -f $(OSXPLUGINSDIR)/$(1)/Makefile && echo $(OSXPLUGINSDIR)/$(1)/Makefile || echo ../common/Makefile.plugin)
-plugin-makefile = $(realpath $(OSXPLUGINSDIR)/$(1)/Makefile ../common/Makefile.plugin)
+plugin-makefile = $(firstword $(realpath $(OSXPLUGINSDIR)/$(1)/Makefile ../common/Makefile.plugin))
 
 # Internal plugin.  Build as lib then link in lib
 # Check for Makefile in iOS plugins directory otherwise use default Makefile
 # N.B.  PLATDIR *must* be a relative path for this to work
-$(OBJDIR)/%.lib: getversion $(call plugin-makefile,$(*F))
+$(OBJDIR)/%.lib: getversion $(call plugin-makefile,$(*F)) $(wildcard $(*F).ignore)
 	@-mkdir -p $(BLDDIR)/$(*F)
-	test $@ -ot $(call plugin-makefile,$(*F)) && rm $(OBJDIR)/$(*F).lib || true
+	test $@ -ot $(call plugin-makefile,$(*F)) && rm $(BUILD)/vm/$(*F).lib || true
+	rm -f $(BUILD)/vm/$(*F).ignore
 	$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
 		-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
 		CONFIGURATION=$(CONFIGURATION) ARCH=$(TARGET_ARCH) \
@@ -228,9 +228,10 @@
 
 # External plugin.  Build as bundle and copy to vm dir ($(OBJDIR)).
 # Check for Makefile in iOS plugins directory otherwise use default Makefile
-$(OBJDIR)/%.bundle:	getversion $(call plugin-makefile,$(*F))
+$(OBJDIR)/%.bundle:	getversion $(call plugin-makefile,$(*F)) $(wildcard $(*F).ignore)
 	@-mkdir -p $(BLDDIR)/$(*F)
-	test $@ -ot $(call plugin-makefile,$(*F)) && rm $(OBJDIR)/$(*F).lib || true
+	test $@ -ot $(call plugin-makefile,$(*F)) && rm -rf $(BUILD)/vm/$(*F).bundle || true
+	rm -f $(BUILD)/vm/$(*F).ignore
 	$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
 		-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
 		CONFIGURATION=$(CONFIGURATION) ARCH=$(TARGET_ARCH) \

Modified: branches/Cog/platforms/iOS/plugins/BochsIA32Plugin/Makefile
===================================================================
--- branches/Cog/platforms/iOS/plugins/BochsIA32Plugin/Makefile	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/platforms/iOS/plugins/BochsIA32Plugin/Makefile	2016-02-18 19:54:22 UTC (rev 3613)
@@ -1,9 +1,11 @@
+BOX:=../bochsx86
+PREREQUISITES:=$(BOX)/cpu/libcpu.a $(BOX)/disasm/libdisasm.a $(BOX)/fpu/libfpu.a
+
 LINK_WITH_CPP:=1
-INCDIRS:=../bochsx86 \
+INCDIRS:=$(BOX) \
          ../../processors/IA32/bochs \
 		 ../../processors/IA32/bochs/instrument/stubs
-EXTRALIBS:=	-L../bochsx86/cpu -L../bochsx86/fpu -L../bochsx86/disasm \
-			-lcpu -lfpu -ldisasm
+EXTRALIBS:=	-L$(BOX)/cpu -L$(BOX)/fpu -L$(BOX)/disasm -lcpu -lfpu -ldisasm
 CFLAGS:=-DUSE_BOCHS_CONFIG_H=1
 
 include ../common/Makefile.plugin

Modified: branches/Cog/platforms/iOS/plugins/BochsX64Plugin/Makefile
===================================================================
--- branches/Cog/platforms/iOS/plugins/BochsX64Plugin/Makefile	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/platforms/iOS/plugins/BochsX64Plugin/Makefile	2016-02-18 19:54:22 UTC (rev 3613)
@@ -1,9 +1,11 @@
+BOX:=../bochsx64
+PREREQUISITES:=$(BOX)/cpu/libcpu.a $(BOX)/disasm/libdisasm.a $(BOX)/fpu/libfpu.a
+
 LINK_WITH_CPP:=1
-INCDIRS:=../bochsx64 \
+INCDIRS:=$(BOX) \
          ../../processors/IA32/bochs \
-         ../../processors/IA32/bochs/instrument/stubs
-EXTRALIBS:=	-L../bochsx64/cpu -L../bochsx64/fpu -L../bochsx64/disasm \
-			-lcpu -lfpu -ldisasm
+		 ../../processors/IA32/bochs/instrument/stubs
+EXTRALIBS:=	-L$(BOX)/cpu -L$(BOX)/fpu -L$(BOX)/disasm -lcpu -lfpu -ldisasm
 CFLAGS:=-DUSE_BOCHS_CONFIG_H=1
 
 include ../common/Makefile.plugin

Modified: branches/Cog/platforms/iOS/plugins/GdbARMPlugin/Makefile
===================================================================
--- branches/Cog/platforms/iOS/plugins/GdbARMPlugin/Makefile	2016-02-16 05:35:08 UTC (rev 3612)
+++ branches/Cog/platforms/iOS/plugins/GdbARMPlugin/Makefile	2016-02-18 19:54:22 UTC (rev 3613)
@@ -1,3 +1,9 @@
+PREREQUISITES:= ../gdbarm32/bfd/libbfd.a \
+				../gdbarm32/libiberty/libiberty.a \
+				../gdbarm32/opcodes/libopcodes.a \
+				../gdbarm32/sim/arm/libsim.a \
+				../gdbarm32/zlib/libz.a
+
 INCDIRS:=../../processors/ARM/gdb-7.10/include \
          ../../processors/ARM/gdb-7.10/sim/arm \
          ../../processors/ARM/gdb-7.10/bfd \

Added: branches/Cog/platforms/iOS/plugins/RePlugin/Makefile
===================================================================
--- branches/Cog/platforms/iOS/plugins/RePlugin/Makefile	                        (rev 0)
+++ branches/Cog/platforms/iOS/plugins/RePlugin/Makefile	2016-02-18 19:54:22 UTC (rev 3613)
@@ -0,0 +1,3 @@
+EXCLUDESRC:=%/chartables.c
+
+include ../common/Makefile.plugin



More information about the Vm-dev mailing list