From d74c57cfbade8a51a5efc969a0d5861979de6c72 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sun, 8 Oct 2023 10:27:06 +0200 Subject: [PATCH] Reduce the dependencies of native-code Dynlink Currently, both the bytecode version and the native-code version of Dynlink drag in many modules from the compiler, including some that use compressed marshaling. This causes users of dynlink.cmxa to depend on -lzstd systematically. Actually, the native-code version of Dynlink needs much fewer compiler modules, none of which require compressed marshaling. This commit just shrinks the list of compiler modules included in dynlink.cmxa, thus cutting the dependency on -lzstd. (cherry picked from commit c6d6e8b426d3bbd8a8ccf3eb6f5d9aa6a2a56b7f) --- otherlibs/dynlink/Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/otherlibs/dynlink/Makefile b/otherlibs/dynlink/Makefile index efc655a4dacf..1e7e367ae950 100644 --- a/otherlibs/dynlink/Makefile +++ b/otherlibs/dynlink/Makefile @@ -35,7 +35,8 @@ ifeq "$(FLAMBDA)" "true" OPTCOMPFLAGS += -O3 endif -COMPFLAGS += -I byte +%.cmo: COMPFLAGS += -I byte +%.cmi: COMPFLAGS += -I byte OPTCOMPFLAGS += -I native LOCAL_SRC=dynlink_compilerlibs @@ -126,6 +127,16 @@ COMPILERLIBS_SOURCES=\ bytecomp/meta.ml \ bytecomp/symtable.ml +# For the native-code version of this library, we need much fewer modules +MINI_COMPILERLIBS_INTFS=\ + file_formats/cmxs_format.mli + +MINI_COMPILERLIBS_SOURCES=\ + utils/binutils.ml \ + utils/config.ml \ + utils/build_path_prefix_map.ml \ + utils/misc.ml + # Rules to make a local copy of the .ml and .mli files required. We also # provide .ml files for .mli-only modules---without this, such modules do # not seem to be located by the type checker inside bytecode packs. @@ -171,6 +182,10 @@ COMPILERLIBS_SOURCES_INTFS=\ COMPILERLIBS_COPIED_SOURCES_INTFS=\ $(addsuffix i, $(COMPILERLIBS_COPIED_SOURCES)) +MINI_COMPILERLIBS_COPIED_SOURCES=\ + $(addprefix $(LOCAL_SRC)/, $(notdir $(MINI_COMPILERLIBS_SOURCES))) \ + $(addprefix $(LOCAL_SRC)/, $(notdir $(MINI_COMPILERLIBS_INTFS))) + # $(LOCAL_SRC)/Makefile uses the variables above in dependencies, so must be # include'd after they've been defined. -include $(LOCAL_SRC)/Makefile @@ -179,7 +194,7 @@ COMPILERLIBS_COPIED_SOURCES_INTFS=\ # that the resulting .cm{o,x} files can be packed. COMPILERLIBS_CMO=$(COMPILERLIBS_COPIED_SOURCES:.ml=.cmo) -COMPILERLIBS_CMX=$(COMPILERLIBS_COPIED_SOURCES:.ml=.cmx) +COMPILERLIBS_CMX=$(MINI_COMPILERLIBS_COPIED_SOURCES:.ml=.cmx) $(LOCAL_SRC)/%.cmi: $(LOCAL_SRC)/%.mli $(V_OCAMLC)$(OCAMLC) -c -for-pack Dynlink_compilerlibs $(COMPFLAGS) \