|
| 1 | +How To Build On Linux |
| 2 | +--------------------- |
| 3 | + |
| 4 | +Contents: |
| 5 | + - Checking out sources |
| 6 | + - How to build the Cog Croquet VM on Unix |
| 7 | + - Testing an external plugin has completely linked |
| 8 | + - Compiling in 32-bit mode on a 64-bit linux |
| 9 | + - Testing an external plugin has completely linked |
| 10 | + - N.B. Please read: Optimization level and gcc version |
| 11 | + |
| 12 | + |
| 13 | +Checking out sources |
| 14 | +------------------------------- |
| 15 | +To generate a VM check-out http://www.squeakvm.org/svn/squeak/branches/Cog/image |
| 16 | +which contains |
| 17 | +http://www.squeakvm.org/svn/squeak/branches/Cog/image/VMMaker-Squeak4.1.changes |
| 18 | +http://www.squeakvm.org/svn/squeak/branches/Cog/image/VMMaker-Squeak4.1.image |
| 19 | +Start up VMMaker-Squeak4.1.image. In it is a workspace containing a doit that |
| 20 | +uses something like generate:and:to:platformDir:excluding:. Doit. |
| 21 | + |
| 22 | + |
| 23 | +How to build the Cog Croquet VM on Unix |
| 24 | +------------------------------- |
| 25 | +1. Install the tools (gcc, X11-devel, etc (e.g. libpng, libX11 & libxt source)) |
| 26 | +2. Check out the following sources from svn (if you haven't already - if you're |
| 27 | + reading this in unixbuild its likely you've already got the sources) |
| 28 | + svn co http://www.squeakvm.org/svn/squeak/branches/Cog/platforms |
| 29 | + svn co http://www.squeakvm.org/svn/squeak/branches/Cog/src |
| 30 | + svn co http://www.squeakvm.org/svn/squeak/branches/Cog/unixbuild |
| 31 | +3. Open a shell, cd into the unixbuild/bld directory and execute |
| 32 | + ../../platforms/unix/config/configure --without-npsqueak CFLAGS="-g -O2 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0" LIBS=-lpthread |
| 33 | + make install prefix=WhereYouWantTheVmToGo |
| 34 | + |
| 35 | + N.B. If you're on a 64-bit linux read 3e below!! |
| 36 | + N.B. On Ubuntu *do not* supply "LIBS=-lpthread", i.e. use |
| 37 | + ../../platforms/unix/config/configure --without-npsqueak CFLAGS="-g -O2 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0" |
| 38 | + |
| 39 | +4. At the end of it you'll get a new VM in the path provided via -prefix |
| 40 | + |
| 41 | +N.B. The plugin set is defined by plugins.ext and plugins.int in the build dir. |
| 42 | + |
| 43 | + |
| 44 | +3a. For an assert-enabled VM do |
| 45 | + ../../platforms/unix/config/configure --without-npsqueak CFLAGS="-g -O1 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0" LIBS=-lpthread |
| 46 | + |
| 47 | +3b. For a full debug VM do |
| 48 | + ../../platforms/unix/config/configure --without-npsqueak CFLAGS="-g3 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=1" LIBS=-lpthread |
| 49 | + |
| 50 | +3c. For a multi-threaded VM open a shell and cd to the mtbld directory. Then |
| 51 | + execute |
| 52 | + ../../platforms/unix/config/configure INTERP=cointerpmt --without-npsqueak CFLAGS="-g -O2 -msse2 -DNDEBUG -DCOGMTVM=1 -DDEBUGVM=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1" LIBS=-lpthread |
| 53 | + make squeakmt |
| 54 | + make installmt prefix=WhereYouWantTheVmToGo |
| 55 | + |
| 56 | +N.B. As of early 2010 the linux pthreads implementation doesn't appear to |
| 57 | +provide a way of setting priorities for the default thread scheduling policy |
| 58 | +SCHED_OTHER (unlike e.g. Mac OS X) and doesn't appear to allow changing the |
| 59 | +policy to one that does (e.g. SCHED_RR). So for now we use the itimer |
| 60 | +scheme. See platforms/unix/vm/sqUnixHeartbeat.c |
| 61 | + |
| 62 | +3d. If you want to get the Cog VM simulator working you'll need to build the |
| 63 | +BochsIA32Plugin/BochsIA32Plugin.xcodeproj project and to build that you'll |
| 64 | +need to first build bochs. First check-out the processor simulator source tree |
| 65 | +containing Bochs: |
| 66 | + svn co http://www.squeakvm.org/svn/squeak/branches/Cog/processors |
| 67 | +Then build libraries linuxbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} |
| 68 | + $ cd ROOT/processors/IA32/linuxbochs |
| 69 | + $ ./conf.COG |
| 70 | + $ ../bochs/makeem |
| 71 | +and build the plugin via |
| 72 | + $ cd ROOT/unixbuild/bld/BochsIA32Plugin |
| 73 | + $ make |
| 74 | + |
| 75 | +3e. (see Compiling in 32-bit mode on a 64-bit linux below) |
| 76 | +If you're building the VM on a 64-bit OS, you'll need a compiler which can |
| 77 | +compile and link to 32-bit binaries. On most Linuxes the gcc-multilib package |
| 78 | +provides the 32-bit compiler and the ia32-libs provides the 32-bit libraries. |
| 79 | +You'll also have to add the -m32 switch to all gcc & g++ invocations. The |
| 80 | +easiest way to do this is to add CC="gcc -m32" & CXX="g++ -m32" to the configure |
| 81 | +script: |
| 82 | + ../../platforms/unix/config/configure CC="gcc -m32" CXX="g++ -m32" --without-npsqueak CFLAGS="-g -O2 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0" LIBS=-lpthread |
| 83 | +To run a 32-bit VM on a 64-bit OS, you'll also need the 32-bit libraries |
| 84 | +provided by the ia32-libs package. |
| 85 | + |
| 86 | +Compiling in 32-bit mode on a 64-bit linux |
| 87 | +------------------------------- |
| 88 | +Follow 3e. above. Also note that according to Paul DeBruicker the following |
| 89 | +packages need to be installed to compile in 32-bt mode on 64-bit ubuntu. YMMV. |
| 90 | + |
| 91 | +build-essential |
| 92 | +lib32asound2-dev |
| 93 | +libgl1-mesa-dev |
| 94 | +libglu1-mesa-dev |
| 95 | +ia32-libs |
| 96 | +gcc-multilib |
| 97 | +g++multilib |
| 98 | + |
| 99 | +In addition [email protected] installed libc6dev-i386. |
| 100 | + |
| 101 | +This in itself may not be enough, but persistence will pay off. See for example |
| 102 | +http://permalink.gmane.org/gmane.comp.lang.smalltalk.pharo.devel/75198. |
| 103 | + |
| 104 | + |
| 105 | +Testing an external plugin has completely linked |
| 106 | +------------------------------- |
| 107 | +You may find that an external plugin compiles and links but does not load. |
| 108 | +This is usually because it contans undefined symbols. To find undefined |
| 109 | +symbols, remake the plugin, capturing the link step and then supply |
| 110 | + -Wl,--warn-unresolved-symbols -Wl,--no-allow-shlib-undefined |
| 111 | +when manually repeating the link command |
| 112 | + |
| 113 | + |
| 114 | +Optimization level and gcc version |
| 115 | +---------------------------------- |
| 116 | +There are issues with gcc version > 4.2.1. Any of the following flags may break the build at -O2: |
| 117 | +-ftree-pre |
| 118 | +-fpartial-inlining |
| 119 | +-fcaller-saves |
| 120 | + |
| 121 | +So turn them off. e.g. |
| 122 | + ../../platforms/unix/config/configure --without-npsqueak CFLAGS="-g -O2 -msse2 -fno-caller-saves -fno-partial-inlining -fno-tree-pre -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0" LIBS=-lpthread |
| 123 | + |
| 124 | +Clang |
| 125 | +----- |
| 126 | +So far Clang only works at -O1. So it may also be subject to some of the same |
| 127 | +issues as gcc. Please report back successes with clang, especially at -O2. |
0 commit comments