Skip to content

Commit

Permalink
Reduce the dependencies of native-code Dynlink
Browse files Browse the repository at this point in the history
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 c6d6e8b)
  • Loading branch information
xavierleroy committed Jan 26, 2024
1 parent 0c278a9 commit d74c57c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions otherlibs/dynlink/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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) \
Expand Down

0 comments on commit d74c57c

Please sign in to comment.