Skip to content

Commit

Permalink
Install compiler internals.
Browse files Browse the repository at this point in the history
Cherry-pick of r12469 and r12471 from trunk + a mention in file Changes.


git-svn-id: http://caml.inria.fr/svn/ocaml/version/4.00@12477 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
xavierleroy committed May 24, 2012
1 parent 52cff84 commit 2671d5b
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 75 deletions.
15 changes: 15 additions & 0 deletions Changes
Expand Up @@ -74,6 +74,21 @@ Standard library:
- Set and Map: more efficient implementation of "filter" and "partition"
- String: new function "map" (PR#3888)

Installation procedure:
- Compiler internals are now installed in `ocamlc -where`/compiler-libs.
The files available there include the .cmi interfaces for all compiler
modules, plus the following libraries:
ocamlcommon.cma/.cmxa modules common to ocamlc, ocamlopt, ocaml
ocamlbytecomp.cma/.cmxa modules for ocamlc and ocaml
ocamloptcomp.cma/.cmxa modules specific to ocamlopt
ocamltoplevel.cma modules specific to ocaml
(PR#1804, PR#4653, frequently-asked feature).
* Some .cmi for toplevel internals that used to be installed in
`ocamlc -where` are now to be found in `ocamlc -where`/compiler-libs.
Add "-I +compiler-libs" where needed.
* toplevellib.cma is no longer installed because subsumed by
ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma

Bug Fixes:
- PR#1643: functions of the Lazy module whose named started with 'lazy_' have
been deprecated, and new ones without the prefix added
Expand Down
161 changes: 96 additions & 65 deletions Makefile
Expand Up @@ -41,8 +41,6 @@ UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
utils/consistbl.cmo

OPTUTILS=$(UTILS)

PARSING=parsing/location.cmo parsing/longident.cmo \
parsing/syntaxerr.cmo parsing/parser.cmo \
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo
Expand All @@ -64,12 +62,16 @@ COMP=bytecomp/lambda.cmo bytecomp/printlambda.cmo \
bytecomp/typeopt.cmo bytecomp/switch.cmo bytecomp/matching.cmo \
bytecomp/translobj.cmo bytecomp/translcore.cmo \
bytecomp/translclass.cmo bytecomp/translmod.cmo \
bytecomp/simplif.cmo bytecomp/runtimedef.cmo
bytecomp/simplif.cmo bytecomp/runtimedef.cmo \
driver/pparse.cmo driver/main_args.cmo

COMMON=$(UTILS) $(PARSING) $(TYPING) $(COMP)

BYTECOMP=bytecomp/meta.cmo bytecomp/instruct.cmo bytecomp/bytegen.cmo \
bytecomp/printinstr.cmo bytecomp/opcodes.cmo bytecomp/emitcode.cmo \
bytecomp/bytesections.cmo bytecomp/dll.cmo bytecomp/symtable.cmo \
bytecomp/bytelink.cmo bytecomp/bytelibrarian.cmo bytecomp/bytepackager.cmo
bytecomp/bytelink.cmo bytecomp/bytelibrarian.cmo bytecomp/bytepackager.cmo \
driver/errors.cmo driver/compile.cmo

ASMCOMP=asmcomp/arch.cmo asmcomp/debuginfo.cmo \
asmcomp/cmm.cmo asmcomp/printcmm.cmo \
Expand All @@ -84,42 +86,22 @@ ASMCOMP=asmcomp/arch.cmo asmcomp/debuginfo.cmo \
asmcomp/printlinear.cmo asmcomp/linearize.cmo \
asmcomp/schedgen.cmo asmcomp/scheduling.cmo \
asmcomp/emitaux.cmo asmcomp/emit.cmo asmcomp/asmgen.cmo \
asmcomp/asmlink.cmo asmcomp/asmlibrarian.cmo asmcomp/asmpackager.cmo

DRIVER=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
driver/main_args.cmo driver/main.cmo

OPTDRIVER= driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
driver/main_args.cmo driver/optmain.cmo
asmcomp/asmlink.cmo asmcomp/asmlibrarian.cmo asmcomp/asmpackager.cmo \
driver/opterrors.cmo driver/optcompile.cmo

TOPLEVEL=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
driver/main_args.cmo toplevel/genprintval.cmo toplevel/toploop.cmo \
TOPLEVEL=toplevel/genprintval.cmo toplevel/toploop.cmo \
toplevel/trace.cmo toplevel/topdirs.cmo toplevel/topmain.cmo

TOPLEVELLIB=toplevel/toplevellib.cma
TOPLEVELSTART=toplevel/topstart.cmo

COMPOBJS=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(DRIVER)
BYTESTART=driver/main.cmo

TOPLIB=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(TOPLEVEL)
OPTSTART=driver/optmain.cmo

TOPOBJS=$(TOPLEVELLIB) $(TOPLEVELSTART)
TOPLEVELSTART=toplevel/topstart.cmo

NATTOPOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
driver/main_args.cmo \
NATTOPOBJS=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
toplevel/genprintval.cmo toplevel/opttoploop.cmo toplevel/opttopdirs.cmo \
toplevel/opttopmain.cmo toplevel/opttopstart.cmo

OPTOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) $(OPTDRIVER)

EXPUNGEOBJS=utils/misc.cmo utils/tbl.cmo \
utils/config.cmo utils/clflags.cmo \
typing/ident.cmo typing/path.cmo typing/types.cmo typing/btype.cmo \
utils/warnings.cmo parsing/location.cmo \
typing/predef.cmo bytecomp/runtimedef.cmo bytecomp/bytesections.cmo \
bytecomp/dll.cmo bytecomp/meta.cmo bytecomp/symtable.cmo toplevel/expunge.cmo

PERVASIVES=$(STDLIB_MODULES) outcometree topdirs toploop

# For users who don't read the INSTALL file
Expand Down Expand Up @@ -278,10 +260,14 @@ base.opt: checkstack runtime core ocaml opt-core ocamlc.opt otherlibraries \
otherlibrariesopt

# Installation

COMPLIBDIR=$(LIBDIR)/compiler-libs

install:
if test -d $(BINDIR); then : ; else $(MKDIR) $(BINDIR); fi
if test -d $(LIBDIR); then : ; else $(MKDIR) $(LIBDIR); fi
if test -d $(STUBLIBDIR); then : ; else $(MKDIR) $(STUBLIBDIR); fi
if test -d $(COMPLIBDIR); then : ; else $(MKDIR) $(COMPLIBDIR); fi
if test -d $(MANDIR)/man$(MANEXT); then : ; \
else $(MKDIR) $(MANDIR)/man$(MANEXT); fi
cp VERSION $(LIBDIR)/
Expand All @@ -294,12 +280,9 @@ install:
cd stdlib; $(MAKE) install
cp lex/ocamllex $(BINDIR)/ocamllex$(EXE)
cp yacc/ocamlyacc$(EXE) $(BINDIR)/ocamlyacc$(EXE)
cp toplevel/toplevellib.cma $(LIBDIR)/toplevellib.cma
cp utils/*.cmi parsing/*.cmi typing/*.cmi bytecomp/*.cmi driver/*.cmi toplevel/*.cmi $(COMPLIBDIR)
cp compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma compilerlibs/ocamltoplevel.cma $(BYTESTART) $(TOPLEVELSTART) $(COMPLIBDIR)
cp expunge $(LIBDIR)/expunge$(EXE)
cp typing/outcometree.cmi typing/outcometree.mli $(LIBDIR)
cp toplevel/topstart.cmo $(LIBDIR)
cp toplevel/toploop.cmi toplevel/topdirs.cmi toplevel/topmain.cmi \
$(LIBDIR)
cd tools; $(MAKE) install
-cd man; $(MAKE) install
for i in $(OTHERLIBRARIES); do \
Expand All @@ -318,34 +301,59 @@ installopt:
cd asmrun; $(MAKE) install
cp ocamlopt $(BINDIR)/ocamlopt$(EXE)
cd stdlib; $(MAKE) installopt
cp asmcomp/*.cmi $(COMPLIBDIR)
cp compilerlibs/ocamloptcomp.cma $(OPTSTART) $(COMPLIBDIR)
cd ocamldoc; $(MAKE) installopt
for i in $(OTHERLIBRARIES); \
do (cd otherlibs/$$i; $(MAKE) installopt) || exit $$?; done
if test -f ocamlc.opt; \
then cp ocamlc.opt $(BINDIR)/ocamlc.opt$(EXE); else :; fi
if test -f ocamlopt.opt; \
then cp ocamlopt.opt $(BINDIR)/ocamlopt.opt$(EXE); else :; fi
if test -f lex/ocamllex.opt; \
then cp lex/ocamllex.opt $(BINDIR)/ocamllex.opt$(EXE); else :; fi
if test -f ocamlopt.opt ; then $(MAKE) installoptopt; fi
cd tools; $(MAKE) installopt

installoptopt:
cp ocamlc.opt $(BINDIR)/ocamlc.opt$(EXE)
cp ocamlopt.opt $(BINDIR)/ocamlopt.opt$(EXE)
cp lex/ocamllex.opt $(BINDIR)/ocamllex.opt$(EXE)
cp compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlcommon.a \
compilerlibs/ocamlbytecomp.cmxa compilerlibs/ocamlbytecomp.a \
compilerlibs/ocamloptcomp.cmxa compilerlibs/ocamloptcomp.a \
$(BYTESTART:.cmo=.cmx) $(BYTESTART:.cmo=.o) \
$(OPTSTART:.cmo=.cmx) $(OPTSTART:.cmo=.o) \
$(COMPLIBDIR)
cd $(COMPLIBDIR) && $(RANLIB) ocamlcommon.a ocamlbytecomp.a ocamloptcomp.a

clean:: partialclean

# The compiler
# Shared parts of the system

ocamlc: $(COMPOBJS)
$(CAMLC) $(LINKFLAGS) -o ocamlc $(COMPOBJS)
compilerlibs/ocamlcommon.cma: $(COMMON)
$(CAMLC) -a -o $@ $(COMMON)
partialclean::
rm -f compilerlibs/ocamlcommon.cma

# The bytecode compiler

compilerlibs/ocamlbytecomp.cma: $(BYTECOMP)
$(CAMLC) -a -o $@ $(BYTECOMP)
partialclean::
rm -f compilerlibs/ocamlbytecomp.cma

ocamlc: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
$(CAMLC) $(LINKFLAGS) -o ocamlc \
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
@sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlc|' \
driver/ocamlcomp.sh.in > ocamlcomp.sh
@chmod +x ocamlcomp.sh

partialclean::
rm -f ocamlc ocamlcomp.sh

# The native-code compiler

ocamlopt: $(OPTOBJS)
$(CAMLC) $(LINKFLAGS) -o ocamlopt $(OPTOBJS)
compilerlibs/ocamloptcomp.cma: $(ASMCOMP)
$(CAMLC) -a -o $@ $(ASMCOMP)
partialclean::
rm -f compilerlibs/ocamloptcomp.cma

ocamlopt: compilerlibs/ocamlcommon.cma compilerlibs/ocamloptcomp.cma $(OPTSTART)
$(CAMLC) $(LINKFLAGS) -o ocamlopt \
compilerlibs/ocamlcommon.cma compilerlibs/ocamloptcomp.cma $(OPTSTART)
@sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlopt|' \
driver/ocamlcomp.sh.in > ocamlcompopt.sh
@chmod +x ocamlcompopt.sh
Expand All @@ -355,16 +363,20 @@ partialclean::

# The toplevel

ocaml: $(TOPOBJS) expunge
$(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp $(TOPOBJS)
compilerlibs/ocamltoplevel.cma: $(TOPLEVEL)
$(CAMLC) -a -o $@ $(TOPLEVEL)
partialclean::
rm -f compilerlibs/ocamltoplevel.cma

ocaml: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART) expunge
$(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp \
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma \
compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART)
- $(CAMLRUN) ./expunge ocaml.tmp ocaml $(PERVASIVES)
rm -f ocaml.tmp

toplevel/toplevellib.cma: $(TOPLIB)
$(CAMLC) -a -o $@ $(TOPLIB)

partialclean::
rm -f ocaml toplevel/toplevellib.cma
rm -f ocaml

# The native toplevel

Expand Down Expand Up @@ -433,13 +445,24 @@ partialclean::

beforedepend:: parsing/lexer.ml

# Shared parts of the system compiled with the native-code compiler

compilerlibs/ocamlcommon.cmxa: $(COMMON:.cmo=.cmx)
$(CAMLOPT) -a -o $@ $(COMMON:.cmo=.cmx)
partialclean::
rm -f compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlcommon.a

# The bytecode compiler compiled with the native-code compiler

ocamlc.opt: $(COMPOBJS:.cmo=.cmx)
cd asmrun; $(MAKE) meta.o dynlink.o
compilerlibs/ocamlbytecomp.cmxa: $(BYTECOMP:.cmo=.cmx)
$(CAMLOPT) -a -o $@ $(BYTECOMP:.cmo=.cmx)
partialclean::
rm -f compilerlibs/ocamlbytecomp.cmxa compilerlibs/ocamlbytecomp.a

ocamlc.opt: compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa $(BYTESTART:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -ccopt "$(BYTECCLINKOPTS)" -o ocamlc.opt \
$(COMPOBJS:.cmo=.cmx) \
asmrun/meta.o asmrun/dynlink.o -cclib "$(BYTECCLIBS)"
compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa \
$(BYTESTART:.cmo=.cmx) -cclib "$(BYTECCLIBS)"
@sed -e 's|@compiler@|$$topdir/ocamlc.opt|' \
driver/ocamlcomp.sh.in > ocamlcomp.sh
@chmod +x ocamlcomp.sh
Expand All @@ -449,16 +472,23 @@ partialclean::

# The native-code compiler compiled with itself

ocamlopt.opt: $(OPTOBJS:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -o ocamlopt.opt $(OPTOBJS:.cmo=.cmx)
compilerlibs/ocamloptcomp.cmxa: $(ASMCOMP:.cmo=.cmx)
$(CAMLOPT) -a -o $@ $(ASMCOMP:.cmo=.cmx)
partialclean::
rm -f compilerlibs/ocamloptcomp.cmxa compilerlibs/ocamloptcomp.a

ocamlopt.opt: compilerlibs/ocamlcommon.cmxa compilerlibs/ocamloptcomp.cmxa $(OPTSTART:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -o ocamlopt.opt \
compilerlibs/ocamlcommon.cmxa compilerlibs/ocamloptcomp.cmxa \
$(OPTSTART:.cmo=.cmx)
@sed -e 's|@compiler@|$$topdir/ocamlopt.opt|' \
driver/ocamlcomp.sh.in > ocamlcompopt.sh
@chmod +x ocamlcompopt.sh

partialclean::
rm -f ocamlopt.opt

$(OPTOBJS:.cmo=.cmx): ocamlopt
$(COMMON:.cmo=.cmx) $(BYTECOMP:.cmo=.cmx) $(ASMCOMP:.cmo=.cmx): ocamlopt

# The numeric opcodes

Expand Down Expand Up @@ -549,8 +579,9 @@ tools/cvt_emit: tools/cvt_emit.mll

# The "expunge" utility

expunge: $(EXPUNGEOBJS)
$(CAMLC) $(LINKFLAGS) -o expunge $(EXPUNGEOBJS)
expunge: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma toplevel/expunge.cmo
$(CAMLC) $(LINKFLAGS) -o expunge \
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma toplevel/expunge.cmo

partialclean::
rm -f expunge
Expand Down
2 changes: 1 addition & 1 deletion _tags
Expand Up @@ -17,7 +17,7 @@ true: -traverse
# Traverse only these directories
<{bytecomp,driver,stdlib,tools,asmcomp,camlp4,ocamlbuild,toplevel,ocamldoc,typing,otherlibs,utils,debugger,lex,parsing,byterun,asmrun}/**>: traverse

"boot" or "byterun" or "asmrun": not_hygienic
"boot" or "byterun" or "asmrun" or "compilerlibs": not_hygienic

# These should not be required but it fails on *BSD and Windows...
"yacc" or "win32caml": not_hygienic
Expand Down
3 changes: 2 additions & 1 deletion asmrun/Makefile
Expand Up @@ -26,7 +26,8 @@ COBJS=startup.o main.o fail.o roots.o globroots.o signals.o signals_asm.o \
misc.o freelist.o major_gc.o minor_gc.o memory.o alloc.o compare.o ints.o \
floats.o str.o array.o io.o extern.o intern.o hash.o sys.o parsing.o \
gc_ctrl.o terminfo.o md5.o obj.o lexing.o printexc.o callback.o weak.o \
compact.o finalise.o custom.o unix.o backtrace.o natdynlink.o debugger.o
compact.o finalise.o custom.o unix.o backtrace.o natdynlink.o debugger.o \
meta.o dynlink.o

ASMOBJS=$(ARCH).o

Expand Down
Empty file added compilerlibs/.gitignore
Empty file.
6 changes: 3 additions & 3 deletions otherlibs/labltk/browser/Makefile.shared
Expand Up @@ -43,10 +43,10 @@ JG = jg_tk.cmo jg_config.cmo jg_bind.cmo jg_completion.cmo \

all: ocamlbrowser$(EXE)

ocamlbrowser$(EXE): $(TOPDIR)/toplevel/toplevellib.cma jglib.cma $(OBJ) \
ocamlbrowser$(EXE): $(TOPDIR)/compilerlibs/ocamlcommon.cma jglib.cma $(OBJ) \
../support/lib$(LIBNAME).$(A) $(XTRAOBJ)
$(CAMLC) -o ocamlbrowser$(EXE) $(INCLUDES) \
$(TOPDIR)/toplevel/toplevellib.cma \
$(TOPDIR)/compilerlibs/ocamlcommon.cma \
unix.cma str.cma $(XTRALIBS) $(LIBNAME).cma jglib.cma \
$(OBJ) $(XTRAOBJ)

Expand All @@ -72,7 +72,7 @@ depend: help.ml
$(CAMLDEP) *.ml *.mli > .depend

shell.cmo: dummy.cmi
setpath.cmo fileselect.cmo lexical.cmi searchid.cmi typecheck.cmi: $(TOPDIR)/toplevel/toplevellib.cma
setpath.cmo fileselect.cmo lexical.cmi searchid.cmi typecheck.cmi: $(TOPDIR)/compilerlibs/ocamlcommon.cma
mytypes.cmi searchpos.cmi searchpos.cmo typecheck.cmo: $(TOPDIR)/typing/stypes.cmi

include .depend
12 changes: 9 additions & 3 deletions otherlibs/labltk/lib/Makefile
Expand Up @@ -42,7 +42,13 @@ SUPPORT=../support/support.cmo ../support/rawwidget.cmo \

TKOBJS=$(SUPPORT) $(LABLTKOBJS) $(CAMLTKOBJS)

TOPDEPS = $(TOPDIR)/toplevel/toplevellib.cma $(TOPDIR)/toplevel/topmain.cmo
TOPLEVELLIBS=$(TOPDIR)/compilerlibs/ocamlcommon.cma \
$(TOPDIR)/compilerlibs/ocamlbytecomp.cma \
$(TOPDIR)/compilerlibs/ocamltoplevel.cma

TOPLEVELSTART=$(TOPDIR)/toplevel/topstart.cmo

TOPDEPS = $(TOPLEVELLIBS) $(TOPLEVELSTART)

$(LIBNAME).cma: $(SUPPORT) ../Widgets.src
$(MAKE) superclean
Expand All @@ -62,11 +68,11 @@ $(LIBNAME).cmxa: $(SUPPORT:.cmo=.cmx) ../Widgets.src

$(LIBNAME)top$(EXE) : $(TOPDEPS) $(LIBNAME).cma ../support/lib$(LIBNAME).$(A)
$(CAMLC) -verbose -linkall -o $(LIBNAME)top$(EXE) -I ../support \
-I $(TOPDIR)/toplevel toplevellib.cma \
$(TOPLEVELLIBS) \
-I $(OTHERS)/unix -I $(OTHERS)/win32unix unix.cma \
-I ../labltk -I ../camltk $(LIBNAME).cma \
-I $(OTHERS)/str str.cma \
topstart.cmo
$(TOPLEVELSTART)

$(LIBNAME): Makefile $(TOPDIR)/config/Makefile
@echo Generate $@
Expand Down
2 changes: 1 addition & 1 deletion tools/ocamlmktop.ml
Expand Up @@ -14,4 +14,4 @@

let _ =
let args = Ccomp.quote_files (List.tl (Array.to_list Sys.argv)) in
exit(Sys.command("ocamlc -linkall toplevellib.cma " ^ args ^ " topstart.cmo"))
exit(Sys.command("ocamlc -I +compiler-libs -linkall ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma " ^ args ^ " topstart.cmo"))
2 changes: 1 addition & 1 deletion tools/ocamlmktop.tpl
Expand Up @@ -13,4 +13,4 @@

# $Id$

exec %%BINDIR%%/ocamlc -linkall toplevellib.cma "$@" topstart.cmo
exec %%BINDIR%%/ocamlc -I +compiler-libs -linkall ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma "$@" topstart.cmo

0 comments on commit 2671d5b

Please sign in to comment.