Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: Check for valid Python on MinGW as well #34515

Merged
merged 1 commit into from
Jul 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,37 @@ build.

#### 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSYS2 seems to be in some horrible transition state currently. The installer at msys2.github.io is not updated yet, but a simple system update suddenly updates pacman, removes mingw32_shell.bat, mingw64_shell.bat and makes all the shortcuts unusable. I'm afraid this instruction will have to be rewritten again soon :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Do you know if there's another location to download installers from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did notice that a pacman -S base-devel cause a bunch of errors and the process never terminated, so if the installers were out of date that'd explain that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if there's another location to download installers from?

No. I suggest to just wait for the next release (there's an issue about this msys2/MSYS2-packages#625) and leave people trying to update core packages alone with their woes.


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
Expand Down
57 changes: 30 additions & 27 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1178,33 +1178,6 @@ do
;;

*-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.
Expand Down Expand Up @@ -1288,6 +1261,36 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
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'`
Expand Down