Skip to content

Commit

Permalink
Started reentrant runtime changes --patch by Fabrice Le Fessant, port…
Browse files Browse the repository at this point in the history
…ed, updated (and likely broken in part) by Luca Saiu
  • Loading branch information
lucasaiu committed Dec 10, 2012
1 parent 3be87f1 commit 7d4891a
Show file tree
Hide file tree
Showing 1,440 changed files with 12,727 additions and 8,775 deletions.
169 changes: 169 additions & 0 deletions BOOTSTRAP
@@ -0,0 +1,169 @@
#!/bin/bash

#MAKEFLAGS='-j 4'

# This assumes we have already configured the sources in $UNPATCHED and $PATCHED .

# cd ...
# make clean
# cp "$UNPATCHED/ocamlc" "$PATCHED/ocamlc"
# cp "$UNPATCHED/boot/"* boot/
# make -C byterun
# make -C "$PATCHED/stdlib" CAMLC="$UNPATCHED/ocamlc" COMPILER="$UNPATCHED/ocamlc"
# for t in compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo; do
# make CAMLC="$UNPATCHED/ocamlc" $t
# done
# # This fails
# ocamlc -o ocamlc stdlib/stdlib.cma compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo -use-runtime byterun/ocamlrun
set -ex

# # This assumes ../unpatched-trunk contains an unpatched, configured
# # and compiled version of the OCaml source.
# PATCHED="$(pwd)"
PATCHED="/home/luca/reentrant-runtime/working/trunk/"
UNPATCHED="$PATCHED/../unpatched-trunk/"
OLD="/tmp/old/"
COMPILERWITHOLDRUNTIME="/tmp/compiler-with-old-runtime/"
COMPILERWITHNEWRUNTIME="/tmp/compiler-with-new-runtime/"
export OLDOCAMLC="$OLD/byterun/ocamlrun $OLD/ocamlc"
export COMPILERWITHOLDRUNTIMEOCAMLC="$OLD/byterun/ocamlrun $COMPILERWITHOLDRUNTIME/ocamlc-stage1 -nostdlib -I $COMPILERWITHOLDRUNTIME/stdlib -use-runtime $COMPILERWITHOLDRUNTIME/byterun/ocamlrun"
export COMPILERWITHNEWRUNTIMEOCAMLC="$COMPILERWITHNEWRUNTIME/byterun/ocamlrun $COMPILERWITHNEWRUNTIME/ocamlc -nostdlib -I $COMPILERWITHNEWRUNTIME/stdlib -use-runtime $COMPILERWITHNEWRUNTIME/byterun/ocamlrun"

echo "Preparing temporary directories..."
rm -rf "$OLD" "$COMPILERWITHOLDRUNTIME" "$COMPILERWITHNEWRUNTIME"
cp -af "$UNPATCHED" "$OLD"
cp -af "$PATCHED" "$COMPILERWITHOLDRUNTIME"
cp -af "$PATCHED" "$COMPILERWITHNEWRUNTIME"

# FIXME: this is correct: I've just disabled it to save time
# echo "Compiling the old runtime..."
# cd "$OLD"
# make clean
# make -C byterun
# make ocamlc
# make -C stdlib # FIXME: is this needed?
# if (! [ -e "$OLD/byterun/ocamlrun" ]) || (! [ -e "$OLD/ocamlc" ]); then exit -1; fi
# echo "Now $OLDOCAMLC exists"

echo "Compiling the patched compiler running on the old runtime..."
cd "$COMPILERWITHOLDRUNTIME"
make clean
cp "$OLD/boot/ocamllex" boot/

# We can start with the part written in C:
make -C yacc
cp yacc/ocamlyacc boot/
make -C byterun
cp byterun/ocamlrun boot/

#cp "$OLD/ocamlc" ocamlc
#cp "$OLD/boot/"* boot/
#make -C byterun
#make -C "$COMPILERWITHOLDRUNTIME/stdlib" CAMLC="$OLDOCAMLC" COMPILER="$OLDOCAMLC"

# # Copy some sources from the unpatched version, so that we don't rely
# # on the new C primitives we lack in our old runtime:
cp "$OLD/utils/terminfo.ml"{,i} utils/
cp "$OLD/bytecomp/dll.ml"{,i} bytecomp/
cp "$OLD/bytecomp/meta.ml"{,i} bytecomp/
# #cp "$OLD/bytecomp/runtimedef.ml"{,i} bytecomp/

for t in compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo; do
make CAMLC="$OLDOCAMLC -I $OLD/boot" CAMLLEX="$OLD/boot/ocamlrun $COMPILERWITHOLDRUNTIME/boot/ocamllex" "$t"
done

$OLDOCAMLC -I "$OLD/boot" -o ocamlc-stage1 -use-runtime "$OLD/byterun/ocamlrun" compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo

