#### MinGW
-[MSYS2](http://msys2.github.io/) can be used to easily build Rust on Windows:
+[MSYS2][msys2] can be used to easily build Rust on Windows:
-1. Grab the latest MSYS2 installer and go through the installer.
+msys2: https://msys2.github.io/
-2. From the MSYS2 terminal, install the `mingw64` toolchain and other required
- tools.
+1. Grab the latest [MSYS2 installer][msys2] and go through the installer.
- ```sh
- # Update package mirrors (may be needed if you have a fresh install of MSYS2)
- $ pacman -Sy pacman-mirrors
- ```
+2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
+ MSYS2 (i.e. `C:\msys64`), depending on whether you want 32-bit or 64-bit
+ Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd
+ -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead)
- Download [MinGW from
- here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
- `version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
- add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
- installing from pacman should be just fine.
+3. From this terminal, install the required tools:
```sh
- # Make git available in MSYS2 (if not already available on path)
- $ pacman -S git
+ # Update package mirrors (may be needed if you have a fresh install of MSYS2)
+ $ pacman -Sy pacman-mirrors
- $ pacman -S base-devel
+ # Install build tools needed for Rust. If you're building a 32-bit compiler,
+ # then replace "x86_64" below with "i686". If you've already got git, python,
+ # or CMake installed and in PATH you can remove them from this list. Note
+ # that it is important that the `python2` and `cmake` packages **not** used.
+ # The build has historically been known to fail with these packages.
+ $ pacman -S git \
+ make \
+ diffutils \
+ mingw-w64-x86_64-python2 \
+ mingw-w64-x86_64-cmake \
+ mingw-w64-x86_64-gcc
```
-3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
- MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
- (As of the latest version of MSYS2 you have to run `msys2_shell.cmd -mingw32`
- or `msys2_shell.cmd -mingw64` from the command line instead)
-
-4. Navigate to Rust's source code, configure and build it:
+4. Navigate to Rust's source code (or clone it), then configure and build it:
```sh
$ ./configure
;;
*-msvc)
- # There are some MSYS python builds which will auto-translate
- # windows-style paths to MSYS-style paths in Python itself.
- # Unfortunately this breaks LLVM's build system as somewhere along
- # the line LLVM prints a path into a file from Python and then CMake
- # later tries to interpret that path. If Python prints a MSYS path
- # and CMake tries to use it as a Windows path, you're gonna have a
- # Bad Time.
- #
- # Consequently here we try to detect when that happens and print an
- # error if it does.
- if $CFG_PYTHON -c 'import sys; print sys.argv[1]' `pwd` | grep '^/' > /dev/null
- then
- err "
-
-python is silently translating windows paths to MSYS paths \
-and the build will fail if this python is used.
-
-Either an official python install must be used or an \
-alternative python package in MinGW must be used.
-
-If you are building under msys2 try installing the mingw-w64-x86_64-python2 \
-package instead of python2:
-
-$ pacman -R python2 && pacman -S mingw-w64-x86_64-python2
-"
- fi
-
# There are three builds of cmake on windows: MSVC, MinGW and Cygwin
# The Cygwin build does not have generators for Visual Studio, so
# detect that here and error.
esac
done
+if [ "$CFG_OSTYPE" = "pc-windows-gnu" ] || [ "$CFG_OSTYPE" = "pc-windows-msvc" ]
+then
+ # There are some MSYS python builds which will auto-translate
+ # windows-style paths to MSYS-style paths in Python itself.
+ # Unfortunately this breaks LLVM's build system as somewhere along
+ # the line LLVM prints a path into a file from Python and then CMake
+ # later tries to interpret that path. If Python prints a MSYS path
+ # and CMake tries to use it as a Windows path, you're gonna have a
+ # Bad Time.
+ #
+ # Consequently here we try to detect when that happens and print an
+ # error if it does.
+ if $CFG_PYTHON -c 'import sys; print sys.argv[1]' `pwd` | grep '^/' > /dev/null
+ then
+ err "
+
+python is silently translating windows paths to MSYS paths \
+and the build will fail if this python is used.
+
+Either an official python install must be used or an \
+alternative python package in MinGW must be used.
+
+If you are building under msys2 try installing the mingw-w64-x86_64-python2 \
+package instead of python2:
+
+$ pacman -S mingw-w64-x86_64-python2
+"
+ fi
+fi
+
if [ -n "$CFG_PERF" ]
then
HAVE_PERF_LOGFD=`$CFG_PERF stat --log-fd 2>&1 | grep 'unknown option'`