Skip to content

Commit

Permalink
fix JuliaLang#3018 and update windows build instructions (closes Juli…
Browse files Browse the repository at this point in the history
…aLang#3049) to avoid gcc/openblas compile bugs
  • Loading branch information
vtjnash committed May 11, 2013
1 parent f2f6351 commit c3a6775
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 25 deletions.
61 changes: 37 additions & 24 deletions README.windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Explore and have fun!

Recommended external libraries:

- msysGit https://code.google.com/p/msysgit/downloads/list
- TortoiseGit https://code.google.com/p/tortoisegit/wiki/Download
- [msysGit](https://code.google.com/p/msysgit/downloads/list)
- [TortoiseGit](https://code.google.com/p/tortoisegit/wiki/Download)

Optional external libraries

Expand All @@ -32,29 +32,19 @@ ___________________________________________________
Source Compiling
================

There are a number of environments you can use to build julia. Making this easy requires getting the right environment. They are ordered below from worst to best.
There are a few environments you can use to build julia. Making this easy requires getting the right environment.

Native Compile
--------------

On Windows, you can get the mingw/msys environment from http:https://www.mingw.org/wiki/Getting_Started. I strongly discourage this. However, if you choose to ignore me, you will need to do the following steps (thanks to Pavan):

1. Download MinGW+ MSYS Innosetup installer from this url
2. Run this installer to choose from options: Destination Directory (Default- C:\MinGW), MinGW compiler suite (selected C, C++, Fortran), MSYS Basic System (selected), MinGW Developer Toolkit packages (selected). Based on your connection speed, it may take a while to download packages.
3. Set path by choosing ControlPanel > System and Security > System > Advanced System Settings > (Advanced) Environment Variables > Path and add to the end of line: C:\MinGW\bin;C:\MinGW\msys\1.0\bin;
4. At command prompt, type - "mingw-get install wget" - to install wget
5. Install 7-zip (http:https://www.7-zip.org/download.html), if you don't have it already
5. Download Python-2.6.7_msys.7z from [here](https://osspack32.googlecode.com/files/python-2.6.7_msys.7z) and extract files (using 7-Zip) to respective locations in C:\MinGw\msys\1.0 path, i.e., bin, lib, libs, to get Python 2.6.7
6. Download msysGIT from [here](https://code.google.com/p/msysgit/downloads/list), install (choose the option to use Git from the Windows Command Prompt when asked)
7. Add the following line - _CRTIMP int __cdecl _resetstkoflw (void); - to C:\MinGW\include\malloc.h at Line 76. This helped in tackling _resetstkoflw errors being showed in compiling codegen.cpp
8. Log out and back in to make sure the changes to the Path variable are available
On Windows, do not use the mingw/msys environment from http:https://www.mingw.org) as it will miscompile the OpenBlas math library

The recommended way to setup your environment follows:

1. Download and extract mingw to C:/MinGW (or similar location) from http:https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
2. Download and extract msys to C:/MinGW/msys/1.0 (or similar location) from http:https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.2/64-bit/threads-win32/sjlj/
1. Download and extract mingw (e.g. x64-4.8.0-release-win32-seh-rev2.7z) to C:/MinGW (or similar location) from [Mingw64](http:https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.0/64-bit/threads-win32/seh/)
2. Download and extract msys (e.g. msys+7za+wget+svn+git+mercurial+cvs-rev12.7z) to C:/MinGW/msys/1.0 (or similar location) from [Mingw64/Msys](http:https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/)
3. Add the line "C:/MinGW /mingw" to C:/MinGW/msys/1.0/etc/fstab (create the file if it doesn't exist)
4. Replace C:/MinGW/msys/1.0/bin/make.exe with a copy of make.exe extracted from the installer in step 1 of the not-recommended setup
4. Replace C:/MinGW/msys/1.0/bin/make.exe with a copy of make.exe extracted from [mingw-msys](http:https://sourceforge.net/projects/mingw/files/MSYS/Base/make/make-3.81-3/) (e.g. make-3.81-3-msys-1.0.13-bin.tar.lzma)

These sections assume you are familiar with building code. If you are not, you should stop reading now and go the the section on binaries. Regardless of which set of steps you followed above, you are now ready to compile julia. Open a unix shell by launching C:/MinGW/msys/1.0/msys.bat (or your favorite shortcut to that file).

Expand All @@ -71,7 +61,7 @@ Running julia can be done in two ways:
Cross-Compile
-------------

If you prefer to cross-compile (i.e. you are sane), the following steps should get you started:
If you prefer to cross-compile, the following steps should get you started:

First, you will need to ensure your system has the required dependencies. Note that I build on an Ubuntu system, so the `make dist` may not be fully functional on other systems. On Ubuntu 12.04, the following command will install the required build dependencies.

Expand All @@ -84,20 +74,43 @@ apt-get install \
mingw-w64-tools \
binutils-mingw-w64 \
gcc-mingw-w64 \
wine
wine \
subversion cvs
```

Unfortunately, the version of gcc installed by Ubuntu is currently 4.6, which does not compile OpenBLAS correctly. So first we need to replace it. Most binary packages appear to not include gfortran, so we will need to compile it from source. This is typically quite a bit of work, so we will use a [script](https://code.google.com/p/mingw-w64-dgn/) to make it easier.

1. `svn checkout http:https://mingw-w64-dgn.googlecode.com/svn/trunk/ mingw-w64-dgn`
2. `cd mingw-w64-dgn`
3. edit `rebuild_cross.sh` and make the following two changes:
(a) uncomment `export MAKE_OPT="-j 2"` if appropriate for you machine
(b) add `,fortran` to the end of `--enable-languages=c,c++,objc,obj-c++`
5. `bash update_source.sh`
4. `bash rebuild_cross.sh`
5. `mv cross ~/cross-w64`
6. `export PATH=$HOME/cross-w64:$PATH` # NOTE: it is important that you remember to always do this before using make in the following steps!
Then we can essentially just repeat these steps for the 32-bit compiler:
7. `cd ..`
8. `cp -a mingw-w64-dgn mingw-w32-dgn`
9. `cd mingw-w32-dgn`
10. `rm -r cross build`
11. `bash rebuild_cross.sh 32r`
12. `mv cross ~/cross-w32`
13. `export PATH=$HOME/cross-w32:$PATH` # NOTE: it is important that you remember to always do this before using make in the following steps!

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 environment.

Finally, the build and install process:

1. `git clone https://github.com/JuliaLang/julia.git julia-win32`
2. `echo override XC_HOST = i686-w64-mingw32 >> Make.user`
3. `echo override DEFAULT_REPL = basic >> Make.user`
4. `make && make install`
5. (optional) `mkdir dist-extras && make win-extras` (actually, you probably want to hand execute these steps)
6. move the julia-* directory to the target machine
7. Ensure your target has the following dependencies "libgfortran-3.dll" "libquadmath-0.dll" "libgcc_s_sjlj-1.dll" "libstdc++-6.dll" "libssp-0.dll" in the PATH (or in installed julia-* lib folder). These can be copied from the your unix system (on my Ubuntu 12.04 system, they are at /usr/lib/gcc/i686-w64-mingw32/4.6/) or, if you followed my advice above to setup MinGW, they are are in C:/MinGW/bin on your Windows system.
4. `make -j4`
5. (optional) `mkdir dist-extras && make win-extras` (actually, you probably want to hand execute the steps in this recipe since they may be inaccurate)
4. `make dist`
6. move the julia-* directory/zipfile to the target machine

If you are building for 64-bit windows. The steps are pretty much the same. Just replace i686 in XC_HOST with x86_64.
If you are building for 64-bit windows. The steps are the same. Just replace i686 in XC_HOST with x86_64.

Important Build Errata
----------------------
Expand Down
6 changes: 5 additions & 1 deletion deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,11 @@ ifneq ($(ARCH),x86_64)
OPENBLAS_BUILD_OPTS += NUM_THREADS=30
else
# assume we may want lots of threads on some future machine
OPENBLAS_BUILD_OPTS += NUM_THREADS=512
ifeq ($(OS),WINNT) #windows seems unable to handle very many
OPENBLAS_BUILD_OPTS += NUM_THREADS=80
else #linux can handle up to 256 according to the FAQ
OPENBLAS_BUILD_OPTS += NUM_THREADS=256
endif
endif
endif

Expand Down

0 comments on commit c3a6775

Please sign in to comment.