Skip to content

Commit 018fd96

Browse files
committed
Merge bitcoin/bitcoin#22093: build: Try posix-specific CXX first for mingw32 host
2fda0c7 doc: Drop no longer required notes for Windows builds (Hennadii Stepanov) f09ed92 build: Try posix-specific CXX first for mingw32 host (Hennadii Stepanov) Pull request description: On master (1186910), when cross-compiling for Windows using our depends build system, we must manually choose the POSIX thread model for the `x86_64-w64-mingw32-g++` compiler. This PR improves the build system to make this choice automa**g**ically. ACKs for top commit: jarolrod: re-ACK 2fda0c7 shaavan: tACK 2fda0c7 Tree-SHA512: ad3bbdfe84b3c8eb56e102aa0abdc76fd864b2724ac59c9a12a798c57d1c5a1172682172588019d5d1715801a9f201fd9424effbd858e8dc30607c23c0d5941f
2 parents 711ce2e + 2fda0c7 commit 018fd96

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

depends/hosts/mingw32.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
ifneq ($(shell which $(host)-g++-posix),)
2+
mingw32_CXX := $(host)-g++-posix
3+
endif
4+
15
mingw32_CFLAGS=-pipe
26
mingw32_CXXFLAGS=$(mingw32_CFLAGS)
37

doc/build-windows.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,6 @@ The first step is to install the mingw-w64 cross-compilation tool chain:
5151

5252
sudo apt install g++-mingw-w64-x86-64
5353

54-
Next, set the default `mingw32 g++` compiler option to POSIX<sup>[1](#footnote1)</sup>:
55-
56-
```
57-
sudo update-alternatives --config x86_64-w64-mingw32-g++
58-
```
59-
60-
After running the above command, you should see output similar to that below.
61-
Choose the option that ends with `posix`.
62-
63-
```
64-
There are 2 choices for the alternative x86_64-w64-mingw32-g++ (providing /usr/bin/x86_64-w64-mingw32-g++).
65-
66-
Selection Path Priority Status
67-
------------------------------------------------------------
68-
0 /usr/bin/x86_64-w64-mingw32-g++-win32 60 auto mode
69-
* 1 /usr/bin/x86_64-w64-mingw32-g++-posix 30 manual mode
70-
2 /usr/bin/x86_64-w64-mingw32-g++-win32 60 manual mode
71-
72-
Press <enter> to keep the current choice[*], or type selection number:
73-
```
74-
7554
Once the toolchain is installed the build steps are common:
7655

7756
Note that for WSL the Bitcoin Core source path MUST be somewhere in the default mount file system, for
@@ -112,13 +91,3 @@ way. This will install to `c:\workspace\bitcoin`, for example:
11291
You can also create an installer using:
11392

11493
make deploy
115-
116-
Footnotes
117-
---------
118-
119-
<a name="footnote1">1</a>: Starting from Ubuntu Xenial 16.04, both the 32 and 64 bit Mingw-w64 packages install two different
120-
compiler options to allow a choice between either posix or win32 threads. The default option is win32 threads which is the more
121-
efficient since it will result in binary code that links directly with the Windows kernel32.lib. Unfortunately, the headers
122-
required to support win32 threads conflict with some of the classes in the C++11 standard library, in particular std::mutex.
123-
It's not possible to build the Bitcoin Core code using the win32 version of the Mingw-w64 cross compilers (at least not without
124-
modifying headers in the Bitcoin Core source code).

0 commit comments

Comments
 (0)