Repository: bitcoin/bitcoin (language: cpp)

Issue:
Homebrew Boost 1.78 breaks external signer configure
Test on macOS 12.2.1 against the master branch. #24397 doesn't fix it.

```
brew info boost
boost: stable 1.78.0 (bottled), HEAD
...
./configure --enable-external-signer
...
checking for boostlib >= 1.64.0 (106400)... yes
checking whether Boost.Process can be used... no
configure: error: External signing is not supported for this Boost version
```

It does work with boost 1.76 (there was no 1.77 release in home-brew):

```
brew install boost@1.76
...
LDFLAGS="-L/usr/local/opt/boost@1.76/lib" CPPFLAGS="-I/usr/local/opt/boost@1.76/include" ./configure --enable-external-signer
...
checking for boostlib >= 1.64.0 (106400)... yes
checking whether Boost.Process can be used... yes
...
Options used to compile and link:
  external signer = yes
```

There's nothing in the release notes about Boost.Process for either [1.77](https://www.boost.org/users/history/version_1_77_0.html) or [1.78](https://www.boost.org/users/history/version_1_78_0.html).

The Homebrew [formula changes](https://github.com/Homebrew/homebrew-core/commits/master/Formula/boost.rb) are nothing but a trivial version and hash bump.


Discussion / hints:
The configure check is failing because of this issue: https://github.com/boostorg/process/issues/235
```bash
configure:32793: checking whether Boost.Process can be used
configure:32806: g++ -std=c++17 -o conftest -g -O2  -DHAVE_BUILD_INFO -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -DPROVIDE_FUZZ_MAIN_FUNCTION  -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-dead_strip_dylibs conftest.cpp  >&5
In file included from conftest.cpp:77:
In file included from /usr/local/include/boost/process.hpp:24:
In file included from /usr/local/include/boost/process/async_system.hpp:22:
In file included from /usr/local/include/boost/process/child.hpp:22:
In file included from /usr/local/include/boost/process/detail/execute_impl.hpp:24:
/usr/local/include/boost/process/detail/posix/executor.hpp:156:36: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'int' in initializer list [-Wc++11-narrowing]
        int data[2] = {ec.value(), len + 1};
                                   ^~~~~~~
/usr/local/include/boost/process/detail/posix/executor.hpp:156:36: note: insert an explicit cast to silence this issue
        int data[2] = {ec.value(), len + 1};
                                   ^~~~~~~
                                   static_cast<int>( )
1 error generated.
```
Ok, we should probably just document the workaround and point to this issue for when the upstream fix is ready and released.

Fix patch:
diff --git a/configure.ac b/configure.ac
index 63ff6a1ebdcc4..d8e80d3f46d7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1446,6 +1446,10 @@ if test "$use_external_signer" != "no"; then
     ;;
     *)
       AC_MSG_CHECKING([whether Boost.Process can be used])
+      TEMP_CXXFLAGS="$CXXFLAGS"
+      dnl Boost 1.78 requires the following workaround.
+      dnl See: https://github.com/boostorg/process/issues/235
+      CXXFLAGS="$CXXFLAGS -Wno-error=narrowing"
       TEMP_CPPFLAGS="$CPPFLAGS"
       CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
       TEMP_LDFLAGS="$LDFLAGS"
@@ -1456,6 +1460,7 @@ if test "$use_external_signer" != "no"; then
         [have_boost_process="no"])
       LDFLAGS="$TEMP_LDFLAGS"
       CPPFLAGS="$TEMP_CPPFLAGS"
+      CXXFLAGS="$TEMP_CXXFLAGS"
       AC_MSG_RESULT([$have_boost_process])
       if test "$have_boost_process" = "yes"; then
         use_external_signer="yes"
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 8e45453d31040..a7e66defcdf6d 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -6,7 +6,16 @@
 #include <util/system.h>
 
 #ifdef ENABLE_EXTERNAL_SIGNER
+#if defined(__GNUC__)
+// Boost 1.78 requires the following workaround.
+// See: https://github.com/boostorg/process/issues/235
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnarrowing"
+#endif
 #include <boost/process.hpp>
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
 #endif // ENABLE_EXTERNAL_SIGNER
 
 #include <chainparamsbase.h>


Test patch:
diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp
index 9c6950f11f9a9..3f5353b5a2bb0 100644
--- a/src/test/system_tests.cpp
+++ b/src/test/system_tests.cpp
@@ -12,7 +12,16 @@
 // For details see https://github.com/bitcoin/bitcoin/pull/22348.
 #define __kernel_entry
 #endif
+#if defined(__GNUC__)
+// Boost 1.78 requires the following workaround.
+// See: https://github.com/boostorg/process/issues/235
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnarrowing"
+#endif
 #include <boost/process.hpp>
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
 #endif // ENABLE_EXTERNAL_SIGNER
 
 #include <boost/test/unit_test.hpp>