Index: configure =================================================================== --- configure (.../vendor/ocaml/4.01.0) (revision 116) +++ configure (.../trunk/ocamlxsim/4.0) (revision 116) @@ -278,7 +278,13 @@ bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" mathlib="";; *,*-*-darwin*) - bytecccompopts="-fno-defer-pop $gcc_warnings" + # On recent versions of OSX, gcc is a symlink to clang + if $bytecc --version | grep -q clang; then + # -fno-defer-pop is not supported by clang. + bytecccompopts="$gcc_warnings" + else + bytecccompopts="-fno-defer-pop $gcc_warnings" + fi mathlib="" mkexe="$mkexe -Wl,-no_compact_unwind" # Tell gcc that we can use 32-bit code addresses for threaded code Index: VERSION =================================================================== --- VERSION (.../vendor/ocaml/4.01.0) (revision 116) +++ VERSION (.../trunk/ocamlxsim/4.0) (revision 116) @@ -1,4 +1,4 @@ -4.01.0 +4.01.0+xsim-4.0.1 # The version string is the first line of this file. # It must be in the format described in stdlib/sys.mli Index: asmcomp/i386/emit.mlp =================================================================== --- asmcomp/i386/emit.mlp (.../vendor/ocaml/4.01.0) (revision 116) +++ asmcomp/i386/emit.mlp (.../trunk/ocamlxsim/4.0) (revision 116) @@ -83,7 +83,14 @@ let emit_data_label lbl = emit_string label_prefix; emit_string "d"; emit_int lbl +(* Emit truncated native int, necessary when cross compiling from 64 to + * 32 bit environments. For the usual self-hosted 32-bit environment + * this acts exactly like emit_nativeint. + *) +let emit_t_nativeint n = + emit_int32 (Nativeint.to_int32 n) + (* Some data directives have different names under Solaris *) let word_dir = @@ -464,7 +471,7 @@ Reg n -> ` xorl {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` | _ -> ` movl $0, {emit_reg i.res.(0)}\n` end else - ` movl ${emit_nativeint n}, {emit_reg i.res.(0)}\n` + ` movl ${emit_t_nativeint n}, {emit_reg i.res.(0)}\n` | Lop(Iconst_float s) -> begin match Int64.bits_of_float (float_of_string s) with | 0x0000_0000_0000_0000L -> (* +0.0 *) @@ -697,7 +704,7 @@ | Lop(Ispecific(Ilea addr)) -> ` lea {emit_addressing addr i.arg 0}, {emit_reg i.res.(0)}\n` | Lop(Ispecific(Istore_int(n, addr))) -> - ` movl ${emit_nativeint n}, {emit_addressing addr i.arg 0}\n` + ` movl ${emit_t_nativeint n}, {emit_addressing addr i.arg 0}\n` | Lop(Ispecific(Istore_symbol(s, addr))) -> ` movl ${emit_symbol s}, {emit_addressing addr i.arg 0}\n` | Lop(Ispecific(Ioffset_loc(n, addr))) -> @@ -724,7 +731,7 @@ stack_offset := !stack_offset + 4 done | Lop(Ispecific(Ipush_int n)) -> - ` pushl ${emit_nativeint n}\n`; + ` pushl ${emit_t_nativeint n}\n`; cfi_adjust_cfa_offset 4; stack_offset := !stack_offset + 4 | Lop(Ispecific(Ipush_symbol s)) -> @@ -964,9 +971,9 @@ | Cint16 n -> ` {emit_string word_dir} {emit_int n}\n` | Cint32 n -> - ` .long {emit_nativeint n}\n` + ` .long {emit_t_nativeint n}\n` | Cint n -> - ` .long {emit_nativeint n}\n` + ` .long {emit_t_nativeint n}\n` | Csingle f -> emit_float32_directive ".long" f | Cdouble f -> Index: tools/make-package-macosx =================================================================== --- tools/make-package-macosx (.../vendor/ocaml/4.01.0) (revision 116) +++ tools/make-package-macosx (.../trunk/ocamlxsim/4.0) (revision 116) @@ -28,9 +28,9 @@ IFPkgDescriptionDeleteWarning IFPkgDescriptionDescription - The OCaml compiler and tools + The OCaml compiler and tools for iOS Simulator IFPkgDescriptionTitle - OCaml + OCaml for iOSS Simulator IFPkgDescriptionVersion ${VERSION} @@ -44,11 +44,11 @@ CFBundleGetInfoString - OCaml ${VERSION} + OCaml ${VERSION} for iOS Simulator CFBundleIdentifier - fr.inria.ocaml + com.psellos.ocamlxsim CFBundleName - OCaml + OCaml for iOS Simulator CFBundleShortVersionString ${VERSION} IFMajorVersion @@ -60,7 +60,7 @@ IFPkgFlagAuthorizationAction AdminAuthorization IFPkgFlagDefaultLocation - /usr/local + /usr/local/ocamlxsim IFPkgFlagInstallFat IFPkgFlagIsRequired @@ -83,15 +83,16 @@ # stop here -> | cat >resources/ReadMe.txt < asmrun/Makefile + make world && make opt + mv -f asmrun/Makefile.aside asmrun/Makefile + trap - EXIT + # Save the Phase 1 shared (dynamically loadable) libraries and + # restore them after Phase 2. They're required by some OCaml + # utilities, such as camlp4. + # + # The shared libraries are useful only with the bytecode + # interpreter, which we don't support under iOS. This lets us (just + # barely) fit OCamlXSim into the form of a usual OCaml release. + find . -name '*.so' -exec mv {} {}phase1 \; +} + +config2 () { + # Clean out OS X runtime + echo 'xsim-build: ----- configure phase 2 -----' + cd asmrun; make clean; cd .. + cd stdlib; make clean; cd .. + cd otherlibs/bigarray; make clean; cd ../.. + cd otherlibs/dynlink; make clean; cd ../.. + cd otherlibs/num; make clean; cd ../.. + cd otherlibs/str; make clean; cd ../.. + cd otherlibs/systhreads; make clean; cd ../.. + cd otherlibs/threads; make clean; cd ../.. + cd otherlibs/unix; make clean; cd ../.. + # Reconfigure for iOSSim environment + ./configure \ + -bindir $XSIMTARGET/bin \ + -libdir $XSIMTARGET/lib/ocaml \ + -mandir $XSIMTARGET/man/man1 \ + -no-curses \ + -no-tk \ + -no-graph \ + -host i386-apple-darwin10.0.0d3 \ + -cc "$TOOLDIR/clang -arch i386 -gdwarf-2 -miphoneos-version-min=6.0 -isysroot $PLT$SDK" \ + -as "$TOOLDIR/clang -arch i386 -miphoneos-version-min=6.0 -c" \ + -aspp "$TOOLDIR/clang -arch i386 -miphoneos-version-min=6.0 -c" + # Rebuild ocamlmklib, so libraries work with iOSSim. + rm myocamlbuild_config.ml + cd tools + make ocamlmklib + cd .. +} + +build2 () { + # Make iOSSim runtime + echo 'xsim-build: ----- build phase 2 -----' + cd asmrun; make all; cd .. + cd stdlib; make all allopt; cd .. + cd otherlibs/unix; make all allopt; cd ../.. + cd otherlibs/str; make all allopt; cd ../.. + cd otherlibs/num; make all allopt; cd ../.. + cd otherlibs/dynlink; make all allopt; cd ../.. + cd otherlibs/bigarray; make all allopt; cd ../.. + cd otherlibs/systhreads; make all allopt; cd ../.. + cd otherlibs/threads; make all allopt; cd ../.. + # Restore the saved Phase 1 .so files (see above). + find . -name '*.sophase1' -print | \ + while read f; do \ + fso="$(expr "$f" : '\(.*\)sophase1$')so"; mv -f $f $fso; \ + done +} + +# Bigger steps + +phase1 () { + config1 && build1 +} + +phase2 () { + config2 && build2 +} + +all () { + phase1 && phase2 +} + +clean () { + rm -f myocamlbuild_config.ml + make clean +} + +case "$1" in +config1) config1 ;; +build1) build1 ;; +config2) config2 ;; +build2) build2 ;; +phase1) phase1 ;; +phase2) phase2 ;; +all) all ;; +clean) clean ;; +*) echo "usage: $(basename $0) {all|phase1|phase2|config1|build1|config2|build2}" >&2; + echo " $(basename $0) clean" >&2; + exit 1 + ;; +esac Index: Makefile =================================================================== --- Makefile (.../vendor/ocaml/4.01.0) (revision 116) +++ Makefile (.../trunk/ocamlxsim/4.0) (revision 116) @@ -776,7 +776,10 @@ package-macosx: sudo rm -rf package-macosx/root - $(MAKE) PREFIX="`pwd`"/package-macosx/root install + $(MAKE) BINDIR="`pwd`"/package-macosx/root/bin \ + LIBDIR="`pwd`"/package-macosx/root/lib/ocaml \ + MANDIR="`pwd`"/package-macosx/root/man \ + install tools/make-package-macosx sudo rm -rf package-macosx/root Index: asmrun/signals_osdep.h =================================================================== --- asmrun/signals_osdep.h (.../vendor/ocaml/4.01.0) (revision 116) +++ asmrun/signals_osdep.h (.../trunk/ocamlxsim/4.0) (revision 116) @@ -32,7 +32,7 @@ /****************** AMD64, MacOSX */ -#elif defined(TARGET_amd64) && defined (SYS_macosx) +#elif (defined(TARGET_amd64) || (defined(TARGET_i386) && defined(__x86_64))) && defined (SYS_macosx) #define DECLARE_SIGNAL_HANDLER(name) \ static void name(int sig, siginfo_t * info, void * context) @@ -151,7 +151,9 @@ #include #include - #if !defined(MAC_OS_X_VERSION_10_5) \ + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + #define CONTEXT_REG(r) __##r + #elif !defined(MAC_OS_X_VERSION_10_5) \ || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 #define CONTEXT_REG(r) r #else