Skip to content

Commit 9578e4b

Browse files
authored
build: More msys2 fixes (#59028)
1 parent 5f0f2eb commit 9578e4b

File tree

10 files changed

+42
-22
lines changed

10 files changed

+42
-22
lines changed

contrib/mac/app/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ dmg/$(APP_NAME): startup.applescript julia.icns
4747
plutil -insert CFBundleVersion -string "$(JULIA_VERSION_OPT_COMMIT)" $@/Contents/Info.plist
4848
plutil -insert NSHumanReadableCopyright -string "$(APP_COPYRIGHT)" $@/Contents/Info.plist
4949
-mkdir -p $@/Contents/Resources/julia
50-
make -C $(JULIAHOME) binary-dist
50+
$(MAKE) -C $(JULIAHOME) binary-dist
5151
$(TAR) -xzf $(JULIAHOME)/$(JULIA_BINARYDIST_FILENAME).tar.gz -C $@/Contents/Resources/julia --strip-components 1
5252
find $@/Contents/Resources/julia -type f -exec chmod -w {} \;
5353
# Even though the tarball may already be signed, we re-sign here to make it easier to add

deps/libgit2.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ifneq ($(USE_BINARYBUILDER_LIBGIT2),1)
44
LIBGIT2_GIT_URL := https://github.com/libgit2/libgit2.git
55
LIBGIT2_TAR_URL = https://api.github.com/repos/libgit2/libgit2/tarball/$1
66
$(eval $(call git-external,libgit2,LIBGIT2,CMakeLists.txt,,$(SRCCACHE)))
7+
$(SRCCACHE)/$(LIBGIT2_SRC_DIR)/source-extracted: $(MSYS_NONEXISTENT_SYMLINK_TARGET_FIX)
78

89
ifeq ($(USE_SYSTEM_LIBSSH2), 0)
910
$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: | $(build_prefix)/manifest/libssh2
@@ -21,7 +22,7 @@ ifeq ($(USE_SYSTEM_ZLIB), 0)
2122
$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: | $(build_prefix)/manifest/zlib
2223
endif
2324

24-
LIBGIT2_OPTS := $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DUSE_THREADS=ON -DUSE_BUNDLED_ZLIB=OFF -DUSE_SSH=ON -DREGEX_BACKEND=pcre2 -DBUILD_CLI=OFF
25+
LIBGIT2_OPTS := $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DUSE_THREADS=ON -DUSE_BUNDLED_ZLIB=OFF -DUSE_SSH=ON -DREGEX_BACKEND=pcre2 -DBUILD_CLI=OFF -DBUILD_TESTS=OFF
2526
ifeq ($(OS),WINNT)
2627
LIBGIT2_OPTS += -DWIN32=ON -DMINGW=ON
2728
ifeq ($(USE_SYSTEM_LIBSSH2), 0)

deps/libssh2.mk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ endif
1717

1818
ifeq ($(OS),WINNT)
1919
LIBSSH2_OPTS += -DCRYPTO_BACKEND=WinCNG -DENABLE_ZLIB_COMPRESSION=OFF
20-
ifeq ($(BUILD_OS),WINNT)
21-
LIBSSH2_OPTS += -G"MSYS Makefiles"
22-
endif
2320
else
2421
LIBSSH2_OPTS += -DCRYPTO_BACKEND=OpenSSL -DENABLE_ZLIB_COMPRESSION=OFF
2522
endif
@@ -37,7 +34,7 @@ LIBSSH2_SRC_PATH := $(SRCCACHE)/$(LIBSSH2_SRC_DIR)
3734
$(BUILDDIR)/$(LIBSSH2_SRC_DIR)/build-configured: $(LIBSSH2_SRC_PATH)/source-extracted
3835
mkdir -p $(dir $@)
3936
cd $(dir $@) && \
40-
$(CMAKE) -G"Unix Makefiles" $(dir $<) $(LIBSSH2_OPTS)
37+
$(CMAKE) $(CMAKE_GENERATOR_COMMAND) $(dir $<) $(LIBSSH2_OPTS)
4138
echo 1 > $@
4239

4340
$(BUILDDIR)/$(LIBSSH2_SRC_DIR)/build-compiled: $(BUILDDIR)/$(LIBSSH2_SRC_DIR)/build-configured

deps/libuv.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LIBUV_GIT_URL:=https://github.com/JuliaLang/libuv.git
44
LIBUV_TAR_URL=https://api.github.com/repos/JuliaLang/libuv/tarball/$1
55
$(eval $(call git-external,libuv,LIBUV,configure,,$(SRCCACHE)))
66

7-
UV_CFLAGS := -O2
7+
UV_CFLAGS := -O2 -DBUILDING_UV_SHARED=1
88

99
UV_FLAGS := LDFLAGS="$(LDFLAGS) $(CLDFLAGS) -v"
1010
UV_FLAGS += CFLAGS="$(CFLAGS) $(UV_CFLAGS) $(SANITIZE_OPTS)"

deps/llvm.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $(eval $(call git-external,llvm,LLVM,CMakeLists.txt,,$(SRCCACHE)))
1414
# symlinks. We don't particularly care either way - we just need to symlinks
1515
# to succeed. We could guard this by a uname check, but it's harmless elsewhere,
1616
# so let's not incur the additional overhead.
17-
$(SRCCACHE)/$(LLVM_SRC_DIR)/source-extracted: export MSYS=winsymlinks:native
17+
$(SRCCACHE)/$(LLVM_SRC_DIR)/source-extracted: $(MSYS_NONEXISTENT_SYMLINK_TARGET_FIX)
1818

1919
LLVM_BUILDDIR := $(BUILDDIR)/$(LLVM_SRC_DIR)
2020
LLVM_BUILDDIR_withtype := $(LLVM_BUILDDIR)/build_$(LLVM_BUILDTYPE)

deps/openssl.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $(BUILDDIR)/openssl-$(OPENSSL_VER)/build-configured: $(SRCCACHE)/openssl-$(OPENS
5959
mkdir -p $(dir $@)
6060
cd $(dir $@) && \
6161
CC="$(CC) $(SANITIZE_OPTS)" CXX="$(CXX) $(SANITIZE_OPTS)" LDFLAGS="$(LDFLAGS) $(RPATH_ESCAPED_ORIGIN) $(SANITIZE_LDFLAGS)" \
62-
$(dir $<)/Configure shared --prefix=$(abspath $(build_prefix)) $(OPENSSL_TARGET)
62+
$(dir $<)/Configure shared --prefix=$(abspath $(build_prefix)) --libdir=$(abspath $(build_libdir)) $(OPENSSL_TARGET)
6363
echo 1 > $@
6464

6565
$(BUILDDIR)/openssl-$(OPENSSL_VER)/build-compiled: $(BUILDDIR)/openssl-$(OPENSSL_VER)/build-configured
@@ -72,9 +72,14 @@ ifeq ($(OS),$(BUILD_OS))
7272
endif
7373
echo 1 > $@
7474

75+
# Override bindir and only install runtime libraries, otherwise they'll go into build_depsbindir.
76+
OPENSSL_INSTALL = \
77+
mkdir -p $2$$(build_shlibdir) && \
78+
$$(MAKE) -C $1 install_runtime_libs $$(MAKE_COMMON) bindir=$$(build_shlibdir) $3 DESTDIR="$2"
79+
7580
$(eval $(call staged-install, \
7681
openssl,openssl-$(OPENSSL_VER), \
77-
MAKE_INSTALL,,, \
82+
OPENSSL_INSTALL,,, \
7883
$$(WIN_MAKE_HARD_LINK) $(build_bindir)/libcrypto-*.dll $(build_bindir)/libcrypto.dll && \
7984
$$(WIN_MAKE_HARD_LINK) $(build_bindir)/libssl-*.dll $(build_bindir)/libssl.dll && \
8085
$$(INSTALL_NAME_CMD)libcrypto.$$(SHLIB_EXT) $$(build_shlibdir)/libcrypto.$$(SHLIB_EXT) && \

deps/tools/common.mk

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ endif
7575
CMAKE_COMMON += -DCMAKE_RC_COMPILER="$$(which $(CROSS_COMPILE)windres)"
7676
endif
7777

78-
# For now this is LLVM specific, but I expect it won't be in the future
7978
ifeq ($(CMAKE_GENERATOR),Ninja)
8079
CMAKE_GENERATOR_COMMAND := -G Ninja
8180
else ifeq ($(CMAKE_GENERATOR),make)
@@ -84,14 +83,27 @@ else
8483
$(error Unknown CMake generator '$(CMAKE_GENERATOR)'. Options are 'Ninja' and 'make')
8584
endif
8685

87-
# Detect MSYS2 with cygwin CMake rather than MinGW cmake - the former fails to
88-
# properly drive MinGW tools
8986
ifneq (,$(findstring MINGW,$(RAW_BUILD_OS)))
9087
ifneq (,$(shell ldd $(shell which cmake) | grep msys-2.0.dll))
88+
# Detect MSYS2 with cygwin CMake rather than MinGW cmake - the former fails to
89+
# properly drive MinGW tools
9190
override CMAKE := echo "ERROR: CMake is Cygwin CMake, not MinGW CMake. Build will fail. Use 'pacman -S mingw-w64-{i686,x86_64}-cmake'."; exit 1; $(CMAKE)
9291
endif
92+
# In our setup, CMAKE_INSTALL_PREFIX is a relative path inside usr-staging.
93+
# We do not want this converted to a windows path, because our make system
94+
# assumes it to be relative to msys `/`.
95+
override CMAKE := MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX" $(CMAKE)
9396
endif
9497

98+
# Some dependencies' tarballs contains symlinks to non-existent targets. This breaks the
99+
# the default msys strategy `deepcopy` symlink strategy. To workaround this,
100+
# switch to `native` which tries native windows symlinks (possible if the
101+
# machine is in developer mode) - or if not, falls back to cygwin-style
102+
# symlinks. We don't particularly care either way - we just need to symlinks
103+
# to succeed. We could guard this by a uname check, but it's harmless elsewhere,
104+
# so let's not incur the additional overhead.
105+
MSYS_NONEXISTENT_SYMLINK_TARGET_FIX := export MSYS=winsymlinks:native
106+
95107
# If the top-level Makefile is called with environment variables,
96108
# they will override the values passed above to ./configure
97109
MAKE_COMMON := DESTDIR="" prefix=$(build_prefix) bindir=$(build_depsbindir) libdir=$(build_libdir) shlibdir=$(build_shlibdir) libexecdir=$(build_libexecdir) datarootdir=$(build_datarootdir) includedir=$(build_includedir) sysconfdir=$(build_sysconfdir) O=
@@ -168,7 +180,7 @@ upper = $(shell echo $1 | tr a-z A-Z)
168180
# this rule ensures that make install is more nearly atomic
169181
# so it's harder to get half-installed (or half-reinstalled) dependencies
170182
# # and enables sharing deps compiles, uninstall, and fast reinstall
171-
MAKE_INSTALL = +$$(MAKE) -C $1 install $$(MAKE_COMMON) $3 DESTDIR="$2"
183+
MAKE_INSTALL = MSYS2_ARG_CONV_EXCL="prefix=" $$(MAKE) -C $1 install $$(MAKE_COMMON) $3 DESTDIR="$2"
172184

173185
define SHLIBFILE_INSTALL
174186
mkdir -p $2/$$(build_shlibdir)

deps/zstd.mk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ ifneq ($(USE_BINARYBUILDER_ZSTD), 1)
33
ZSTD_GIT_URL := https://github.com/facebook/zstd.git
44
ZSTD_TAR_URL = https://api.github.com/repos/facebook/zstd/tarball/$1
55
$(eval $(call git-external,zstd,ZSTD,,,$(BUILDDIR)))
6-
# See note in llvm.mk for source tarballs with symlinks to non-existent targets
7-
$(BUILDDIR)/$(ZSTD_SRC_DIR)/source-extracted: export MSYS=winsymlinks:native
6+
$(BUILDDIR)/$(ZSTD_SRC_DIR)/source-extracted: $(MSYS_NONEXISTENT_SYMLINK_TARGET_FIX)
87

98
ZSTD_BUILD_OPTS := MOREFLAGS="-DZSTD_MULTITHREAD $(fPIC)" bindir=$(build_private_libexecdir)
9+
ifeq ($(OS), WINNT)
10+
# Zstd detects "Windows" not WINNT, ordinarily from the inherited $(OS), but it expects the
11+
# override to be done using TARGET_SYSTEM.
12+
ZSTD_BUILD_OPTS += TARGET_SYSTEM="Windows"
13+
endif
1014

1115
$(BUILDDIR)/$(ZSTD_SRC_DIR)/build-configured: $(BUILDDIR)/$(ZSTD_SRC_DIR)/source-extracted
1216
echo 1 > $@

src/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ else
7777
GC_CODEGEN_SRCS += llvm-late-gc-lowering-stock
7878
endif
7979
CODEGEN_SRCS := codegen jitlayers aotcompile debuginfo disasm llvm-simdloop \
80-
llvm-pass-helpers llvm-ptls llvm-propagate-addrspaces null_sysimage \
80+
llvm-pass-helpers llvm-ptls llvm-propagate-addrspaces \
8181
llvm-multiversioning llvm-alloc-opt llvm-alloc-helpers cgmemmgr llvm-remove-addrspaces \
8282
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures llvm-expand-atomic-modify \
8383
pipeline llvm_api \
@@ -198,6 +198,7 @@ endif
198198

199199
COMMON_LIBPATHS := -L$(build_libdir) -L$(build_shlibdir)
200200
RT_LIBS := $(WHOLE_ARCHIVE) $(LIBUV) $(WHOLE_ARCHIVE) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LIBUNWIND) $(RT_LLVMLINK) $(OSLIBS) $(LIBTRACYCLIENT) $(LIBITTAPI)
201+
# NB: CG needs uv_mutex_* symbols, but we expect to export them from libjulia-internal
201202
CG_LIBS := $(LIBUNWIND) $(CG_LLVMLINK) $(OSLIBS) $(LIBTRACYCLIENT) $(LIBITTAPI)
202203

203204
ifeq (${USE_THIRD_PARTY_GC},mmtk)
@@ -494,10 +495,10 @@ libjulia-codegen-debug: $(build_shlibdir)/libjulia-codegen-debug.$(JL_MAJOR_MINO
494495
libjulia-codegen-debug libjulia-codegen-release: $(PUBLIC_HEADER_TARGETS)
495496

496497
# set the exports for the source files based on where they are getting linked
497-
$(OBJS): SHIPFLAGS += -DJL_LIBRARY_EXPORTS_INTERNAL
498-
$(DOBJS): DEBUGFLAGS += -DJL_LIBRARY_EXPORTS_INTERNAL
499-
$(CODEGEN_OBJS): SHIPFLAGS += -DJL_LIBRARY_EXPORTS_CODEGEN
500-
$(CODEGEN_DOBJS): DEBUGFLAGS += -DJL_LIBRARY_EXPORTS_CODEGEN
498+
$(OBJS): SHIPFLAGS += -DJL_LIBRARY_EXPORTS_INTERNAL -DBUILDING_UV_SHARED
499+
$(DOBJS): DEBUGFLAGS += -DJL_LIBRARY_EXPORTS_INTERNAL -DBUILDING_UV_SHARED
500+
$(CODEGEN_OBJS): SHIPFLAGS += -DJL_LIBRARY_EXPORTS_CODEGEN -DUSING_UV_SHARED
501+
$(CODEGEN_DOBJS): DEBUGFLAGS += -DJL_LIBRARY_EXPORTS_CODEGEN -DUSING_UV_SHARED
501502

502503
clean:
503504
-rm -fr $(build_shlibdir)/libjulia-internal* $(build_shlibdir)/libjulia-codegen* $(build_shlibdir)/libccalltest* $(build_shlibdir)/libllvmcalltest*

src/flisp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ $(BUILDDIR)/host/Makefile:
117117
@printf "%s\n" 'include $(SRCDIR)/Makefile' >> $@
118118

119119
$(BUILDDIR)/host/$(EXENAME): $(BUILDDIR)/host/Makefile | ${BUILDDIR}/host/flisp.boot
120-
make -C $(BUILDDIR)/host $(EXENAME)
120+
$(MAKE) -C $(BUILDDIR)/host $(EXENAME)
121121

122122

123123
$(BUILDDIR)/host/flisp.boot: $(SRCDIR)/flisp.boot | $(BUILDDIR)/host/Makefile

0 commit comments

Comments
 (0)