make -C stdlib/ RUNTIME="$OLD/byterun/ocamlrun" COMPILER="$COMPILERWITHOLDRUNTIME/ocamlc-stage1"

# The generated runtime (in byterun/) should be the same in stages 1
# and 2. The difference is the runtime *on top of which* the compiler
# runs.

echo "Compiling test programs with ocamlc-stage1, to be run with the new runtime..."
$COMPILERWITHOLDRUNTIMEOCAMLC -o a ~/reentrant-runtime/tests/a.ml
$COMPILERWITHOLDRUNTIMEOCAMLC -o b ~/reentrant-runtime/tests/b.ml
$COMPILERWITHOLDRUNTIMEOCAMLC -o i ~/reentrant-runtime/tests/i.ml
$COMPILERWITHOLDRUNTIMEOCAMLC -o l ~/reentrant-runtime/tests/length.ml

#make -C lex CAMLC="$COMPILERWITHOLDRUNTIMEOCAMLC"
#make -C tools CAMLRUN="$COMPILERWITHOLDRUNTIMEOCAMLC/byterun/ocamlrun" CAMLC="$COMPILERWITHOLDRUNTIMEOCAMLC"

echo Generated the compiler running on the old runtime

# FIXME: I suppose that before doing this I have to clean compilerlibs, util/ and and driver/
#$OLDOCAMLC -nostdlib -o ocamlc compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo -I stdlib/ -use-runtime byterun/ocamlrun
#Fails with
#Error: Error while linking stdlib/stdlib.cma(Array):
#The external function `caml_array_concat' is not available

cd "$COMPILERWITHNEWRUNTIME"
cp "$COMPILERWITHOLDRUNTIME/ocamlc-stage1" boot/ocamlc
cp "$COMPILERWITHOLDRUNTIME/byterun/ocamlrun" boot/ocamlrun
#echo '#!'"$OLD/boot/ocamlrun" > boot/ocamllex; tail --lines=+2 < "$OLD/boot/ocamllex" >> boot/ocamllex
cp "$OLD/boot/ocamlyacc" boot/ocamlyacc
#echo '#!'"$OLD/boot/ocamlrun" > boot/ocamldep; tail --lines=+2 < "$OLD/boot/ocamldep" >> boot/ocamldep
#echo '#!'"$OLD/boot/ocamlrun" > boot/ocamlbuild; tail --lines=+2 < "$OLD/boot/ocamlbuild" >> boot/ocamlbuild

make -C byterun clean
make -C byterun
make -C lex CAMLC="$COMPILERWITHOLDRUNTIMEOCAMLC" CAMLLEX="$OLD/boot/ocamlrun $COMPILERWITHOLDRUNTIME/boot/ocamllex"
cp lex/ocamllex boot/
make -C stdlib/ RUNTIME="$OLD/byterun/ocamlrun" COMPILER="$COMPILERWITHOLDRUNTIME/ocamlc-stage1"
for t in compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo; do
make CAMLC="$COMPILERWITHOLDRUNTIMEOCAMLC" "$t"
done
$OLDOCAMLC -nostdlib -I stdlib -o ocamlc-stage2 -use-runtime "$COMPILERWITHNEWRUNTIME/byterun/ocamlrun" compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo
cp ocamlc-stage2 boot/ocamlc
cp ocamlc-stage2 ocamlc
cp byterun/ocamlrun boot/ocamlrun # This shouldn't be needed, but let's play it safe

make coldstart

make ocamltools
make -C tools
#cp tools/ocamldep boot/ocamldep

echo "Compiling test programs with ocamlc-stage2, to be run with the new runtime..."
$COMPILERWITHNEWRUNTIMEOCAMLC -o a ~/reentrant-runtime/tests/a.ml
$COMPILERWITHNEWRUNTIMEOCAMLC -o b ~/reentrant-runtime/tests/b.ml
$COMPILERWITHNEWRUNTIMEOCAMLC -o i ~/reentrant-runtime/tests/i.ml
$COMPILERWITHNEWRUNTIMEOCAMLC -o l ~/reentrant-runtime/tests/length.ml

#make -C lex CAMLLEX="$COMPILERWITHNEWRUNTIME/boot/ocamllex"
cp tools/ocamldep boot/
#cp myocamlbuild_config.ml ocamlbuild/ocamlbuild_Myocamlbuild_config.ml
#make -C ocamlbuild/

# What we did up to this point has built a non-working
# boot/myocamlbuild.boot; let's replace it with something that can
# actually be run:
echo '#!'"$OLD/boot/ocamlrun" > boot/myocamlbuild.boot; chmod a+x boot/myocamlbuild.boot; tail --lines=+2 < "$OLD/boot/myocamlbuild.boot" >> boot/myocamlbuild.boot

