Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[win] Fix source build without pre-built deps #45712

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions deps/blastrampoline.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ BLASTRAMPOLINE_GIT_URL := https://github.com/JuliaLinearAlgebra/libblastrampolin
BLASTRAMPOLINE_TAR_URL = https://api.github.com/repos/JuliaLinearAlgebra/libblastrampoline/tarball/$1
$(eval $(call git-external,blastrampoline,BLASTRAMPOLINE,,,$(BUILDDIR)))

BLASTRAMPOLINE_BUILD_OPTS := $(MAKE_COMMON) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
BLASTRAMPOLINE_BUILD_OPTS += ARCH="$(ARCH)" OS="$(OS)"

$(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-configured: $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/source-extracted
mkdir -p $(dir $@)
echo 1 > $@

$(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-compiled: $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-configured
cd $(dir $@)/src && $(MAKE) $(MAKE_COMMON)
cd $(dir $@)/src && $(MAKE) $(BLASTRAMPOLINE_BUILD_OPTS)
ifeq ($(OS), WINNT)
# Windows doesn't like soft link, use hard link
cd $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/src/build/ && \
cp -f --dereference --link libblastrampoline.dll libblastrampoline.dll
endif
echo 1 > $@

define BLASTRAMPOLINE_INSTALL
$(MAKE) -C $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/src $(MAKE_COMMON) install DESTDIR="$2"
$(MAKE) -C $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/src install $(BLASTRAMPOLINE_BUILD_OPTS) DESTDIR="$2"
endef
$(eval $(call staged-install, \
blastrampoline,$(BLASTRAMPOLINE_SRC_DIR), \
Expand Down
9 changes: 7 additions & 2 deletions deps/curl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ $(BUILDDIR)/curl-$(CURL_VER)/build-configured: $(SRCCACHE)/curl-$(CURL_VER)/sour
--without-libidn2 --without-librtmp --without-nss --without-libpsl \
--disable-ldap --disable-ldaps --without-zsh-functions-dir --disable-static \
--with-libssh2=$(build_prefix) --with-zlib=$(build_prefix) --with-nghttp2=$(build_prefix) \
--enable-versioned-symbols \
$(CURL_TLS_CONFIGURE_FLAGS) \
CFLAGS="$(CFLAGS) $(CURL_CFLAGS)" LDFLAGS="$(LDFLAGS) $(CURL_LDFLAGS)"
echo 1 > $@

ifeq ($(OS), WINNT)
# keep version number
LIBTOOL_CCLD_VERSIONED := CCLD="$(CC) -no-undefined"
endif
$(BUILDDIR)/curl-$(CURL_VER)/build-compiled: $(BUILDDIR)/curl-$(CURL_VER)/build-configured
$(MAKE) -C $(dir $<) $(LIBTOOL_CCLD)
$(MAKE) -C $(dir $<) $(MAKE_COMMON) $(LIBTOOL_CCLD_VERSIONED)
echo 1 > $@

$(BUILDDIR)/curl-$(CURL_VER)/build-checked: $(BUILDDIR)/curl-$(CURL_VER)/build-compiled
Expand All @@ -69,7 +74,7 @@ endif

$(eval $(call staged-install, \
curl,curl-$$(CURL_VER), \
MAKE_INSTALL,$$(LIBTOOL_CCLD),, \
MAKE_INSTALL,$$(LIBTOOL_CCLD_VERSIONED),, \
$$(INSTALL_NAME_CMD)libcurl.$$(SHLIB_EXT) $$(build_shlibdir)/libcurl.$$(SHLIB_EXT)))

clean-curl:
Expand Down
2 changes: 2 additions & 0 deletions deps/gmp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ifeq ($(BUILD_OS),WINNT)
GMP_CONFIGURE_OPTS += --srcdir="$(subst \,/,$(call mingw_to_dos,$(SRCCACHE)/gmp-$(GMP_VER)))"
endif

GMP_CONFIGURE_OPTS += CC_FOR_BUILD=$(HOSTCC)

ifneq ($(USE_BINARYBUILDER_GMP),1)

$(SRCCACHE)/gmp-$(GMP_VER).tar.bz2: | $(SRCCACHE)
Expand Down
17 changes: 12 additions & 5 deletions deps/libgit2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,28 @@ ifeq ($(USE_SYSTEM_MBEDTLS), 0)
$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: | $(build_prefix)/manifest/mbedtls
endif

LIBGIT2_OPTS := $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DUSE_THREADS=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
LIBGIT2_OPTS := $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DTHREADSAFE=ON -DUSE_BUNDLED_ZLIB=ON
# no test
LIBGIT2_OPTS += -DBUILD_CLAR=OFF

# Special windows flags
ifeq ($(OS),WINNT)
LIBGIT2_OPTS += -DWIN32=ON -DMINGW=ON

ifneq ($(ARCH),x86_64)
ifneq ($(USECLANG),1)
LIBGIT2_OPTS += -DCMAKE_C_FLAGS="-mincoming-stack-boundary=2"
endif
endif

ifeq ($(BUILD_OS),WINNT)
LIBGIT2_OPTS += -G"MSYS Makefiles"
else
LIBGIT2_OPTS += -DBUILD_CLAR=OFF -DDLLTOOL=`which $(CROSS_COMPILE)dlltool`
LIBGIT2_OPTS += -DCMAKE_FIND_ROOT_PATH=/usr/$(XC_HOST) -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
endif
# build on *nix or cygwin
LIBGIT2_OPTS += -DDLLTOOL=`which $(CROSS_COMPILE)dlltool`
LIBGIT2_OPTS += -DCMAKE_FIND_ROOT_PATH=/usr/$(XC_HOST)/sys-root/mingw/ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
endif
endif # OS == WINNT

ifneq (,$(findstring $(OS),Linux FreeBSD))
LIBGIT2_OPTS += -DUSE_HTTPS="mbedTLS" -DUSE_SHA1="CollisionDetection" -DCMAKE_INSTALL_RPATH="\$$ORIGIN"
Expand Down Expand Up @@ -59,7 +66,7 @@ $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: $(LIBGIT2_SRC_PATH)/source-extr
echo 1 > $@

$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-compiled: $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured
$(MAKE) -C $(dir $<)
$(MAKE) -C $(dir $<) $(MAKE_COMMON)
echo 1 > $@

$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-checked: $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-compiled
Expand Down
9 changes: 8 additions & 1 deletion deps/libssh2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ $(LIBSSH2_SRC_PATH)/libssh2-userauth-check.patch-applied: $(LIBSSH2_SRC_PATH)/so
patch -p1 -f < $(SRCDIR)/patches/libssh2-userauth-check.patch
echo 1 > $@

# issue: https://github.com/JuliaLang/julia/issues/45645#issuecomment-1153214379
# fix pr: https://github.com/libssh2/libssh2/pull/711
$(LIBSSH2_SRC_PATH)/libssh2-fix-import-lib-name.patch-applied: $(LIBSSH2_SRC_PATH)/libssh2-userauth-check.patch-applied
cd $(LIBSSH2_SRC_PATH) && \
patch -p1 -f < $(SRCDIR)/patches/libssh2-fix-import-lib-name.patch
echo 1 > $@

$(BUILDDIR)/$(LIBSSH2_SRC_DIR)/build-configured: \
$(LIBSSH2_SRC_PATH)/libssh2-userauth-check.patch-applied
$(LIBSSH2_SRC_PATH)/libssh2-fix-import-lib-name.patch-applied

$(BUILDDIR)/$(LIBSSH2_SRC_DIR)/build-configured: $(LIBSSH2_SRC_PATH)/source-extracted
mkdir -p $(dir $@)
Expand Down
9 changes: 5 additions & 4 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ LLVM_CMAKE += -DCMAKE_EXE_LINKER_FLAGS="$(LLVM_LDFLAGS)" \
-DCMAKE_SHARED_LINKER_FLAGS="$(LLVM_LDFLAGS)"

# change the SONAME of Julia's private LLVM
# i.e. libLLVM-6.0jl.so
# i.e. libLLVM-13jl.[so|dll]
# see #32462
LLVM_CMAKE += -DLLVM_VERSION_SUFFIX:STRING="jl"
LLVM_CMAKE += -DLLVM_SHLIB_SYMBOL_VERSION:STRING="JL_LLVM_$(LLVM_VER_SHORT)"
LLVM_SHARED_LIB_NAME = libLLVM-$(LLVM_VER_MAJ)jl

# Apply version-specific LLVM patches sequentially
LLVM_PATCH_PREV :=
Expand Down Expand Up @@ -259,10 +260,10 @@ endif

LLVM_INSTALL = \
cd $1 && mkdir -p $2$$(build_depsbindir) && \
cp -r $$(SRCCACHE)/$$(LLVM_SRC_DIR)/llvm/utils/lit $2$$(build_depsbindir)/ && \
$$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake
cp -r $$(SRCCACHE)/$$(LLVM_SRC_DIR)/llvm/utils/lit $2$$(build_depsbindir)/ && \
$$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake
ifeq ($(OS), WINNT)
LLVM_INSTALL += && cp $2$$(build_shlibdir)/libLLVM.dll $2$$(build_depsbindir)
LLVM_INSTALL += && cp $2$$(build_shlibdir)/$(LLVM_SHARED_LIB_NAME).dll $2$$(build_depsbindir)
endif
ifeq ($(OS),Darwin)
# https://github.com/JuliaLang/julia/issues/29981
Expand Down
3 changes: 2 additions & 1 deletion deps/mbedtls.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ MBEDTLS_SRC = mbedtls-$(MBEDTLS_VER)
MBEDTLS_URL = https://github.com/ARMmbed/mbedtls/archive/v$(MBEDTLS_VER).tar.gz

MBEDTLS_OPTS := $(CMAKE_COMMON) -DUSE_SHARED_MBEDTLS_LIBRARY=ON \
-DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DENABLE_PROGRAMS=OFF -DCMAKE_BUILD_TYPE=Release
-DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DENABLE_PROGRAMS=OFF -DCMAKE_BUILD_TYPE=Release \
-DENABLE_TESTING=OFF

MBEDTLS_OPTS += -DENABLE_ZLIB_SUPPORT=OFF -DMBEDTLS_FATAL_WARNINGS=OFF
ifeq ($(BUILD_OS),WINNT)
Expand Down
8 changes: 7 additions & 1 deletion deps/p7zip.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ ifneq ($(USE_BINARYBUILDER_P7ZIP),1)
$(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz: | $(SRCCACHE)
$(JLDOWNLOAD) $@ https://github.com/jinfeihan57/p7zip/archive/refs/tags/v$(P7ZIP_VER).tar.gz

P7ZIP_BUILD_OPTS := $(MAKE_COMMON)
# Build with cygwin, not use cross build.
ifeq (,$(findstring CYGWIN,$(BUILD_OS)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unlikely this should care about the BUILD_OS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a workaround for cygwin.
I'm not sure if there is a better solution.

It's incredibly frustrating to build p7zip on mingw, so instead we just redistribute 7z
https://github.com/JuliaPackaging/Yggdrasil/blob/b2e0c2c5851b71230fb7170f74d773393ce37f80/P/p7zip/build_tarballs.jl#L21

In my case, on Windows, build p7zip with gcc on cygwin, works well.
But when cross build p7zip with x86_64-w64-mingw32-gcc it fails.

P7ZIP_BUILD_OPTS += CC="$(CC)" CXX="$(CXX)"
endif

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz
$(JLCHECKSUM) $<
mkdir -p $(dir $@)
Expand All @@ -17,7 +23,7 @@ checksum-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted
$(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-compiled: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured
$(MAKE) -C $(dir $<) $(MAKE_COMMON) CC="$(CC)" CXX="$(CXX)" 7za
$(MAKE) -C $(dir $<) $(P7ZIP_BUILD_OPTS) 7za
echo 1 > $@

define P7ZIP_INSTALL
Expand Down
26 changes: 26 additions & 0 deletions deps/patches/libssh2-fix-import-lib-name.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 3732420725efbf410df5863b91a09ca214ee18ba Mon Sep 17 00:00:00 2001
From: "Y. Yang" <[email protected]>
Date: Thu, 16 Jun 2022 19:16:37 +0800
Subject: [PATCH] Fix DLL import library name

https://aur.archlinux.org/packages/mingw-w64-libssh2
https://cmake.org/cmake/help/latest/prop_tgt/IMPORT_PREFIX.html
---
src/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cb8fee1..17ecefd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -220,6 +220,7 @@ endif()
add_library(libssh2 ${SOURCES})
# we want it to be called libssh2 on all platforms
set_target_properties(libssh2 PROPERTIES PREFIX "")
+set_target_properties(libssh2 PROPERTIES IMPORT_PREFIX "")

target_compile_definitions(libssh2 PRIVATE ${PRIVATE_COMPILE_DEFINITIONS})
target_include_directories(libssh2
--
2.36.1

2 changes: 1 addition & 1 deletion deps/zlib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(eval $(call git-external,zlib,ZLIB,,,$(SRCCACHE)))

$(BUILDDIR)/$(ZLIB_SRC_DIR)/build-configured: $(SRCCACHE)/$(ZLIB_SRC_DIR)/source-extracted
mkdir -p $(dir $@)
cd $(dir $@) && $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(abspath $(build_prefix)) -DCMAKE_BUILD_TYPE=Release -DUNIX=true $(dir $<)
cd $(dir $@) && $(CMAKE) $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DUNIX=true $(dir $<)
echo 1 > $@

$(BUILDDIR)/$(ZLIB_SRC_DIR)/build-compiled: $(BUILDDIR)/$(ZLIB_SRC_DIR)/build-configured
Expand Down