Skip to content

Commit b9865b7

Browse files
authored
Merge pull request #47958 from JuliaLang/sf/win-1.6-fixes
[backports-1.6] [win] fixes for msys2 build system
2 parents 98f8585 + 24e766a commit b9865b7

File tree

4 files changed

+80
-13
lines changed

4 files changed

+80
-13
lines changed

Make.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ LLVM_CONFIG_PATH_FIX := PATH="$(build_bindir):$(PATH)"
10581058
endif
10591059

10601060
ifeq ($(BUILD_OS),$(OS))
1061-
LLVM_CONFIG_HOST := $(LLVM_CONFIG)
1061+
LLVM_CONFIG_HOST := $(LLVM_CONFIG_PATH_FIX) $(LLVM_CONFIG)
10621062
else
10631063
LLVM_CONFIG_HOST := $(basename $(LLVM_CONFIG))-host$(BUILD_EXE)
10641064
ifeq (exists, $(shell [ -f '$(LLVM_CONFIG_HOST)' ] && echo exists ))
@@ -1497,13 +1497,13 @@ define symlink_target # (from, to-dir, to-name)
14971497
CLEAN_TARGETS += clean-$$(abspath $(2)/$(3))
14981498
clean-$$(abspath $(2)/$(3)):
14991499
ifeq ($(BUILD_OS), WINNT)
1500-
-cmd //C rmdir $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&)
1500+
-cmd //C rmdir $$(call cygpath_w,$(2)/$(3))
15011501
else
15021502
-rm -r $$(abspath $(2)/$(3))
15031503
endif
15041504
$$(abspath $(2)/$(3)): | $$(abspath $(2))
15051505
ifeq ($$(BUILD_OS), WINNT)
1506-
@cmd //C mklink //J $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&) $$(call mingw_to_dos,$(1),)
1506+
@cmd //C mklink //J $$(call cygpath_w,$(2)/$(3)) $$(call cygpath_w,$(1))
15071507
else ifneq (,$$(findstring CYGWIN,$$(BUILD_OS)))
15081508
@cmd /C mklink /J $$(call cygpath_w,$(2)/$(3)) $$(call cygpath_w,$(1))
15091509
else ifdef JULIA_VAGRANT_BUILD
@@ -1518,7 +1518,7 @@ endef
15181518
# many of the following targets must be = not := because the expansion of the makefile functions (and $1) shouldn't happen until later
15191519
ifeq ($(BUILD_OS), WINNT) # MSYS
15201520
spawn = $(1)
1521-
cygpath_w = $(1)
1521+
cygpath_w = `cygpath -w $(1)`
15221522
else ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # Cygwin
15231523
spawn = $(1)
15241524
cygpath_w = `cygpath -w $(1)`

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,10 @@ endif
221221
endif
222222
endif
223223

224+
# Note that we disable MSYS2's path munging here, as otherwise
225+
# it replaces our `:`-separated list as a `;`-separated one.
224226
define stringreplace
225-
$(build_depsbindir)/stringreplace $$(strings -t x - $1 | grep $2 | awk '{print $$1;}') $3 255 "$(call cygpath_w,$1)"
227+
MSYS2_ARG_CONV_EXCL='*' $(build_depsbindir)/stringreplace $$(strings -t x - $1 | grep $2 | awk '{print $$1;}') $3 255 "$(call cygpath_w,$1)"
226228
endef
227229

228230

@@ -430,8 +432,9 @@ endif
430432
cd $(BUILDROOT) && $(TAR) zcvf $(JULIA_BINARYDIST_FILENAME).tar.gz julia-$(JULIA_COMMIT)
431433

432434
exe:
433-
# run Inno Setup to compile installer
434-
$(call spawn,$(JULIAHOME)/dist-extras/inno/iscc.exe /DAppVersion=$(JULIA_VERSION) /DSourceDir="$(call cygpath_w,$(BUILDROOT)/julia-$(JULIA_COMMIT))" /DRepoDir="$(call cygpath_w,$(JULIAHOME))" /F"$(JULIA_BINARYDIST_FILENAME)" /O"$(call cygpath_w,$(BUILDROOT))" $(INNO_ARGS) $(call cygpath_w,$(JULIAHOME)/contrib/windows/build-installer.iss))
435+
# run Inno Setup to compile installer.
436+
# Note that we disable MSYS2 path munging, as it interferes with the `/` options:
437+
MSYS2_ARG_CONV_EXCL='*' $(call spawn,$(JULIAHOME)/dist-extras/inno/iscc.exe /DAppVersion=$(JULIA_VERSION) /DSourceDir="$(call cygpath_w,$(BUILDROOT)/julia-$(JULIA_COMMIT))" /DRepoDir="$(call cygpath_w,$(JULIAHOME))" /F"$(JULIA_BINARYDIST_FILENAME)" /O"$(call cygpath_w,$(BUILDROOT))" $(INNO_ARGS) $(call cygpath_w,$(JULIAHOME)/contrib/windows/build-installer.iss))
435438
chmod a+x "$(BUILDROOT)/$(JULIA_BINARYDIST_FILENAME).exe"
436439