# # ocamlbuild complains about this if I keep it:
# rm -rf compilerlibs-from-unpatched-version

cp $OLD/boot/ocamlrun boot/ocamlrun.boot

# I can't run make world at this point, because ocamlcomp.sh is not
# there yet. What's the clean way of producing it? "make bootstrap"
# works.
make bootstrap
make install

# Now we have bootstrapped. From now on, if the installation prefix
# is accessible, we can directly compile from the current directory.
# Just copy the executables from the previous stage into boot:
rm boot/* &> /dev/null || true
cp $COMPILERWITHNEWRUNTIME/ocamlc boot/
cp $COMPILERWITHNEWRUNTIME/byterun/ocamlrun boot/
cp $COMPILERWITHNEWRUNTIME/byterun/ocamlrun boot/ocamlrun.boot # Added by me, to be used in build/boot.sh
cp $COMPILERWITHNEWRUNTIME/tools/ocamldep boot/
cp $COMPILERWITHNEWRUNTIME/lex/ocamllex boot/
cp $COMPILERWITHNEWRUNTIME/yacc/ocamlyacc boot/
cp $COMPILERWITHNEWRUNTIME/_build/myocamlbuild boot/myocamlbuild
cp $COMPILERWITHNEWRUNTIME/_build/myocamlbuild boot/myocamlbuild.boot # Not a mistake

make world

echo SUCCESS
39 changes: 3 additions & 36 deletions Changes
Expand Up @@ -4,14 +4,10 @@ Next version
Compilers:
- PR#5634: parsetree rewriter (-ppx flag)
- ocamldep now supports -absname
- PR#5768: On "unbound identifier" errors, use spell-checking to suggest names present in the environment
- ocamlc has a new option -dsource which visualize the parsetree
- tools/eqparsetree compare two parsetree ignoring location

Bug fixes:
- PR#4762: ?? is not used at all, but registered as a lexer token
- PR#4994: ocaml-mode doesn't work with xemacs21
* PR#5119: camlp4 now raises a specific exception when 'DELETE_RULE' fails,
rather than raising 'Not_found'
- PR#5327: (Windows) Unix.select blocks if same socket listed in first and
third arguments
- PR#5468: ocamlbuild should preserve order of parametric tags
Expand All @@ -30,61 +26,32 @@ Bug fixes:
- PR#5747: 'unused open' warning not given when compiling with -annot
- PR#5758: Compiler bug when matching on floats
- PR#5763: ocamlbuild does not give correct flags when running menhir
- PR#5784: -dclambda option is ignored
- PR#5787: Bad behavior of 'Unused ...' warnings in the toplevel
- PR#5770: Syntax error messages involving unclosed parens are sometimes incorrect
- PR#5805: Assert failure with warning 34 on pre-processed file

Internals:
- Moved debugger/envaux.ml to typing/envaux.ml to publish env_of_only_summary
as part of compilerlibs, to be used on bin-annot files.

Feature wishes:
- PR#5597: add instruction trace option 't' to OCAMLRUNPARAM
- PR#5762: Add primitives for fast access to bigarray dimensions


OCaml 4.00.2:
-------------

Bug fixes:
- PR#5102: ocamlbuild fails when using an unbound variable in rule dependency
- PR#5240: register exception printers for Unix.Unix_error and Dynlink.Error
- PR#5300: verbose parameter should implicitly set classic display
- PR#5772: problem with marshaling of mutually-recursive functions
- PR#5775: several bug fixes for tools/pprintast.ml
- PR#5785: misbehaviour with abstracted structural type used as GADT index
- PR#5806: ensure that backtrace tests are always run (testsuite)
- PR#5810: error in switch printing when using -dclambda


OCaml 4.00.1:
-------------

Bug fixes:
- PR#4019: better documentation of Str.matched_string
- PR#5111: ocamldoc, heading tags inside spans tags is illegal in html
- PR#5278: better error message when typing "make"
- PR#5468: ocamlbuild should preserve order of parametric tags
- PR#5563: harden Unix.select against file descriptors above FD_SETSIZE
- PR#5690: "ocamldoc ... -text README" raises exception
- PR#5700: crash with native-code stack backtraces under MacOS 10.8 x86-64
- PR#5707: AMD64 code generator: do not use r10 and r11 for parameter passing,
as these registers can be destroyed by the dynamic loader
- PR#5712: some documentation problems
- PR#5715: configuring with -no-shared-libs breaks under cygwin
- PR#5718: false positive on 'unused constructor' warning
- PR#5719: ocamlyacc generates code that is not warning 33-compliant
- PR#5725: ocamldoc output of preformatted code
- PR#5727: emacs caml-mode indents shebang line in toplevel scripts
- PR#5729: tools/untypeast.ml creates unary Pexp_tuple
- PR#5731: instruction scheduling forgot to account for destroyed registers
- PR#5735: %apply and %revapply not first class citizens
- PR#5738: first class module patterns not handled by ocamldep
- PR#5742: missing bound checks in Array.sub
- PR#5744: ocamldoc error on "val virtual"
- PR#5757: GC compaction bug (crash)
- PR#5758: Compiler bug when matching on floats
- PR#5761: Incorrect bigarray custom block size


Expand All @@ -96,7 +63,7 @@ OCaml 4.00.0:
- The official name of the language is now OCaml.

Language features:
- Added Generalized Algebraic Data Types (GADTs) to the language.
- Added Generalized Abstract Data Types (GADTs) to the language.
See chapter "Language extensions" of the reference manual for documentation.
- It is now possible to omit type annotations when packing and unpacking
first-class modules. The type-checker attempts to infer it from the context.
Expand Down Expand Up @@ -1740,7 +1707,7 @@ Standard library:
- Module Printf:
added %S and %C formats (quoted, escaped strings and characters);
added kprintf (calls user-specified continuation on formatted string).
- Module Queue: faster implementation (courtesy of Francois Pottier).
- Module Queue: faster implementation (courtesy of Fran�ois Pottier).
- Module Random: added Random.bool.
- Module Stack: added Stack.is_empty.
- Module Pervasives:
Expand Down
25 changes: 19 additions & 6 deletions Makefile
Expand Up @@ -10,20 +10,29 @@
# #
#########################################################################

# $Id$

# The main Makefile

include config/Makefile
include stdlib/StdlibModules

CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot
#CAMLC=ocamlc -nostdlib -I boot
CAMLC=./boot/ocamlrun ./boot/ocamlc -nostdlib -I boot # REENTRANTRUNTIME
CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
#CAMLC=./boot-from-unpatched-version/ocamlrun ./boot/ocamlc -nostdlib -I boot # REENTRANTRUNTIME
#CAMLOPT=boot-from-unpatched-version/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
COMPFLAGS=-strict-sequence -w +33..39 -warn-error A $(INCLUDES)
LINKFLAGS=

CAMLYACC=boot/ocamlyacc
#CAMLYACC=boot-from-unpatched-version/ocamlyacc
YACCFLAGS=-v
CAMLLEX=boot/ocamlrun boot/ocamllex
#CAMLLEX=boot/ocamlrun boot/ocamllex
CAMLLEX=./boot/ocamlrun boot/ocamllex # REENTRANTRUNTIME
#CAMLLEX=./boot-from-unpatched-version/ocamlrun boot/ocamllex # REENTRANTRUNTIME
CAMLDEP=boot/ocamlrun tools/ocamldep
#CAMLDEP=boot-from-unpatched-version/ocamlrun tools/ocamldep
DEPFLAGS=$(INCLUDES)
CAMLRUN=byterun/ocamlrun
SHELL=/bin/sh
Expand All @@ -41,8 +50,7 @@ UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \

PARSING=parsing/location.cmo parsing/longident.cmo \
parsing/syntaxerr.cmo parsing/parser.cmo \
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo \
parsing/pprintast.cmo
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo

TYPING=typing/ident.cmo typing/path.cmo \
typing/primitive.cmo typing/types.cmo \
Expand Down Expand Up @@ -369,9 +377,14 @@ partialclean::
rm -f compilerlibs/ocamltoplevel.cma

ocaml: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART) expunge
# FIXME: is it ok to use the an ocaml from the old stage? --Luca Saiu REENTRANTRUNTIME
# byterun/ocamlrun ./boot/ocamlc $(LINKFLAGS) -linkall -o ocaml.tmp \
# compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma \
# compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART)
# - $(CAMLRUN) ./expunge ocaml.tmp ocaml $(PERVASIVES)
$(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp \
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma \
compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART)
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma \
compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART)
- $(CAMLRUN) ./expunge ocaml.tmp ocaml $(PERVASIVES)
rm -f ocaml.tmp

Expand Down
5 changes: 3 additions & 2 deletions Makefile.nt
Expand Up @@ -10,6 +10,8 @@
# #
#########################################################################

# $Id$

# The main Makefile

include config/Makefile
Expand Down Expand Up @@ -38,8 +40,7 @@ UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \

PARSING=parsing/location.cmo parsing/longident.cmo \
parsing/syntaxerr.cmo parsing/parser.cmo \
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo \
parsing/pprintast.cmo
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo

TYPING=typing/ident.cmo typing/path.cmo \
typing/primitive.cmo typing/types.cmo \
Expand Down
4 changes: 4 additions & 0 deletions README
Expand Up @@ -129,3 +129,7 @@ To be effective, bug reports should include a complete program
configuration you are using (machine type, etc).

You can also contact the implementors directly at caml@inria.fr.


----
$Id$

0 comments on commit 7d4891a

Please sign in to comment.