-
Notifications
You must be signed in to change notification settings - Fork 0
Note Building Rust Before 0.8 on Windows Systems
Please note that this is an in-progress and temporary guide only intended for versions of Rust before 0.8 on Windows systems.
This temporary guide will cover building Rust < 0.8 on a Windows system through MSYS & MinGW using gcc 4.8 .
- Download the MinGW installer:
- Run the
mingw-get-setup
installer.
- For simplicity use the default path of
C:\MinGW
, pretty please. - I like to install for all users.
- Run with Administrator privileges if possible.
- Make sure MinGW is on your system path.
-
;C:\MinGW\bin
for example should be appended to the PATH environment variable, similar to these instructions: http://stackoverflow.com/a/6318188/458550 . - Be careful not to disturb the existing entries.
- It is pretty handy to create a shortcut on your desktop to
C:\MinGW\msys\1.0\msys.bat
We have a few packages to add.
- Run the mingw-get GUI from your desktop by double clicking the "MinGW Installer" shortcut.
- Right click the following list of packages (bin) within the right pane and select "Mark for Installation". Use the left navigation tree to filter categories.
- Basic Setup
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
- All Packages
msys-wget
- MinGW Libraries
- MinGW Standard Libraries
mingw32-libpthread-old
mingw32-libpthreadgc
- MinGW Standard Libraries
- Basic Setup
- From the GUI menu navigate to Installation > Apply Changes
- This will take some time to complete.
If you already have Git installed and available on the path you may skip this section. You should be able to use the git command from your msys shell.
- Install git for windows from http://git-scm.com/download/win
- Uncheck Associate .sh files to be run with Bash from within the components screen.
- Select the option to Run Git from the Windows Command Prompt.
- It is recommended to choose the option to Checkout as-is, commit Unix-style line endings.
- Open a new msys console and type
git --version
to verify installation.
- Note: if your shell (explorer) does not return after installation, start the task manager and navigate to File > Run New Task... then enter
explorer
.
If you already have python installed and on the path, you may skip this section.
- Get the Python27 installer from http://www.python.org/getit/
- I am using "Python 2.7.5 Windows X86-64 Installer"
- Accept the defaults, please.
- Add python to your system path: http://stackoverflow.com/a/6318188/458550
- Navigate to a place on your file system where you feel comfortable downloading the Rust repository.
-
C:\projects
is a nice cozy spot!
-
- execute
git clone git://github.com/mozilla/rust.git
to clone the Rust repository into a newrust
directory.
While the clone is taking place you can continue on to patching.
If you care about your MinGW environment beyond building Rust stop right now and find another method!
There are some issues with our environment that we need to patch up. This is some greasy stuff but it will get you further down the compilation path. These patches should be applied within your MinGW installation folder. Thanks to klutzy for all of these.
If you receive errors regarding WSAPOLLFD (haha, you will!) you must patch /mingw/include/winsock2.h
by inserting the following at line 915:
typedef struct pollfd {
SOCKET fd;
short events;
short revents;
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
From: http://sourceforge.net/p/mingw/bugs/1980/
For errors regarding FE_ALL_EXCEPT
you must patch \MinGW\lib\gcc\mingw32\4.8.1\include\c++\mingw32\bits\c++config.h
by inserting the following at line 597:
#define _GLIBCXX_HAVE_FENV_H 1
If you have errors regarding the definition of FILE_FLAG_FIRST_PIPE_INSTANCE
you must patch \MinGW\include\winbase.h
by changing line 1986 from #if (NTDDK_VERSION >= NTDDI_WIN2KSP2)
to the following:
#if (_WIN32_WINNT >= 0x0500)
-
Navigate to the directory where you cloned rust from within the msys shell. For me that is
cd /C/Projects/rust
. -
Run the command
./configure
- This will take a while!
-
When that completes run the command
make
- This will take much longer!
-
Get your sad face ready because this build will fail. Eventually you should get an error such as this:
--------------------------- rustc.exe - Application Error --------------------------- The application was unable to start correctly (0xc0000142). Click OK to close the application. --------------------------- OK ---------------------------
-
Download
libstdc++-4.6.2-1-mingw32-dll-6.tar.lzma
from http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.6.2-1/libstdc%2B%2B-4.6.2-1-mingw32-dll-6.tar.lzma/download and extract the contained libstdc++-6.dll into the\rust\i686-pc-mingw32\stage0\bin
folder.- Try running
rustc.exe
to confirm the fix.
- Try running
-
Run the
make
command again.- This will take a really long time!
User@Machine /c/projects/rust/i686-pc-mingw32/stage2/bin
$ rustc.exe hello.rs
User@Machine /c/projects/rust/i686-pc-mingw32/stage2/bin
$ hello
Hello, world.