Skip to content

Commit

Permalink
Fix parallel build (#93)
Browse files Browse the repository at this point in the history
When running "make -j", the build fails because there are no rules to
build .cmti files. (They are byproducts of .cmi files.)

It also fails because it invokes ocamlmklib twice for generating both
zarith.cmxa and zarith.a, thus corrupting files.

Thus, instead of depending on the whole content of TOINSTALL, the "all"
rule now depends only on a subset large enough to trigger all the rules.

The downside is that one can no longer type "make zarith.a". Instead, one
has to type "make zarith.cmxa" (or just "make").
  • Loading branch information
silene authored Jan 3, 2021
1 parent 6028d67 commit bee604e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions project.mak
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@ CMIOBJ = $(MLISRC:%.mli=%.cmi)
CMXOBJ = $(MLISRC:%.mli=%.cmx)
CMIDOC = $(MLISRC:%.mli=%.cmti)

TOINSTALL := zarith.h zarith.cma libzarith.$(LIBSUFFIX) $(MLISRC) $(CMIOBJ) \
zarith_top.cma
TOBUILD = zarith.cma libzarith.$(LIBSUFFIX) $(CMIOBJ) zarith_top.cma z.mli

TOINSTALL = $(TOBUILD) zarith.h q.mli big_int_Z.mli

ifeq ($(HASOCAMLOPT),yes)
TOINSTALL += zarith.$(LIBSUFFIX) zarith.cmxa $(CMXOBJ)
TOBUILD += zarith.cmxa $(CMXOBJ)
TOINSTALL += zarith.$(LIBSUFFIX)
endif

OCAMLFLAGS = -I +compiler-libs
OCAMLOPTFLAGS = -I +compiler-libs

ifeq ($(HASDYNLINK),yes)
TOINSTALL += zarith.cmxs
TOBUILD += zarith.cmxs
endif

ifeq ($(HASBINANNOT),yes)
Expand All @@ -64,21 +66,21 @@ endif
# build targets
###############

all: $(TOINSTALL)
all: $(TOBUILD)

tests:
make -C tests test

zarith.cma: $(MLSRC:%.ml=%.cmo)
$(OCAMLMKLIB) -failsafe -o zarith $+ $(LIBS)

zarith.cmxa zarith.$(LIBSUFFIX): $(MLSRC:%.ml=%.cmx)
zarith.cmxa: $(MLSRC:%.ml=%.cmx)
$(OCAMLMKLIB) -failsafe -o zarith $+ $(LIBS)

zarith.cmxs: zarith.cmxa libzarith.$(LIBSUFFIX)
$(OCAMLOPT) -shared -o $@ -I . zarith.cmxa -linkall

libzarith.$(LIBSUFFIX) dllzarith.$(DLLSUFFIX): $(SSRC:%.S=%.$(OBJSUFFIX)) $(CSRC:%.c=%.$(OBJSUFFIX))
libzarith.$(LIBSUFFIX): $(SSRC:%.S=%.$(OBJSUFFIX)) $(CSRC:%.c=%.$(OBJSUFFIX))
$(OCAMLMKLIB) -failsafe -o zarith $+ $(LIBS)

zarith_top.cma: zarith_top.cmo
Expand Down

0 comments on commit bee604e

Please sign in to comment.