437440
app:
@@ -556,7 +559,7 @@ win-extras:
556559
cd $(JULIAHOME)/dist-extras && \
557560
$(JLDOWNLOAD) https://www.jrsoftware.org/download.php/is.exe && \
558561
chmod a+x is.exe && \
559-
$(call spawn, $(JULIAHOME)/dist-extras/is.exe /DIR="$(call cygpath_w,$(JULIAHOME)/dist-extras/inno)" /PORTABLE=1 /CURRENTUSER /VERYSILENT)
562+
MSYS2_ARG_CONV_EXCL='*' $(call spawn, $(JULIAHOME)/dist-extras/is.exe /DIR="$(call cygpath_w,$(JULIAHOME)/dist-extras/inno)" /PORTABLE=1 /CURRENTUSER /VERYSILENT)
560563

561564
# various statistics about the build that may interest the user
562565
ifeq ($(USE_SYSTEM_LLVM), 1)

cli/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ endif
2929
# Build list of dependent libraries that must be opened
3030
SHIPFLAGS += -DDEP_LIBS="\"$(LOADER_BUILD_DEP_LIBS)\""
3131
DEBUGFLAGS += -DDEP_LIBS="\"$(LOADER_DEBUG_BUILD_DEP_LIBS)\""
32+
ifneq (,$(findstring MINGW,$(shell uname)))
33+
# In MSYS2, do not perform path conversion for `DEP_LIBS`.
34+
# https://www.msys2.org/wiki/Porting/#filesystem-namespaces
35+
# We define this environment variable for only these two object files,
36+
# as they're the only ones that require it at the time of writing.
37+
$(BUILDDIR)/loader_lib.o: export MSYS2_ARG_CONV_EXCL = -DDEP_LIBS=
38+
$(BUILDDIR)/loader_lib.dbg.obj: export MSYS2_ARG_CONV_EXCL = -DDEP_LIBS=
39+
endif # MSYS2
3240

3341
EXE_OBJS := $(BUILDDIR)/loader_exe.o
3442
EXE_DOBJS := $(BUILDDIR)/loader_exe.dbg.obj

doc/build/windows.md

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,67 @@ MinGW-w64 compilers available through Cygwin's package manager.
118118

119119
### Compiling with MinGW/MSYS2
120120

121-
Compiling Julia from source using [MSYS2](https://msys2.github.io) has worked
122-
in the past but is not actively supported. Pull requests to restore support
123-
would be welcome. See a [past version of this file](
124-
https://github.com/JuliaLang/julia/blob/v0.6.0/README.windows.md)
125-
for the former instructions for compiling using MSYS2.
121+
> MSYS2 provides a robust MSYS experience.
122+
123+
Note: MSYS2 requires **64 bit** Windows 7 or newer.
124+
125+
1. Install and configure [MSYS2](https://www.msys2.org/), Software Distribution
126+
and Building Platform for Windows.
127+
128+
1. Download and run the latest installer for the
129+
[64-bit](https://github.com/msys2/msys2-installer/releases/latest) distribution.
130+
The installer will have a name like `msys2-x86_64-yyyymmdd.exe`.
131+
132+
2. Open MSYS2. Update package database and base packages:
133+
```sh
134+
pacman -Syu
135+
```
136+
137+
3. Exit and restart MSYS2, Update the rest of the base packages:
138+
```sh
139+
pacman -Syu
140+
```
141+
142+
3. Then install tools required to build julia:
143+
```sh
144+
# tools
145+
pacman -S cmake diffutils git m4 make patch tar p7zip curl python
146+
147+
# For 64 bit Julia, install x86_64
148+
pacman -S mingw-w64-x86_64-gcc
149+
# For 32 bit Julia, install i686
150+
pacman -S mingw-w64-i686-gcc
151+
```
152+
153+
4. Configuration of MSYS2 is complete. Now `exit` the MSYS2 shell.
154+
155+
156+
2. Build Julia and its dependencies with pre-build dependencies.
157+
158+
1. Open a new [**MINGW64/MINGW32 shell**](https://www.msys2.org/docs/environments/#overview).
159+
Currently we can't use both mingw32 and mingw64,
160+
so if you want to build the x86_64 and i686 versions,
161+
you'll need to build them in each environment separately.
162+
163+
2. and clone the Julia sources
164+
```sh
165+
git clone https://github.com/JuliaLang/julia.git
166+
cd julia
167+
```
168+
169+
3. Start the build
170+
```sh
171+
make -j$(nproc)
172+
```
173+
174+
> Protip: build in dir
175+
> ```sh
176+
> make O=julia-mingw-w64 configure
177+
> echo 'ifeq ($(BUILDROOT),$(JULIAHOME))
178+
> $(error "in-tree build disabled")
179+
> endif' >> Make.user
180+
> make -C julia-mingw-w64
181+
> ```
126182

127183

128184
### Cross-compiling from Unix

0 commit comments

Comments
 (0)