Skip to content

Commit 709b8f4

Browse files
committed
Rewrite the MSYS2 build instructions
testers needed! Rewrite cross-compiling instructions to use docker and opensuse 13.1 and fix markdown lists Vagrant instead of Docker adjust msys2 setup steps Test with msys2's python2 Remove path recommendation, not really needed any more [av skip]
1 parent 690a376 commit 709b8f4

File tree

2 files changed

+66
-128
lines changed

2 files changed

+66
-128
lines changed

README.windows.md

+65-127
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ Both the 32-bit and 64-bit versions are supported.
2525
The 32-bit (i686) binary will run on either a 32-bit and 64-bit operating system.
2626
The 64-bit (x86_64) binary will only run on 64-bit Windows and will otherwise refuse to launch.
2727

28-
1. Download and install [7-Zip](http://www.7-zip.org/download.html). Install the full program, not just the command line version.
28+
1. [Download](http://julialang.org/downloads) the latest version of Julia. Extract the binary to a reasonable destination folder, e.g. `C:\julia`.
2929

30-
2. [Download](http://julialang.org/downloads) the latest version of Julia. Extract the binary to a reasonable destination folder, e.g. `C:\julia`.
31-
32-
3. Double-click the file `julia.bat` to launch Julia.
30+
2. Double-click the `julia` shortcut to launch Julia.
3331

3432
# Line endings
3533

@@ -56,80 +54,48 @@ or edit `%USERPROFILE%\.gitconfig` and add/edit the lines:
5654
## Compiling with MinGW/MSYS2
5755

5856
### MSYS2 provides a robust MSYS experience.
59-
### The instructions in this section were tested with the latest versions of all packages specified as of 2014-02-28.
60-
61-
1. Install [7-Zip](http://www.7-zip.org/download.html).
62-
63-
2. Install [Python 2.x](http://www.python.org/download/releases). Do **not** install Python 3.
64-
65-
3. Install [CMake](http://www.cmake.org/download/).
6657

67-
4. Install [MinGW-builds](http://sourceforge.net/projects/mingwbuilds/), a Windows port of GCC, as follows. Do **not** use the regular MinGW distribution.
68-
1. Download the [MinGW-builds installer](http://downloads.sourceforge.net/project/mingwbuilds/mingw-builds-install/mingw-builds-install.exe).
69-
2. Run the installer. When prompted, choose:
70-
- Version: the most recent version (these instructions were tested with 4.8.1)
71-
- Architecture: `x32` or `x64` as appropriate and desired.
72-
- Threads: `win32` (not posix)
73-
- Exception: `sjlj` (for x32) or `seh` (for x64). Do not choose dwarf2.
74-
- Build revision: most recent available (tested with 5)
75-
3. Do **not** install to a directory with spaces in the name. You will have to change the default installation path, for example,
76-
- `C:\mingw-builds\x64-4.8.1-win32-seh-rev5` for 64 bits
77-
- `C:\mingw-builds\x32-4.8.1-win32-sjlj-rev5` for 32 bits
58+
1. Install [CMake](http://www.cmake.org/download/).
7859

79-
5. Install and configure [MSYS2](http://sourceforge.net/projects/msys2), a minimal POSIX-like environment for Windows.
60+
2. Install and configure [MSYS2](https://msys2.github.io), a minimal POSIX-like environment for Windows.
8061

81-
1. Download the latest base [32-bit](http://sourceforge.net/projects/msys2/files/Base/i686/) or [64-bit](http://sourceforge.net/projects/msys2/files/Base/x86_64/) distribution, consistent with the architecture you chose for MinGW-builds. The archive will have a name like `msys2-base-x86_64-yyyymmdd.tar.xz` and these instructions were tested with `msys2-base-x86_64-20140216.tar.xz`.
62+
1. Download and run the latest installer for the [32-bit](http://sourceforge.net/projects/msys2/files/Base/i686/) or [64-bit](http://sourceforge.net/projects/msys2/files/Base/x86_64/) distribution. The installer will have a name like `msys2-i686-yyyymmdd.exe` or `msys2-x86_64-yyyymmdd.exe`.
8263

83-
2. Using [7-Zip](http://www.7-zip.org/download.html), extract the archive to any convenient directory.
84-
- *N.B.* Some versions of this archive contain zero-byte files that clash with existing files. If prompted, choose **not** to overwrite existing files.
85-
- You may need to extract the tarball in a separate step. This will create an `msys32` or `msys64` directory, according to the architecture you chose.
86-
- Move the `msys32` or `msys64` directory into your MinGW-builds directory, which is `C:\mingw-builds` if you followed the suggestions in step 3. We will omit the "32" or "64" in the steps below and refer to this as "the msys directory".
64+
2. Double-click `msys2_shell.bat` in the installed msys directory. Initialize the MSYS2 base system using the `pacman` package manager included in MSYS2:
8765

88-
3. Double-click `msys2_shell.bat` in the msys directory. This will initialize MSYS2. The shell will tell you to `exit` and restart the shell. For now, ignore it.
66+
```
67+
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
68+
```
8969

90-
4. Update MSYS2 and install packages required to build julia, using the `pacman` package manager included in MSYS2:
70+
3. Exit and restart MSYS2, then install packages required to build julia:
9171

9272
```
93-
pacman-key --init #Download keys
9473
pacman -Syu #Update package database and full system upgrade
95-
```
96-
Now `exit` the MSYS2 shell and restart it, *even if you already restarted it above*. This is necessary in case the system upgrade updated the main MSYS2 libs. Reopen the MSYS2 shell and continue with:
97-
98-
```
99-
pacman -S diffutils git m4 make patch tar msys/openssh
74+
pacman -S diffutils git m4 make patch tar python2 p7zip msys/openssh
10075
```
10176

102-
5. Configure your MSYS2 shell for convenience:
77+
4. Configuration of MSYS2 is complete. Now `exit` the MSYS2 shell.
10378

79+
3. Build Julia and its dependencies from source.
80+
1. Open a new MSYS2 shell and clone the Julia sources
10481
```
105-
echo "mount C:/Python27 /python" >> ~/.bashrc
106-
# uncomment ONE of the following two lines
107-
#echo "mount C:/mingw-builds/x64-4.8.1-win32-seh-rev5/mingw64 /mingw" >> ~/.bashrc
108-
#echo "mount C:/mingw-builds/x32-4.8.1-win32-sjlj-rev5/mingw32 /mingw" >> ~/.bashrc
109-
echo "export PATH=/usr/local/bin:/usr/bin:/opt/bin:/mingw/bin:/python" >> ~/.bashrc
82+
git clone https://github.com/JuliaLang/julia.git
83+
cd julia
11084
```
11185

112-
*N.B.* The `export` clobbers whatever `$PATH` is already defined. This is suggested to avoid path-masking. If you use MSYS2 for purposes other than building Julia, you may prefer to append rather than clobber.
113-
114-
*N.B.* All of the path-separators in the mount commands are unix-style.
115-
116-
117-
6. Configuration of the toolchain is complete. Now `exit` the MSYS2 shell.
118-
119-
6. Build Julia and its dependencies from source.
120-
1. Relaunch the MSYS2 shell and type
121-
86+
2. Run the following script to download the correct versions of the MinGW-w64 compilers
12287
```
123-
. ~/.bashrc # Some versions of MSYS2 do not run this automatically
88+
contrib/windows/get_toolchain.sh 32 # for 32 bit Julia
89+
# or
90+
contrib/windows/get_toolchain.sh 64 # for 64 bit Julia
12491
```
125-
126-
Ignore any warnings you see from `mount` about `/mingw` and `/python` not existing.
127-
128-
2. Get the Julia sources
129-
```
130-
git clone https://github.com/JuliaLang/julia.git
131-
cd julia
92+
Then follow the printed instructions by running either
93+
```
94+
export PATH=$PWD/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH # for 32 bit Julia
95+
# or
96+
export PATH=$PWD/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH # for 64 bit Julia
13297
```
98+
to add the downloaded MinGW-w64 compilers to your path (temporarily, only needed during the shell session when you build Julia).
13399

134100
3. Specify the location where you installed CMake
135101

@@ -138,15 +104,16 @@ or edit `%USERPROFILE%\.gitconfig` and add/edit the lines:
138104
```
139105

140106
4. Start the build
141-
```
107+
```
142108
make -j 4 # Adjust the number of cores (4) to match your build environment.
143109
```
144-
7. Setup Package Development Environment
110+
111+
4. Setup Package Development Environment
145112
1. The `Pkg` module in Base provides many convenient tools for [developing and publishing packages](http://docs.julialang.org/en/latest/manual/packages/).
146113
One of the packages added through pacman above was `openssh`, which will allow secure access to GitHub APIs.
147114
Follow GitHub's [guide](https://help.github.com/articles/generating-ssh-keys) to setting up SSH keys to ensure your local machine can communicate with GitHub effectively.
148115

149-
5. In case of the issues with building packages (i.e. ICU fails to build with the following error message ```error compiling xp_parse: error compiling xp_make_parser: could not load module libexpat-1: %```) run ```make win-extras``` and then copy everything from the ```dist-extras``` folder into ```usr/bin```.
116+
2. In case of the issues with building packages (i.e. ICU fails to build with the following error message ```error compiling xp_parse: error compiling xp_make_parser: could not load module libexpat-1: %```) run ```make win-extras``` and then copy everything from the ```dist-extras``` folder into ```usr/bin```.
150117

151118
## Cygwin-to-MinGW cross compiling
152119

@@ -208,69 +175,40 @@ Julia can be also compiled from source in [Cygwin](http://www.cygwin.com), using
208175

209176
If you prefer to cross-compile, the following steps should get you started.
210177

211-
### Ubuntu and Mac Dependencies (these steps will work for almost any linux platform)
212-
213-
First, you will need to ensure your system has the required dependencies. We need wine (>=1.7.5),
214-
a system compiler, and some downloaders.
215-
216-
On Ubuntu:
217-
218-
apt-add-repository ppa:ubuntu-wine/ppa
219-
apt-get upate
220-
apt-get install wine1.7 subversion cvs gcc wget p7zip-full
221-
222-
223-
On Mac: Install XCode, XCode command line tools, X11 (now [XQuartz](http://xquartz.macosforge.org/)),
224-
and [MacPorts](http://www.macports.org/install.php) or [Homebrew](http://mxcl.github.io/homebrew/).
225-
Then run ```port install wine wget``` or ```brew install wine wget```, as appropriate.
226-
227-
On Both:
228-
229-
Unfortunately, the version of gcc installed by Ubuntu targets pthreads.
230-
On Mac, the situation is similar: the version in MacPorts is very old and Homebrew does not have it.
231-
So first we need to get a cross-compile version of gcc.
232-
Most binary packages appear to not include gfortran, so we will need to compile it from source (or ask @vtjnash to send you a tgz of his build).
233-
This is typically quite a bit of work, so we will use [this script](http://sourceforge.net/projects/mingw-w64-dgn/) to make it easy.
234-
235-
1. `svn checkout svn checkout svn://svn.code.sf.net/p/mingw-w64-dgn/code/trunk mingw-w64-dgn-code`
236-
2. `cd mingw-w64-dgn`
237-
3. edit `rebuild_cross.sh` and make the following two changes:
238-
a. uncomment `export MAKE_OPT="-j 2"`, if appropriate for your machine
239-
b. add `fortran` to the end of `--enable-languages=c,c++,objc,obj-c++`
240-
5. `bash update_source.sh`
241-
4. `bash rebuild_cross.sh`
242-
5. `mv cross ~/cross-w64`
243-
6. `export PATH=$HOME/cross-w64/bin:$PATH` # NOTE: it is important that you remember to always do this before using make in the following steps!, you can put this line in your .profile to make it easy
244-
245-
Then we can essentially just repeat these steps for the 32-bit compiler, reusing some of the work:
246-
247-
7. `cd ..`
248-
8. `cp -a mingw-w64-dgn mingw-w32-dgn`
249-
9. `cd mingw-w32-dgn`
250-
10. `rm -r cross build`
251-
11. `bash rebuild_cross.sh 32r`
252-
12. `mv cross ~/cross-w32`
253-
13. `export PATH=$HOME/cross-w32/bin:$PATH` # NOTE: it is important that you remember to always do this before using make in the following steps!, you can put this line in your .profile to make it easy
254-
255-
Note: for systems that support rpm-based package managers, the OpenSUSE build service appears to contain a fully up-to-date versions of the necessary dependencies.
256-
257-
### Arch Linux Dependencies
258-
259-
1. Install the following packages from the official Arch repository:
260-
`sudo pacman -S cloog gcc-ada libmpc p7zip ppl subversion zlib`
261-
2. The rest of the prerequisites consist of the mingw-w64 packages, which are available in the AUR Arch repository. They must be installed exactly in the order they are given or else their installation will fail. The `yaourt` package manager is used for illustration purposes; you may instead follow the [Arch instructions for installing packages from AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages) or may use your preferred package manager. To start with, install `mingw-w64-binutils` via the command
262-
`yaourt -S mingw-w64-binutils`
263-
3. `yaourt -S mingw-w64-headers-svn`
264-
4. `yaourt -S mingw-w64-headers-bootstrap`
265-
5. `yaourt -S mingw-w64-gcc-base`
266-
6. `yaourt -S mingw-w64-crt-svn`
267-
7. Remove `mingw-w64-headers-bootstrap` without removing its dependent mingw-w64 installed packages by using the command
268-
`yaourt -Rdd mingw-w64-headers-bootstrap`
269-
8. `yaourt -S mingw-w64-winpthreads`
270-
9. Remove `mingw-w64-gcc-base` without removing its installed mingw-w64 dependencies:
271-
`yaourt -Rdd mingw-w64-gcc-base`
272-
10. Complete the installation of the required `mingw-w64` packages:
273-
`yaourt -S mingw-w64-gcc`
178+
For maximum compatibility with packages that use [WinRPM.jl](https://github.com/JuliaLang/WinRPM.jl) for binary dependencies on Windows, it is recommended that you use OpenSUSE 13.1 for cross-compiling a Windows build of Julia. If you use a different Linux distribution or OS X, install [Vagrant](http://www.vagrantup.com/downloads) and use the following `Vagrantfile`:
179+
```
180+
# Vagrantfile for MinGW-w64 cross-compilation of Julia
181+
182+
$script = <<SCRIPT
183+
# Change the following to i686-w64-mingw32 for 32 bit Julia:
184+
export XC_HOST=x86_64-w64-mingw32
185+
# Change the following to 32 for 32 bit Julia:
186+
export BITS=64
187+
zypper addrepo http://download.opensuse.org/repositories/windows:mingw:win$BITS/openSUSE_13.1/windows:mingw:win$BITS.repo
188+
zypper --gpg-auto-import-keys refresh
189+
zypper -n install --no-recommends git make cmake tar wine which curl \
190+
python python-xml patch gcc-c++ m4 p7zip.i586 libxml2-tools
191+
zypper -n install mingw$BITS-cross-gcc-c++ mingw$BITS-cross-gcc-fortran \
192+
mingw$BITS-libstdc++6 mingw$BITS-libgfortran3 mingw$BITS-libssp0
193+
# opensuse packages the mingw runtime dlls under sys-root/mingw/bin, not /usr/lib64/gcc
194+
cp /usr/$XC_HOST/sys-root/mingw/bin/*.dll /usr/lib*/gcc/$XC_HOST/*/
195+
git clone git://github.com/JuliaLang/julia.git julia
196+
cd julia
197+
make -j4 win-extras julia-ui-release
198+
export WINEDEBUG=-all # suppress wine fixme's
199+
# this last step may need to be run interactively
200+
make -j4 binary-dist
201+
SCRIPT
202+
203+
Vagrant.configure("2") do |config|
204+
config.vm.box = "chef/opensuse-13.1"
205+
config.vm.provider :virtualbox do |vb|
206+
# Use VBoxManage to customize the VM. For example to change memory:
207+
vb.memory = 2048
208+
end
209+
config.vm.provision :shell, :inline => $script
210+
end
211+
```
274212

275213
### Cross-building Julia
276214

@@ -281,7 +219,7 @@ Finally, the build and install process for Julia:
281219
3. `make`
282220
4. `make win-extras` (Necessary before running `make binary-dist`p)
283221
5. `make binary-dist`
284-
6. move the julia-* directory / zip file to the target machine
222+
6. move the julia-*.exe installer to the target machine
285223

286224
If you are building for 64-bit windows, the steps are essentially the same. Just replace i686 in XC_HOST with x86_64. (note: on Mac, wine only runs in 32-bit mode)
287225

deps/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,7 @@ $(VIRTUALENV_SOURCE): virtualenv-$(VIRTUALENV_VER).tar.gz
18571857
$(VIRTUALENV_TARGET): $(VIRTUALENV_SOURCE)
18581858
"$(shell ./find_python2)" $< $@
18591859
ifeq ($(BUILD_OS), WINNT)
1860-
[ -e $@/Scripts ] && ! [ -e $@/bin ] && cmd //C mklink //J $@\\bin $@\\Scripts
1860+
-[ -e $@/Scripts ] && ! [ -e $@/bin ] && cmd //C mklink //J $@\\bin $@\\Scripts
18611861
endif
18621862
touch -c $@
18631863

0 commit comments

Comments
 (0)