Parallel compilation

This commit is contained in:
Nathanaël Courant 2021-02-19 12:07:54 +01:00
parent 92037d7271
commit f8ed42b26d
4 changed files with 27 additions and 13 deletions

View File

@ -117,10 +117,12 @@ ocamlrun: $(OCAMLRUN)
$(BOOT)/ocamlc: $(COPY_TARGETS)
make -C $(OCAMLSRC)/yacc all
make -C miniml/interp interpopt.opt
./timed.sh make -C _boot/stdlib all
touch _boot/stdlib/.depend && make -C _boot/stdlib depend
touch _boot/.depend && make -C _boot depend
./timed.sh make -C _boot/stdlib -j$(nproc) all
# cd $(BOOT)/stdlib && ../../timed.sh ../../compile_stdlib.sh
mkdir -p $(BOOT)/compilerlibs
./timed.sh make -C _boot all
./timed.sh make -C _boot -j$(nproc) all
# cd $(BOOT) && ../timed.sh ../compile_ocamlc.sh
.PHONY: test-compiler

View File

@ -13,7 +13,9 @@
#* *
#**************************************************************************
COMPILER=../miniml/interp/interp.opt -g -nostdlib -I stdlib
OPAQUE=-opaque
COMPILER=../miniml/interp/interp.opt $(OPAQUE) -nostdlib -I stdlib
INCLUDES=-I utils -I parsing -I typing -I bytecomp -I driver
COMPFLAGS=-strict-sequence -principal -absname -w +a-4-9-41-42-44-45-48 \
@ -21,7 +23,7 @@ COMPFLAGS=-strict-sequence -principal -absname -w +a-4-9-41-42-44-45-48 \
-bin-annot -safe-string -strict-formats $(INCLUDES)
LINKFLAGS=
DEPEND=../miniml/interp/depend.sh
DEPEND=../miniml/interp/depend.sh $(OPAQUE)
DEPFLAGS=$(INCLUDES)
UTILS=utils/config.cmx utils/misc.cmx \
@ -79,8 +81,6 @@ BYTECOMP=bytecomp/instruct.cmx bytecomp/bytegen.cmx \
BYTESTART=driver/main.cmx
all: ocamlc
# Shared parts of the system compiled with the native-code compiler
compilerlibs/ocamlcommon.cmxa: $(COMMON)

View File

@ -13,14 +13,15 @@
#* *
#**************************************************************************
CAMLRUN = ../../ocaml-src/byterun/ocamlrun
TARGET_BINDIR ?= $(BINDIR)
COMPFLAGS=-strict-sequence -absname -w +a-4-9-41-42-44-45-48 \
-g -warn-error A -bin-annot -nostdlib \
-safe-string -strict-formats
COMPILER=../../miniml/interp/interp.opt
DEPEND=../../miniml/interp/depend.sh -native
# Set -opaque for faster compilation
OPAQUE=-opaque
COMPILER=../../miniml/interp/interp.opt $(OPAQUE)
DEPEND=../../miniml/interp/depend.sh $(OPAQUE) -native
# Object file prefix
P=stdlib__
@ -72,10 +73,17 @@ stdlib__%.cmx: %.ml
$(COMPILER) $(COMPFLAGS) $(shell ./Compflags $@) -o $@ -c $<
# Dependencies on Stdlib (not tracked by ocamldep)
$(OTHERS:.cmx=.cmi) std_exit.cmi: stdlib.cmi
$(OBJS) std_exit.cmx: stdlib.cmi
ifeq "$(OPAQUE)" ""
CMIX=cmx
$(OTHERS) std_exit.cmx: stdlib.cmx
else
CMIX=cmi
endif
clean::
rm -f *.cm* *.o *.a
@ -86,12 +94,13 @@ include .depend
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
.PHONY: depend
depend:
$(DEPEND) $(filter-out stdlib.%,$(wildcard *.mli *.ml)) \
> .depend.tmp
echo "stdlib.cmi : camlinternalFormatBasics.cmi" >> .depend.tmp
echo "stdlib.cmx : camlinternalFormatBasics.cmx" >> .depend.tmp
echo "stdlib.cmx : camlinternalFormatBasics.$(CMIX)" >> .depend.tmp
sed -Ee \
's#(^| )(${subst ${SPACE},|,${PREFIXED_OBJS:stdlib__%.cmx=%}})[.]#\1stdlib__\2.#g' \
.depend.tmp > .depend

View File

@ -29,6 +29,7 @@ let load_path = ref ([] : (string * string array) list)
let ml_synonyms = ref [".ml"]
let mli_synonyms = ref [".mli"]
let shared = ref false
let opaque = ref false
let native_only = ref false
let bytecode_only = ref false
let error_occurred = ref false
@ -117,7 +118,7 @@ let find_dependency target_kind modname (byt_deps, opt_deps) =
let basename = Filename.chop_extension filename in
let cmi_file = basename ^ ".cmi" in
let cmx_file = basename ^ ".cmx" in
let ml_exists =
let ml_exists = not !opaque &&
List.exists (fun ext -> Sys.file_exists (basename ^ ext)) !ml_synonyms in
let new_opt_dep =
if !all_dependencies then
@ -401,6 +402,8 @@ let main () =
" Generate dependencies for native-code only (no .cmo files)";
"-bytecode", Arg.Set bytecode_only,
" Generate dependencies for bytecode-code only (no .cmx files)";
"-opaque", Arg.Set opaque,
" Generate dependencies for compilation with -opaque";
(* "-pp", Arg.String(fun s -> Clflags.preprocessor := Some s),
"<cmd> Pipe sources through preprocessor <cmd>"; *)
] in