Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jun 27, 2021

On master (9c3751a) the cross build for Win64 is broken if configured with --enable-external-signer:

...
  CXX      crypto/libbitcoin_crypto_base_a-chacha_poly_aead.o
In file included from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handles.hpp:11,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/used_handles.hpp:17,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/async_in.hpp:20,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/async.hpp:49,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process.hpp:23,
                 from util/system.cpp:9:
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:208:51: error: expected ‘)’ before ‘*’ token
  208 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_system_query_information_p )(
      |                                    ~              ^~
      |                                                   )
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:223:51: error: expected ‘)’ before ‘*’ token
  223 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_query_object_p )(
      |                                    ~              ^~
      |                                                   )
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp: In function ‘boost::winapi::NTSTATUS_ boost::process::detail::windows::workaround::nt_system_query_information(boost::process::detail::windows::workaround::SYSTEM_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)’:
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:239:12: error: ‘nt_system_query_information_p’ does not name a type; did you mean ‘nt_system_query_information’?
  239 |     static nt_system_query_information_p f = reinterpret_cast<nt_system_query_information_p>(::boost::winapi::get_proc_address(h, "NtQuerySystemInformation"));
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            nt_system_query_information
In file included from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handles.hpp:11,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/used_handles.hpp:17,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/async_in.hpp:20,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/async.hpp:49,
                 from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process.hpp:23,
                 from util/system.cpp:9:
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:241:14: error: ‘f’ was not declared in this scope
  241 |     return (*f)(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
      |              ^
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp: In function ‘boost::winapi::BOOL_ boost::process::detail::windows::workaround::nt_query_object(boost::winapi::HANDLE_, boost::process::detail::windows::workaround::OBJECT_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)’:
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:253:12: error: ‘nt_query_object_p’ does not name a type; did you mean ‘nt_query_object’?
  253 |     static nt_query_object_p f = reinterpret_cast<nt_query_object_p>(::boost::winapi::get_proc_address(h, "NtQueryObject"));
      |            ^~~~~~~~~~~~~~~~~
      |            nt_query_object
/home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:255:14: error: ‘f’ was not declared in this scope
  255 |     return (*f)(Handle, ObjectInformationClass, ObjectInformation, ObjectInformationLength, ReturnLength);
      |              ^
make[2]: *** [Makefile:9906: util/libbitcoin_util_a-system.o] Error 1
make[2]: *** Waiting for unfinished jobs....
  CXX      crypto/libbitcoin_crypto_base_a-chacha20.o
make[2]: Leaving directory '/home/hebasto/GitHub/bitcoin/src'
make[1]: *** [Makefile:16141: all-recursive] Error 1
make[1]: Leaving directory '/home/hebasto/GitHub/bitcoin/src'
make: *** [Makefile:820: all-recursive] Error 1

The upstream bug: boostorg/process#96
Also see: https://stackoverflow.com/a/59338759

#22348 (comment):

This commit, containing the __kernel_entry SAL annotations was included in Boost Process as part of the 1.71.0 release, which broke support for compiling with mingw-w64 because it doesn't define the __kernel_entry SAL annotation (but it does define some others, i.e see sal.h).

A commit was made to remove the annotations, however, it hasn't made it into either of the two Boost releases that have happened since (1.75.0 & 1.76.0). Meaning that this is currently needed for all versions of Boost process from 1.71.0 onwards.

@theStack
Copy link
Contributor

Concept ACK

@maflcko
Copy link
Member

maflcko commented Jun 28, 2021

Is this also a fix for gitian/guix?

@hebasto
Copy link
Member Author

hebasto commented Jun 28, 2021 via email

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK 91c70a7

Tested on Windows 10 and 8 with cross compile from both Arch Linux and Ubuntu.
Also used this to cross-compile a GUI pr to test on windows.

master:
run into the same error when building

/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:208:51: error: expected ‘)’ before ‘*’ token
  208 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_system_query_information_p )(
      |                                    ~              ^~
      |                                                   )
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:223:51: error: expected ‘)’ before ‘*’ token
  223 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_query_object_p )(
      |                                    ~              ^~
      |                                                   )
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp: In function ‘boost::winapi::NTSTATUS_ boost::process::detail::windows::workaround::nt_system_query_information(boost::process::detail::windows::workaround::SYSTEM_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)’:
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:239:12: error: ‘nt_system_query_information_p’ does not name a type
  239 |     static nt_system_query_information_p f = reinterpret_cast<nt_system_query_information_p>(::boost::winapi::get_proc_address(h, "NtQuerySystemInformation"));
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handles.hpp:11,
                 from /home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/used_handles.hpp:17,
                 from /home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/async_in.hpp:20,
                 from /home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/async.hpp:49,
                 from /home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process.hpp:23,
                 from util/system.cpp:9:
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:241:14: error: ‘f’ was not declared in this scope
  241 |     return (*f)(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
      |              ^
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp: In function ‘boost::winapi::BOOL_ boost::process::detail::windows::workaround::nt_query_object(boost::winapi::HANDLE_, boost::process::detail::windows::workaround::OBJECT_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)’:
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:253:12: error: ‘nt_query_object_p’ does not name a type
  253 |     static nt_query_object_p f = reinterpret_cast<nt_query_object_p>(::boost::winapi::get_proc_address(h, "NtQueryObject"));
      |            ^~~~~~~~~~~~~~~~~
/home/xyz/Code/Bitcoin/test-cross/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:255:14: error: ‘f’ was not declared in this scope
  255 |     return (*f)(Handle, ObjectInformationClass, ObjectInformation, ObjectInformationLength, ReturnLength);
      |              ^

pr:
Builds and works fine 🥃

@fanquake
Copy link
Member

fanquake commented Jun 30, 2021

Concept ACK. I think the fix is correct, however this needs a better explanation than just linking to a Boost issue or stack overflow post (which just links back to the same Boost issue). Neither actually explain the problem or solution, other than, copy-pasting these lines "made the compilation error(s) go away". There's also no indication of when the fix is needed from, or can be dropped.

My understanding is that between Boost 1.64.0 and 1.70.0, there are no issues using Boost Process and mingw-w64. Although I haven't tested this.

This commit, containing the __kernel_entry SAL annotations was included in Boost Process as part of the 1.71.0 release, which broke support for compiling with mingw-w64 because it doesn't define the __kernel_entry SAL annotation (but it does define some others, i.e see sal.h).

A commit was made to remove the annotations, however, it hasn't made it into either of the two Boost releases that have happened since (1.75.0 & 1.76.0). Meaning that this is currently needed for all versions of Boost process from 1.71.0 onwards.

@fanquake fanquake added this to the 22.0 milestone Jul 1, 2021
Boost 1.71 has a broken compatibility with mingw-w64 compiler due to the
added __kernel_entry SAL annotations.
@hebasto
Copy link
Member Author

hebasto commented Jul 1, 2021

@fanquake Detailed info added to the OP, the commit message and code comments re-worded.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK 67669ab - thanks for updating this.

@fanquake fanquake merged commit 2749613 into bitcoin:master Jul 1, 2021
@hebasto hebasto deleted the 210627-boost branch July 1, 2021 12:19
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 1, 2021
…ocess

67669ab build: Fix Boost Process compatibility with mingw-w64 compiler (Hennadii Stepanov)

Pull request description:

  On master (9c3751a) the cross build for Win64 is broken if configured with `--enable-external-signer`:
  ```
  ...
    CXX      crypto/libbitcoin_crypto_base_a-chacha_poly_aead.o
  In file included from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handles.hpp:11,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/used_handles.hpp:17,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/async_in.hpp:20,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/async.hpp:49,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process.hpp:23,
                   from util/system.cpp:9:
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:208:51: error: expected ‘)’ before ‘*’ token
    208 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_system_query_information_p )(
        |                                    ~              ^~
        |                                                   )
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:223:51: error: expected ‘)’ before ‘*’ token
    223 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_query_object_p )(
        |                                    ~              ^~
        |                                                   )
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp: In function ‘boost::winapi::NTSTATUS_ boost::process::detail::windows::workaround::nt_system_query_information(boost::process::detail::windows::workaround::SYSTEM_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)’:
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:239:12: error: ‘nt_system_query_information_p’ does not name a type; did you mean ‘nt_system_query_information’?
    239 |     static nt_system_query_information_p f = reinterpret_cast<nt_system_query_information_p>(::boost::winapi::get_proc_address(h, "NtQuerySystemInformation"));
        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |            nt_system_query_information
  In file included from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handles.hpp:11,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/used_handles.hpp:17,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/async_in.hpp:20,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/async.hpp:49,
                   from /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process.hpp:23,
                   from util/system.cpp:9:
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:241:14: error: ‘f’ was not declared in this scope
    241 |     return (*f)(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
        |              ^
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp: In function ‘boost::winapi::BOOL_ boost::process::detail::windows::workaround::nt_query_object(boost::winapi::HANDLE_, boost::process::detail::windows::workaround::OBJECT_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)’:
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:253:12: error: ‘nt_query_object_p’ does not name a type; did you mean ‘nt_query_object’?
    253 |     static nt_query_object_p f = reinterpret_cast<nt_query_object_p>(::boost::winapi::get_proc_address(h, "NtQueryObject"));
        |            ^~~~~~~~~~~~~~~~~
        |            nt_query_object
  /home/hebasto/GitHub/bitcoin/depends/x86_64-w64-mingw32/include/boost/process/detail/windows/handle_workaround.hpp:255:14: error: ‘f’ was not declared in this scope
    255 |     return (*f)(Handle, ObjectInformationClass, ObjectInformation, ObjectInformationLength, ReturnLength);
        |              ^
  make[2]: *** [Makefile:9906: util/libbitcoin_util_a-system.o] Error 1
  make[2]: *** Waiting for unfinished jobs....
    CXX      crypto/libbitcoin_crypto_base_a-chacha20.o
  make[2]: Leaving directory '/home/hebasto/GitHub/bitcoin/src'
  make[1]: *** [Makefile:16141: all-recursive] Error 1
  make[1]: Leaving directory '/home/hebasto/GitHub/bitcoin/src'
  make: *** [Makefile:820: all-recursive] Error 1
  ```

  The upstream bug: boostorg/process#96
  Also see: https://stackoverflow.com/a/59338759

  bitcoin#22348 (comment):
  > [This commit](boostorg/process@7fc41b2), containing the `__kernel_entry` [SAL annotations](https://docs.microsoft.com/en-us/cpp/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects?view=msvc-160) was included in Boost Process as part of the `1.71.0` release, which broke support for compiling with mingw-w64 because it doesn't define the `__kernel_entry` SAL annotation (but it does define some others, i.e see [`sal.h`](https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/include/sal.h)).
  >
  > A [commit was made](boostorg/process@d7a721e) to remove the annotations, however, it hasn't made it into either of the two Boost releases that have happened since (1.75.0 & 1.76.0). Meaning that this is currently needed for all versions of Boost process from 1.71.0 onwards.

ACKs for top commit:
  fanquake:
    ACK 67669ab - thanks for updating this.

Tree-SHA512: 5931ca1fb77ce38c042cf5a7556add024ea2386c208bf26c792a8ca4a771d97fac9802c32fa8aa2e3de1ad35f3362d8c066f0a83ee675859d226c602fd0bcf93
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
Boost 1.71 has a broken compatibility with mingw-w64 compiler due to the
added __kernel_entry SAL annotations.

Github-Pull: bitcoin#22348
Rebased-From: 67669ab
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants