diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Changes | 4 | ||||
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | Makefile.config.in | 4 | ||||
-rw-r--r-- | runtime/Makefile | 46 | ||||
-rw-r--r-- | runtime/caml/config.h | 4 | ||||
-rw-r--r-- | runtime/win32.c | 11 | ||||
-rw-r--r-- | stdlib/Makefile | 4 |
8 files changed, 58 insertions, 44 deletions
diff --git a/.gitignore b/.gitignore index bfc37866dc..dd0dfece2d 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ _build /asmcomp/CSE.ml /boot/ocamlrun +/boot/ocamlruns /boot/camlheader /boot/ocamlc.opt @@ -358,6 +358,10 @@ Working version (Gabriel Scherer, review by Sébastien Hinderer and David Allsopp, report by Ralph Seichter) +- #10135: Speed-up the FlexDLL bootstrap by building a separate non-shared + version of the runtime and keeping shared artefacts. + (David Allsopp, review by Sébastien Hinderer) + - #10156: configure script: fix sockets feature detection. (Lucas Pluvinage, review by David Allsopp and Damien Doligez) @@ -96,10 +96,9 @@ ifeq "$(FLEXDLL_SUBMODULE_PRESENT)" "" BOOT_FLEXLINK_CMD = else BOOT_FLEXLINK_CMD = \ - FLEXLINK_CMD="../boot/ocamlrun$(EXE) ../flexdll/flexlink.exe" -endif -else -endif + FLEXLINK_CMD="../boot/ocamlruns$(EXE) ../flexdll/flexlink.exe" +endif # ifeq "$(FLEXDLL_SUBMODULE_PRESENT)" "" +endif # ifeq "$(UNIX_OR_WIN32)" "win32" expunge := expunge$(EXE) @@ -300,23 +299,27 @@ flexdll: flexdll/Makefile flexlink # Bootstrapping flexlink - leaves a bytecode image of flexlink.exe in flexdll/ FLEXLINK_OCAMLOPT = \ - ../boot/ocamlrun$(EXE) ../boot/ocamlc \ + ../boot/ocamlruns$(EXE) ../boot/ocamlc \ -use-prims ../runtime/primitives -nostdlib -I ../boot +# Command to coldstart the standard library when bootstrapping flexlink +FLEXLINK_STDLIB_CAMLC = \ + ../boot/ocamlruns$(EXE) ../boot/ocamlc -use-prims ../runtime/primitives + +runtime/ocamlruns$(EXE): + $(MAKE) -C runtime ocamlruns$(EXE) + .PHONY: flexlink -flexlink: flexdll/Makefile - $(MAKE) -C runtime BOOTSTRAPPING_FLEXLINK=yes ocamlrun$(EXE) - cp runtime/ocamlrun$(EXE) boot/ocamlrun$(EXE) +flexlink: flexdll/Makefile runtime/ocamlruns$(EXE) + cp runtime/ocamlruns$(EXE) boot/ocamlruns$(EXE) $(MAKE) -C stdlib \ - COMPILER="../boot/ocamlc -use-prims ../runtime/primitives" \ + CAMLC="$(FLEXLINK_STDLIB_CAMLC)" \ $(filter-out *.cmi,$(LIBFILES)) cd stdlib && cp $(LIBFILES) ../boot/ $(MAKE) -C flexdll MSVC_DETECT=0 OCAML_CONFIG_FILE=../Makefile.config \ CHAINS=$(FLEXDLL_CHAIN) NATDYNLINK=false \ OCAMLOPT="$(FLEXLINK_OCAMLOPT)" \ flexlink.exe - $(MAKE) -C runtime clean - $(MAKE) partialclean .PHONY: flexlink.opt flexlink.opt: @@ -1091,7 +1094,8 @@ depend: beforedepend .PHONY: distclean distclean: clean rm -f boot/ocamlrun boot/ocamlrun.exe boot/camlheader \ - boot/*.cm* boot/libcamlrun.a boot/libcamlrun.lib boot/ocamlc.opt + boot/ocamlruns boot/ocamlruns.exe \ + boot/*.cm* boot/libcamlrun.a boot/libcamlrun.lib boot/ocamlc.opt rm -f Makefile.config Makefile.build_config rm -f runtime/caml/m.h runtime/caml/s.h rm -rf autom4te.cache diff --git a/Makefile.config.in b/Makefile.config.in index 215a2b9872..adcb8a09d0 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -251,10 +251,10 @@ ifeq "$(TOOLCHAIN)" "msvc" MERGEMANIFESTEXE=test ! -f $(1).manifest \ || mt -nologo -outputresource:$(1) -manifest $(1).manifest \ && rm -f $(1).manifest - MKEXE_BOOT=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OUTPUTEXE)$(1) $(2) \ + MKEXE_USING_COMPILER=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OUTPUTEXE)$(1) $(2) \ /link /subsystem:console $(OC_LDFLAGS) $(LDFLAGS) && ($(MERGEMANIFESTEXE)) else - MKEXE_BOOT=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_LDFLAGS) $(LDFLAGS) \ + MKEXE_USING_COMPILER=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_LDFLAGS) $(LDFLAGS) \ $(OUTPUTEXE)$(1) $(2) endif # ifeq "$(TOOLCHAIN)" "msvc" diff --git a/runtime/Makefile b/runtime/Makefile index 535f056dd2..71eb3dbc19 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -83,6 +83,10 @@ ASM_OBJECTS := $(ASM_SOURCES:.$(ASM_EXT)=.$(O)) libcamlrun_OBJECTS := $(BYTECODE_C_SOURCES:.c=.b.$(O)) +libcamlrun_non_shared_OBJECTS := \ + $(subst $(UNIX_OR_WIN32).b.$(O),$(UNIX_OR_WIN32)_non_shared.b.$(O), \ + $(libcamlrun_OBJECTS)) + libcamlrund_OBJECTS := $(BYTECODE_C_SOURCES:.c=.bd.$(O)) \ instrtrace.bd.$(O) @@ -101,10 +105,6 @@ libasmrunpic_OBJECTS := $(NATIVE_C_SOURCES:.c=.npic.$(O)) \ # General (non target-specific) assembler and compiler flags -ifdef BOOTSTRAPPING_FLEXLINK -OC_CPPFLAGS += -DBOOTSTRAPPING_FLEXLINK -endif - # On Windows, OCAML_STDLIB_DIR needs to be defined dynamically ifeq "$(UNIX_OR_WIN32)" "win32" @@ -154,16 +154,10 @@ endif # Commands used to build native libraries +LIBS := $(BYTECCLIBS) + ifeq "$(UNIX_OR_WIN32)" "win32" -LIBS = $(BYTECCLIBS) $(EXTRALIBS) -ifdef BOOTSTRAPPING_FLEXLINK -MAKE_OCAMLRUN=$(MKEXE_BOOT) -else -MAKE_OCAMLRUN = $(MKEXE) -o $(1) $(2) -endif -else -LIBS = $(BYTECCLIBS) -MAKE_OCAMLRUN = $(MKEXE) -o $(1) $(2) +LIBS += $(EXTRALIBS) endif # Build, install and clean targets @@ -200,8 +194,8 @@ endif .PHONY: clean clean: rm -f *.o *.obj *.a *.lib *.so *.dll ld.conf - rm -f ocamlrun ocamlrund ocamlruni - rm -f ocamlrun.exe ocamlrund.exe ocamlruni.exe + rm -f ocamlrun ocamlrund ocamlruni ocamlruns + rm -f ocamlrun.exe ocamlrund.exe ocamlruni.exe ocamlruns.exe rm -f primitives primitives.new prims.c $(GENERATED_HEADERS) rm -f domain_state*.inc rm -rf $(DEPDIR) @@ -272,11 +266,17 @@ caml/version.h : $(ROOTDIR)/tools/make-version-header.sh $(ROOTDIR)/VERSION # Libraries and programs ocamlrun$(EXE): prims.$(O) libcamlrun.$(A) - $(call MAKE_OCAMLRUN,$@,$^ $(LIBS)) + $(MKEXE) -o $@ $^ $(LIBS) + +ocamlruns$(EXE): prims.$(O) libcamlrun_non_shared.$(A) + $(call MKEXE_USING_COMPILER,$@,$^ $(LIBS)) libcamlrun.$(A): $(libcamlrun_OBJECTS) $(call MKLIB,$@, $^) +libcamlrun_non_shared.$(A): $(libcamlrun_non_shared_OBJECTS) + $(call MKLIB,$@, $^) + ocamlrund$(EXE): prims.$(O) libcamlrund.$(A) $(MKEXE) $(MKEXEDEBUGFLAG) -o $@ $^ $(LIBS) @@ -350,11 +350,11 @@ ifneq "$(1)" "%" $(DEPDIR)/$(1).$(D): %.c | $(DEPDIR) $(GENERATED_HEADERS) $$(DEP_CC) $$(OC_CPPFLAGS) $$(CPPFLAGS) $$< -MT \ '$$*$(subst %,,$(1)).$(O)' -MF $$@ -endif -$(1).$(O): %.c +endif # ifneq "$(1)" "%" +$(1).$(O): $(2).c else -$(1).$(O): %.c $(CONFIG_HEADERS) $(GENERATED_HEADERS) $(RUNTIME_HEADERS) -endif +$(1).$(O): $(2).c $(CONFIG_HEADERS) $(GENERATED_HEADERS) $(RUNTIME_HEADERS) +endif # ifneq "$(COMPUTE_DEPS)" "false" $$(CC) -c $$(OC_CFLAGS) $$(CFLAGS) $$(OC_CPPFLAGS) $$(CPPFLAGS) \ $$(OUTPUTOBJ)$$@ $$< endef @@ -365,12 +365,16 @@ object_types += %.n %.nd %.ni %.np %.npic endif $(foreach object_type, $(object_types), \ - $(eval $(call COMPILE_C_FILE,$(object_type)))) + $(eval $(call COMPILE_C_FILE,$(object_type),%))) dynlink.%.$(O): OC_CPPFLAGS += $(STDLIB_CPP_FLAG) startup_byt.%.$(O): OC_CPPFLAGS += $(STDLIB_CPP_FLAG) -DHOST='"$(HOST)"' +$(UNIX_OR_WIN32)_non_shared.%.$(O): OC_CPPFLAGS += -DBUILDING_LIBCAMLRUNS + +$(eval $(call COMPILE_C_FILE,$(UNIX_OR_WIN32)_non_shared.%,$(UNIX_OR_WIN32))) + $(foreach object_type,$(subst %,,$(object_types)), \ $(eval dynlink$(object_type).$(O): $(ROOTDIR)/Makefile.config)) diff --git a/runtime/caml/config.h b/runtime/caml/config.h index dce08e0687..471a6bc6f4 100644 --- a/runtime/caml/config.h +++ b/runtime/caml/config.h @@ -41,10 +41,6 @@ #include "s.h" -#ifdef BOOTSTRAPPING_FLEXLINK -#undef SUPPORT_DYNAMIC_LINKING -#endif - #ifndef CAML_NAME_SPACE #include "compatibility.h" #endif diff --git a/runtime/win32.c b/runtime/win32.c index d72c95400b..a4d3b15b98 100644 --- a/runtime/win32.c +++ b/runtime/win32.c @@ -48,7 +48,12 @@ #include "caml/sys.h" #include "caml/config.h" -#ifdef SUPPORT_DYNAMIC_LINKING + +#if defined(SUPPORT_DYNAMIC_LINKING) && !defined(BUILDING_LIBCAMLRUNS) +#define WITH_DYNAMIC_LINKING +#endif + +#ifdef WITH_DYNAMIC_LINKING #include <flexdll.h> #endif @@ -214,7 +219,7 @@ wchar_t * caml_search_dll_in_path(struct ext_table * path, const wchar_t * name) return res; } -#ifdef SUPPORT_DYNAMIC_LINKING +#ifdef WITH_DYNAMIC_LINKING void * caml_dlopen(wchar_t * libname, int for_execution, int global) { @@ -275,7 +280,7 @@ char * caml_dlerror(void) return "dynamic loading not supported on this platform"; } -#endif +#endif /* WITH_DYNAMIC_LINKING */ /* Proper emulation of signal(), including ctrl-C and ctrl-break */ diff --git a/stdlib/Makefile b/stdlib/Makefile index 195511d41c..03eb04f8c9 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -158,7 +158,7 @@ camlhead%: tmphead%.exe # Again, pattern weirdness here means that the dot is always present so that # tmpheader.exe matches. tmpheader%exe: $(HEADERPROGRAM)%$(O) - $(call MKEXE_BOOT,$@,$^ $(EXTRALIBS)) + $(call MKEXE_USING_COMPILER,$@,$^ $(EXTRALIBS)) # FIXME This is wrong - mingw could invoke strip; MSVC equivalent? ifneq "$(UNIX_OR_WIN32)" "win32" strip $@ @@ -176,7 +176,7 @@ camlheader_ur: camlheader ifeq "$(UNIX_OR_WIN32)" "unix" tmptargetcamlheader%exe: $(TARGETHEADERPROGRAM)%$(O) - $(call MKEXE_BOOT,$@,$^ $(EXTRALIBS)) + $(call MKEXE_USING_COMPILER,$@,$^ $(EXTRALIBS)) strip $@ $(TARGETHEADERPROGRAM)%$(O): $(HEADERPROGRAM).c |