Merge #11438: Updated Windows build doc for WSL/Xenial workaround
7383d77 Updated instructions for Windows 10 Fall Creators Update. (Aaron Clauson)
e0fc4a7 Updated Windows build doc for WSL/Xenial workarounds. (Aaron Clauson)
Pull request description:
An update to the Windows build document that provides workarounds for the broken 64 bit mingw32 cross compiler on WSL/Xenial.
This update is an alternative to pull request #11437. While that pull request takes a valid approach by stating building on WSL should be avoided I think it is more useful to give Windows developers a workaround option.
The instructions have been tested on:
- Ubuntu 14.04 and 64 bit mingw32 tool chain
- Ubuntu 16.04 and 64 bit mingw32 tool chain
- Ubuntu 17.04 and 64 bit mingw32 tool chain
- Windows Subsystem for Linux (Windows 10 OS Build 15063.608) and 32 bit mingw32 tool chain
- Windows Subsystem for Linux (Windows 10 OS Build 15063.608) and 64 bit mingw32 tool chain
Related items:
- Serious incompatibility problems w/ newer mingw-64 on Ubuntu #8653
- `-fstack-protector-all` triggers crashes in mingw-w64 5.3.1 #8732
- Windows build appears broken on WSL (buntu okay) #10269
- Compilation error for windows target #11437
Tree-SHA512: 7c937e37ed7120ae5dcf61aba50e5228a7ed6f729647c724b8f48e7cbbd81366c1a83a818618766a8fe0418425e05ba2eba2b14f2616621c58606585444f45fc
@ -4,11 +4,14 @@ WINDOWS BUILD NOTES
@@ -4,11 +4,14 @@ WINDOWS BUILD NOTES
Below are some notes on how to build Bitcoin Core for Windows.
Most developers use cross-compilation from Ubuntu to build executables for
Windows. Cross-compilation is also used to build the release binaries.
Windows. This is also used to build the release binaries.
Currently only building on Ubuntu Trusty 14.04 or Ubuntu Zesty 17.04 or later is supported.
Building on Ubuntu Xenial 16.04 is known to be broken, see extensive discussion in issue [8732](https://github.com/bitcoin/bitcoin/issues/8732).
While it may be possible to do so with work arounds, it's potentially dangerous and not recommended.
Building on Ubuntu Trusty 14.04 is recommended.
At the time of writing the Windows Subsystem for Linux installs Ubuntu Xenial 16.04. The default cross
compiler package for Ubuntu Xenial does not produce working executables for some of the bitcoin applications.
It is possible to build on Ubuntu Xenial by installing the cross compiler packages from
Ubuntu Zesty, see the steps below.
Building on Ubuntu Zesty 17.04 up to 17.10 has been verified to work.
While there are potentially a number of ways to build on Windows (for example using msys / mingw-w64),
using the Windows Subsystem For Linux is the most straightforward. If you are building with
@ -19,7 +22,7 @@ Compiling with Windows Subsystem For Linux
@@ -19,7 +22,7 @@ Compiling with Windows Subsystem For Linux
-------------------------------------------
With Windows 10, Microsoft has released a new feature named the [Windows
Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about). This
Subsystem for Linux (WSL)](https://msdn.microsoft.com/commandline/wsl/about). This
feature allows you to run a bash shell directly on Windows in an Ubuntu-based
environment. Within this environment you can cross compile for Windows without
the need for a separate Linux VM or server.
@ -28,6 +31,10 @@ This feature is not supported in versions of Windows prior to Windows 10 or on
@@ -28,6 +31,10 @@ This feature is not supported in versions of Windows prior to Windows 10 or on
Windows Server SKUs. In addition, it is available [only for 64-bit versions of
For Ubuntu Xenial 16.04, Ubuntu Zesty 17.04 and Windows Subsystem for Linux <sup>[2](#footnote2)</sup>:
sudo update-alternatives --config i686-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
Then build using:
@ -117,3 +140,20 @@ as they appear in the release `.zip` archive. This can be done in the following
@@ -117,3 +140,20 @@ as they appear in the release `.zip` archive. This can be done in the following
way. This will install to `c:\workspace\bitcoin`, for example:
make install DESTDIR=/mnt/c/workspace/bitcoin
Footnotes
---------
<aname="footnote1">1</a>: There is currently a bug in the 64 bit mingw-w64 cross compiler packaged for WSL/Ubuntu Xenial 16.04 that
causes two of the bitcoin executables to crash shortly after start up. The bug is related to the
-fstack-protector-all g++ compiler flag which is used to mitigate buffer overflows.
Installing the mingw-w64 packages from the Ubuntu 17 distribution solves the issue, however, this is not
an officially supported approach and it's only recommended if you are prepared to reinstall WSL/Ubutntu should
something break.
<aname="footnote2">2</a>: Starting from Ubuntu Xenial 16.04 both the 32 and 64 bit mingw-w64 packages install two different
compiler options to allow a choice between either posix or win32 threads. The default option is win32 threads which is the more
efficient since it will result in binary code that links directly with the Windows kernel32.lib. Unfortunately, the headers
required to support win32 threads conflict with some of the classes in the C++11 standard library in particular std::mutex.
It's not possible to build the bitcoin code using the win32 version of the mingw-w64 cross compilers (at least not without