From c62686b1caeacc70ad880ffee2bcf7b2d671b8be Mon Sep 17 00:00:00 2001 From: woclass Date: Fri, 22 Jul 2022 15:16:59 +0800 Subject: [PATCH 1/7] Makefile: MSYS2: close path conversion for `DEP_LIBS` Automatic path conversion will replace `:` with `;` --- cli/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/Makefile b/cli/Makefile index e5298a8da7619..ad681f5afba21 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -28,6 +28,13 @@ endif # Build list of dependent libraries that must be opened SHIPFLAGS += -DDEP_LIBS="\"$(LOADER_BUILD_DEP_LIBS)\"" DEBUGFLAGS += -DDEP_LIBS="\"$(LOADER_DEBUG_BUILD_DEP_LIBS)\"" +ifneq (,$(findstring MINGW,$(shell uname))) +# In MSYS2, do not perform path conversion for `DEP_LIBS`. +# https://www.msys2.org/wiki/Porting/#filesystem-namespaces +CC_WITH_ENV := MSYS2_ARG_CONV_EXCL="-DDEP_LIBS=" $(CC) +else +CC_WITH_ENV := $(CC) +endif # in MSYS2? EXE_OBJS := $(BUILDDIR)/loader_exe.o EXE_DOBJS := $(BUILDDIR)/loader_exe.dbg.obj @@ -45,9 +52,9 @@ all: release debug release debug : % : julia-% libjulia-% $(BUILDDIR)/loader_lib.o : $(SRCDIR)/loader_lib.c $(HEADERS) $(JULIAHOME)/VERSION - @$(call PRINT_CC, $(CC) -DLIBRARY_EXPORTS $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@) + @$(call PRINT_CC, $(CC_WITH_ENV) -DLIBRARY_EXPORTS $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_lib.dbg.obj : $(SRCDIR)/loader_lib.c $(HEADERS) $(JULIAHOME)/VERSION - @$(call PRINT_CC, $(CC) -DLIBRARY_EXPORTS $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@) + @$(call PRINT_CC, $(CC_WITH_ENV) -DLIBRARY_EXPORTS $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_exe.o : $(SRCDIR)/loader_exe.c $(HEADERS) $(JULIAHOME)/VERSION @$(call PRINT_CC, $(CC) $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_exe.dbg.obj : $(SRCDIR)/loader_exe.c $(HEADERS) $(JULIAHOME)/VERSION From 7d951ae5feda33f2a391f83e1dd516afdd5a275d Mon Sep 17 00:00:00 2001 From: woclass Date: Fri, 22 Jul 2022 15:21:08 +0800 Subject: [PATCH 2/7] Makefile: MSYS2: use `cygpath` for path convert ref: https://www.msys2.org/docs/filesystem-paths/#manual-unix-windows-path-conversion --- Make.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Make.inc b/Make.inc index 1b223b245a56b..039add362b65e 100644 --- a/Make.inc +++ b/Make.inc @@ -1394,13 +1394,13 @@ define symlink_target # (from, to-dir, to-name) CLEAN_TARGETS += clean-$$(abspath $(2)/$(3)) clean-$$(abspath $(2)/$(3)): ifeq ($(BUILD_OS), WINNT) - -cmd //C rmdir $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&) + -cmd //C rmdir $$(call cygpath_w,$(2)/$(3)) else rm -rf $$(abspath $(2)/$(3)) endif $$(abspath $(2)/$(3)): | $$(abspath $(2)) ifeq ($$(BUILD_OS), WINNT) - @cmd //C mklink //J $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&) $$(call mingw_to_dos,$(1),) + @cmd //C mklink //J $$(call cygpath_w,$(2)/$(3)) $$(call cygpath_w,$(1)) else ifneq (,$$(findstring CYGWIN,$$(BUILD_OS))) @cmd /C mklink /J $$(call cygpath_w,$(2)/$(3)) $$(call cygpath_w,$(1)) else ifdef JULIA_VAGRANT_BUILD @@ -1418,7 +1418,7 @@ WINE ?= wine # many of the following targets must be = not := because the expansion of the makefile functions (and $1) shouldn't happen until later ifeq ($(BUILD_OS), WINNT) # MSYS spawn = $(1) -cygpath_w = $(1) +cygpath_w = `cygpath -w $(1)` else ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # Cygwin spawn = $(1) cygpath_w = `cygpath -w $(1)` From 06efda6e45e7e796d924306f07edd4aa2eb8cbb8 Mon Sep 17 00:00:00 2001 From: woclass Date: Sun, 24 Jul 2022 06:32:05 +0800 Subject: [PATCH 3/7] devdoc/win/msys2: add build steps --- doc/src/devdocs/build/windows.md | 54 +++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/doc/src/devdocs/build/windows.md b/doc/src/devdocs/build/windows.md index fef4413db7d1a..91582de293c1c 100644 --- a/doc/src/devdocs/build/windows.md +++ b/doc/src/devdocs/build/windows.md @@ -118,11 +118,55 @@ MinGW-w64 compilers available through Cygwin's package manager. ### Compiling with MinGW/MSYS2 -Compiling Julia from source using [MSYS2](https://msys2.github.io) has worked in the past -but is not actively supported. Pull requests to restore support would be welcome. See a -[past version of this -file](https://github.com/JuliaLang/julia/blob/v0.6.0/README.windows.md) for the former -instructions for compiling using MSYS2. +> MSYS2 provides a robust MSYS experience. + +Note: MSYS2 requires **64 bit** Windows 7 or newer. + + 1. Install and configure [MSYS2](https://www.msys2.org/), Software Distribution + and Building Platform for Windows. + + 1. Download and run the latest installer for the + [64-bit](https://github.com/msys2/msys2-installer/releases/latest) distribution. + The installer will have a name like `msys2-x86_64-yyyymmdd.exe`. + + 2. Open MSYS2. Update package database and base packages: + ```sh + pacman -Syu + ``` + + 3. Exit and restart MSYS2, Update the rest of the base packages: + ```sh + pacman -Syu + ``` + + 3. Then install tools required to build julia: + ```sh + # tools + pacman -S cmake diffutils git m4 make patch tar p7zip curl python + + # For 64 bit Julia, install x86_64 + pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran + # For 32 bit Julia, install i686 + pacman -S mingw-w64-i686-gcc mingw-w64-i686-gcc-fortran + ``` + + 4. Configuration of MSYS2 is complete. Now `exit` the MSYS2 shell. + + + 2. Build Julia and its dependencies with pre-build dependencies. + + 1. Open a new [**MINGW64/32 shell**](https://www.msys2.org/docs/environments/#overview) + and clone the Julia sources + ```sh + git clone https://github.com/JuliaLang/julia.git + cd julia + ``` + + 2. Start the build + ```sh + # Adjust the number of cores (4) to match your build environment. + make -j 4 + ``` ### Cross-compiling from Unix (Linux/Mac/WSL) From c7ff32668c76500737dc9a83fcc747be86b00051 Mon Sep 17 00:00:00 2001 From: woclass Date: Thu, 28 Jul 2022 15:49:39 +0800 Subject: [PATCH 4/7] devdoc/win/msys2: Add x86/x64 build notes --- doc/src/devdocs/build/windows.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/src/devdocs/build/windows.md b/doc/src/devdocs/build/windows.md index 91582de293c1c..e1fa8dae71999 100644 --- a/doc/src/devdocs/build/windows.md +++ b/doc/src/devdocs/build/windows.md @@ -155,19 +155,32 @@ Note: MSYS2 requires **64 bit** Windows 7 or newer. 2. Build Julia and its dependencies with pre-build dependencies. - 1. Open a new [**MINGW64/32 shell**](https://www.msys2.org/docs/environments/#overview) - and clone the Julia sources + 1. Open a new [**MINGW64/MINGW32 shell**](https://www.msys2.org/docs/environments/#overview). + Currently we can't use both mingw32 and mingw64, + so if you want to build the x86_64 and i686 versions, + you'll need to build them in each environment separately. + + 2. and clone the Julia sources ```sh git clone https://github.com/JuliaLang/julia.git cd julia ``` - 2. Start the build + 3. Start the build ```sh # Adjust the number of cores (4) to match your build environment. make -j 4 ``` + > Protip: build in dir + > ```sh + > make O=julia-mingw-w64 configure + > echo 'ifeq ($(BUILDROOT),$(JULIAHOME)) + > $(error "in-tree build disabled") + > endif' >> Make.user + > make -C julia-mingw-w64 + > ``` + ### Cross-compiling from Unix (Linux/Mac/WSL) From 89e033362f37964fd09e804a3491959f30b39f6d Mon Sep 17 00:00:00 2001 From: woclass Date: Fri, 5 Aug 2022 00:48:15 +0800 Subject: [PATCH 5/7] devdoc/win/msys2: apply sugestions Co-Authored-By: Elliot Saba --- doc/src/devdocs/build/windows.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/src/devdocs/build/windows.md b/doc/src/devdocs/build/windows.md index e1fa8dae71999..61088380ff59a 100644 --- a/doc/src/devdocs/build/windows.md +++ b/doc/src/devdocs/build/windows.md @@ -145,9 +145,9 @@ Note: MSYS2 requires **64 bit** Windows 7 or newer. pacman -S cmake diffutils git m4 make patch tar p7zip curl python # For 64 bit Julia, install x86_64 - pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran + pacman -S mingw-w64-x86_64-gcc # For 32 bit Julia, install i686 - pacman -S mingw-w64-i686-gcc mingw-w64-i686-gcc-fortran + pacman -S mingw-w64-i686-gcc ``` 4. Configuration of MSYS2 is complete. Now `exit` the MSYS2 shell. @@ -168,8 +168,7 @@ Note: MSYS2 requires **64 bit** Windows 7 or newer. 3. Start the build ```sh - # Adjust the number of cores (4) to match your build environment. - make -j 4 + make -j$(nproc) ``` > Protip: build in dir From adfaff911b95bfa7b3b6409a4b7a91f4bc543042 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Wed, 14 Sep 2022 11:49:45 -0700 Subject: [PATCH 6/7] Instead of `CC_WITH_ENV`, scope environment variables to targets --- cli/Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cli/Makefile b/cli/Makefile index ad681f5afba21..274877ecaf12a 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -31,10 +31,11 @@ DEBUGFLAGS += -DDEP_LIBS="\"$(LOADER_DEBUG_BUILD_DEP_LIBS)\"" ifneq (,$(findstring MINGW,$(shell uname))) # In MSYS2, do not perform path conversion for `DEP_LIBS`. # https://www.msys2.org/wiki/Porting/#filesystem-namespaces -CC_WITH_ENV := MSYS2_ARG_CONV_EXCL="-DDEP_LIBS=" $(CC) -else -CC_WITH_ENV := $(CC) -endif # in MSYS2? +# We define this environment variable for only these two object files, +# as they're the only ones that require it at the time of writing. +$(BUILDDIR)/loader_lib.o: export MSYS2_ARG_CONV_EXCL = -DDEP_LIBS= +$(BUILDDIR)/loader_lib.dbg.obj: export MSYS2_ARG_CONV_EXCL = -DDEP_LIBS= +endif # MSYS2 EXE_OBJS := $(BUILDDIR)/loader_exe.o EXE_DOBJS := $(BUILDDIR)/loader_exe.dbg.obj @@ -52,9 +53,9 @@ all: release debug release debug : % : julia-% libjulia-% $(BUILDDIR)/loader_lib.o : $(SRCDIR)/loader_lib.c $(HEADERS) $(JULIAHOME)/VERSION - @$(call PRINT_CC, $(CC_WITH_ENV) -DLIBRARY_EXPORTS $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@) + @$(call PRINT_CC, $(CC) -DLIBRARY_EXPORTS $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_lib.dbg.obj : $(SRCDIR)/loader_lib.c $(HEADERS) $(JULIAHOME)/VERSION - @$(call PRINT_CC, $(CC_WITH_ENV) -DLIBRARY_EXPORTS $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@) + @$(call PRINT_CC, $(CC) -DLIBRARY_EXPORTS $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_exe.o : $(SRCDIR)/loader_exe.c $(HEADERS) $(JULIAHOME)/VERSION @$(call PRINT_CC, $(CC) $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_exe.dbg.obj : $(SRCDIR)/loader_exe.c $(HEADERS) $(JULIAHOME)/VERSION From 121afaf9f4e80335f1edd4251561a0d6c0274e73 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Wed, 14 Sep 2022 11:52:47 -0700 Subject: [PATCH 7/7] Fix whitespace --- doc/src/devdocs/build/windows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/devdocs/build/windows.md b/doc/src/devdocs/build/windows.md index 61088380ff59a..1f5f03cb7aac8 100644 --- a/doc/src/devdocs/build/windows.md +++ b/doc/src/devdocs/build/windows.md @@ -155,7 +155,7 @@ Note: MSYS2 requires **64 bit** Windows 7 or newer. 2. Build Julia and its dependencies with pre-build dependencies. - 1. Open a new [**MINGW64/MINGW32 shell**](https://www.msys2.org/docs/environments/#overview). + 1. Open a new [**MINGW64/MINGW32 shell**](https://www.msys2.org/docs/environments/#overview). Currently we can't use both mingw32 and mingw64, so if you want to build the x86_64 and i686 versions, you'll need to build them in each environment separately.