@@ -464,6 +464,11 @@ include shared.mak
464464#
465465# CURL_LDFLAGS=-lcurl
466466#
467+ # Define LAZYLOAD_LIBCURL to dynamically load the libcurl; This can be useful
468+ # if Multiple libcurl versions exist (with different file names) that link to
469+ # various SSL/TLS backends, to support the `http.sslBackend` runtime switch in
470+ # such a scenario.
471+ #
467472# === Optional library: libpcre2 ===
468473#
469474# Define USE_LIBPCRE if you have and want to use libpcre. Various
@@ -1325,6 +1330,7 @@ BUILTIN_OBJS += builtin/write-tree.o
13251330# upstream unnecessarily (making merging in future changes easier).
13261331THIRD_PARTY_SOURCES += compat/inet_ntop.c
13271332THIRD_PARTY_SOURCES += compat/inet_pton.c
1333+ THIRD_PARTY_SOURCES += compat/mimalloc/%
13281334THIRD_PARTY_SOURCES += compat/nedmalloc/%
13291335THIRD_PARTY_SOURCES += compat/obstack.%
13301336THIRD_PARTY_SOURCES += compat/poll/%
@@ -1598,10 +1604,23 @@ else
15981604 CURL_LIBCURL =
15991605 endif
16001606
1601- ifndef CURL_LDFLAGS
1602- CURL_LDFLAGS = $(eval CURL_LDFLAGS := $$(shell $$(CURL_CONFIG) --libs))$(CURL_LDFLAGS)
1607+ ifdef LAZYLOAD_LIBCURL
1608+ LAZYLOAD_LIBCURL_OBJ = compat/lazyload-curl.o
1609+ OBJECTS += $(LAZYLOAD_LIBCURL_OBJ)
1610+ # The `CURL_STATICLIB` constant must be defined to avoid seeing the functions
1611+ # declared as DLL imports
1612+ CURL_CFLAGS = -DCURL_STATICLIB
1613+ ifneq ($(uname_S ) ,MINGW)
1614+ ifneq ($(uname_S ) ,Windows)
1615+ CURL_LIBCURL = -ldl
1616+ endif
1617+ endif
1618+ else
1619+ ifndef CURL_LDFLAGS
1620+ CURL_LDFLAGS = $(eval CURL_LDFLAGS := $$(shell $$(CURL_CONFIG) --libs))$(CURL_LDFLAGS)
1621+ endif
1622+ CURL_LIBCURL += $(CURL_LDFLAGS)
16031623 endif
1604- CURL_LIBCURL += $(CURL_LDFLAGS)
16051624
16061625 ifndef CURL_CFLAGS
16071626 CURL_CFLAGS = $(eval CURL_CFLAGS := $$(shell $$(CURL_CONFIG) --cflags))$(CURL_CFLAGS)
@@ -1622,7 +1641,7 @@ else
16221641 endif
16231642 ifdef USE_CURL_FOR_IMAP_SEND
16241643 BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND
1625- IMAP_SEND_BUILDDEPS = http.o
1644+ IMAP_SEND_BUILDDEPS = http.o $(LAZYLOAD_LIBCURL_OBJ)
16261645 IMAP_SEND_LDFLAGS += $(CURL_LIBCURL)
16271646 endif
16281647 ifndef NO_EXPAT
@@ -2053,6 +2072,41 @@ ifdef USE_NED_ALLOCATOR
20532072 OVERRIDE_STRDUP = YesPlease
20542073endif
20552074
2075+ ifdef USE_MIMALLOC
2076+ MIMALLOC_OBJS = \
2077+ compat/mimalloc/alloc-aligned.o \
2078+ compat/mimalloc/alloc.o \
2079+ compat/mimalloc/arena.o \
2080+ compat/mimalloc/bitmap.o \
2081+ compat/mimalloc/heap.o \
2082+ compat/mimalloc/init.o \
2083+ compat/mimalloc/options.o \
2084+ compat/mimalloc/os.o \
2085+ compat/mimalloc/page.o \
2086+ compat/mimalloc/random.o \
2087+ compat/mimalloc/segment.o \
2088+ compat/mimalloc/segment-cache.o \
2089+ compat/mimalloc/stats.o
2090+
2091+ COMPAT_CFLAGS += -Icompat/mimalloc -DMI_DEBUG=0 -DUSE_MIMALLOC --std=gnu11
2092+ COMPAT_OBJS += $(MIMALLOC_OBJS)
2093+
2094+ $(MIMALLOC_OBJS ) : COMPAT_CFLAGS += -DBANNED_H
2095+
2096+ $(MIMALLOC_OBJS ) : COMPAT_CFLAGS += \
2097+ -Wno-attributes \
2098+ -Wno-unknown-pragmas \
2099+ -Wno-array-bounds
2100+
2101+ ifdef DEVELOPER
2102+ $(MIMALLOC_OBJS ) : COMPAT_CFLAGS += \
2103+ -Wno-pedantic \
2104+ -Wno-declaration-after-statement \
2105+ -Wno-old-style-definition \
2106+ -Wno-missing-prototypes
2107+ endif
2108+ endif
2109+
20562110ifdef OVERRIDE_STRDUP
20572111 COMPAT_CFLAGS += -DOVERRIDE_STRDUP
20582112 COMPAT_OBJS += compat/strdup.o
@@ -2779,17 +2833,24 @@ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
27792833compat/nedmalloc/nedmalloc.sp : SP_EXTRA_FLAGS += -Wno-non-pointer-null
27802834endif
27812835
2836+ headless-git.o : compat/win32/headless.c GIT-CFLAGS
2837+ $(QUIET_CC )$(CC ) $(ALL_CFLAGS ) $(COMPAT_CFLAGS ) \
2838+ -fno-stack-protector -o $@ -c -Wall -Wwrite-strings $<
2839+
2840+ headless-git$X : headless-git.o git.res GIT-LDFLAGS
2841+ $(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) $(ALL_LDFLAGS ) -mwindows -o $@ $< git.res
2842+
27822843git-% $X : % .o GIT-LDFLAGS $(GITLIBS )
27832844 $(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) $(LIBS )
27842845
27852846git-imap-send$X : imap-send.o $(IMAP_SEND_BUILDDEPS ) GIT-LDFLAGS $(GITLIBS )
27862847 $(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
27872848 $(IMAP_SEND_LDFLAGS ) $(LIBS )
27882849
2789- git-http-fetch$X : http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS )
2850+ git-http-fetch$X : http.o http-walker.o http-fetch.o $( LAZYLOAD_LIBCURL_OBJ ) GIT-LDFLAGS $(GITLIBS )
27902851 $(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
27912852 $(CURL_LIBCURL ) $(LIBS )
2792- git-http-push$X : http.o http-push.o GIT-LDFLAGS $(GITLIBS )
2853+ git-http-push$X : http.o http-push.o $( LAZYLOAD_LIBCURL_OBJ ) GIT-LDFLAGS $(GITLIBS )
27932854 $(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
27942855 $(CURL_LIBCURL ) $(EXPAT_LIBEXPAT ) $(LIBS )
27952856
@@ -2799,7 +2860,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
27992860 ln -s $< $@ 2> /dev/null || \
28002861 cp $< $@
28012862
2802- $(REMOTE_CURL_PRIMARY ) : remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS )
2863+ $(REMOTE_CURL_PRIMARY ) : remote-curl.o http.o http-walker.o $( LAZYLOAD_LIBCURL_OBJ ) GIT-LDFLAGS $(GITLIBS )
28032864 $(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
28042865 $(CURL_LIBCURL ) $(EXPAT_LIBEXPAT ) $(LIBS )
28052866
@@ -3652,6 +3713,7 @@ clean: profile-clean coverage-clean cocciclean
36523713 $(RM ) po/git.pot po/git-core.pot
36533714 $(RM ) git.res
36543715 $(RM ) $(OBJECTS )
3716+ $(RM ) headless-git.o
36553717 $(RM ) $(LIB_FILE ) $(XDIFF_LIB ) $(REFTABLE_LIB ) $(REFTABLE_TEST_LIB )
36563718 $(RM ) $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) $(OTHER_PROGRAMS )
36573719 $(RM ) $(TEST_PROGRAMS )
@@ -3680,13 +3742,17 @@ endif
36803742 $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS
36813743ifdef MSVC
36823744 $(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
3745+ $(RM) headless-git.o.pdb
36833746 $(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
3747+ $(RM) $(patsubst %.exe,%.ilk,$(OTHER_PROGRAMS))
36843748 $(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))
36853749 $(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))
36863750 $(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))
3751+ $(RM) $(patsubst %.exe,%.ilk,$(PROGRAMS))
36873752 $(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))
36883753 $(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))
36893754 $(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))
3755+ $(RM) $(patsubst %.exe,%.ilk,$(TEST_PROGRAMS))
36903756 $(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))
36913757 $(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))
36923758 $(RM) compat/vcbuild/MSVC-DEFS-GEN
0 commit comments