From b759074f0313c3070b415fc770bc269151d5b557 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 22 Oct 2026 19:45:37 -0400 Subject: [PATCH] Pin softfloat 3.0.0#3: thread-local rounding and exception state Moves the wire registry baseline to abed0cc1 (the wire-vcpkg-registry#22 merge) and the softfloat override to 3.0.0#3, which builds Wire-Network/berkeley-softfloat-3@e9bb379 (its PR #5): THREAD_LOCAL is now a PUBLIC definition of the softfloat target, so softfloat_roundingMode, softfloat_detectTininess, softfloat_exceptionFlags and extF80_roundingPrecision are per thread instead of process globals shared by the read-only transaction threads and the sys-vm runtimes. Ports gofractally/eos-vm#24 and #25 to Wire's vcpkg-built softfloat. Also defines SOFTFLOAT_DISABLE_LEGACY_TYPE_ALIASES tree-wide and, with THREAD_LOCAL, on the exported SysioChain interface (which links the archive directly): since berkeley-softfloat-3@67af45c the port no longer forces the alias disable, and the legacy float32_t/float64_t aliases collide with arm_neon.h, which Boost.Unordered pulls into most chain TUs on arm64. Adds softfloat_thread_local_tests: a worker thread starts from the default rounding mode and flags and leaks nothing back. Change-Id: Id884de24d946846e8802a83c84c369862d4118f0 --- CMakeLists.txt | 3 ++ cmake/SysioTester.cmake.in | 7 +++ unittests/softfloat_thread_local_tests.cpp | 62 ++++++++++++++++++++++ vcpkg-configuration.json | 4 +- vcpkg.json | 2 +- 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 unittests/softfloat_thread_local_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 502056f221..a7ac639075 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,9 @@ set(CMAKE_DISABLE_FIND_PACKAGE_OpenSSL On) # many tests require handling of signals themselves and even when they don't we'd like for them to generate a core dump, this # is effectively --catch_system_errors=no broadly across all tests add_compile_definitions(BOOST_TEST_DEFAULTS_TO_CORE_DUMP) +# softfloat's legacy float32_t/float64_t aliases collide with arm_neon.h, which Boost.Unordered pulls in on arm64; +# nothing here uses them. +add_compile_definitions(SOFTFLOAT_DISABLE_LEGACY_TYPE_ALIASES) add_definitions(-DSYSIO_SYS_VM_RUNTIME_ENABLED) diff --git a/cmake/SysioTester.cmake.in b/cmake/SysioTester.cmake.in index 526fc41ca2..d260495939 100644 --- a/cmake/SysioTester.cmake.in +++ b/cmake/SysioTester.cmake.in @@ -311,6 +311,13 @@ target_include_directories(SysioChain INTERFACE @CMAKE_INSTALL_FULL_INCLUDEDIR@/wasm-jit @CMAKE_INSTALL_FULL_INCLUDEDIR@/softfloat) +# softfloat is linked above as a raw archive, so the definitions its CMake package carries are repeated: +# THREAD_LOCAL is the storage class the archive's per-thread state was built with, and the alias disable +# keeps softfloat's legacy float32_t/float64_t typedefs away from arm_neon.h on arm64. +target_compile_definitions(SysioChain INTERFACE + THREAD_LOCAL=__thread + SOFTFLOAT_DISABLE_LEGACY_TYPE_ALIASES) + add_library(SysioTester INTERFACE) target_link_libraries(SysioTester INTERFACE diff --git a/unittests/softfloat_thread_local_tests.cpp b/unittests/softfloat_thread_local_tests.cpp new file mode 100644 index 0000000000..906486d2fc --- /dev/null +++ b/unittests/softfloat_thread_local_tests.cpp @@ -0,0 +1,62 @@ +/** + * Berkeley SoftFloat keeps the rounding mode and exception flags in per-thread state (softfloat 3.0.0#3): a + * worker thread starts from the defaults and leaks nothing back to the thread that spawned it. With the + * process-global state of 3.0.0#2 every check below fails. + */ +extern "C" { +#include +} +#include + +#include + +#include +#include + +namespace { + +const softfloat32_t one = {0x3f800000u}; +const softfloat32_t zero = {0u}; +const softfloat32_t minus_one = {0xbf800000u}; + +/// Other suites may leave the calling thread's state behind; start from the defaults and put them back. +struct softfloat_state_guard { + softfloat_state_guard() { reset(); } + ~softfloat_state_guard() { reset(); } + static void reset() { + softfloat_roundingMode = softfloat_round_near_even; + softfloat_exceptionFlags = 0; + } +}; + +} // namespace + +BOOST_AUTO_TEST_SUITE(softfloat_thread_local_tests) + +BOOST_AUTO_TEST_CASE(rounding_mode_and_exception_flags_are_per_thread) { + softfloat_state_guard guard; + + softfloat_roundingMode = softfloat_round_max; + f32_div(one, zero); + BOOST_CHECK_EQUAL(unsigned(softfloat_exceptionFlags), unsigned(softfloat_flag_infinite)); + + unsigned worker_mode = ~0u; + unsigned worker_flags_before = ~0u; + unsigned worker_flags_after = 0; + std::thread worker([&] { + worker_mode = softfloat_roundingMode; + worker_flags_before = softfloat_exceptionFlags; + softfloat_roundingMode = softfloat_round_minMag; + f32_sqrt(minus_one); + worker_flags_after = softfloat_exceptionFlags; + }); + worker.join(); + + BOOST_CHECK_EQUAL(worker_mode, unsigned(softfloat_round_near_even)); + BOOST_CHECK_EQUAL(worker_flags_before, 0u); + BOOST_CHECK_EQUAL(worker_flags_after, unsigned(softfloat_flag_invalid)); + BOOST_CHECK_EQUAL(unsigned(softfloat_roundingMode), unsigned(softfloat_round_max)); + BOOST_CHECK_EQUAL(unsigned(softfloat_exceptionFlags), unsigned(softfloat_flag_infinite)); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 1f50d78f23..b0062a485d 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -10,8 +10,8 @@ { "kind": "git", "repository": "https://github.com/wire-network/wire-vcpkg-registry", - "baseline": "2806c1bc39dda520c100b5ea75aef8aa2693a85f", - "reference": "2806c1bc39dda520c100b5ea75aef8aa2693a85f", + "baseline": "abed0cc16f9e9514fec4a0b6751bc34ec427ca0d", + "reference": "abed0cc16f9e9514fec4a0b6751bc34ec427ca0d", "packages": [ "boost", "softfloat", diff --git a/vcpkg.json b/vcpkg.json index 6ab201bad6..c595a60419 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -147,7 +147,7 @@ }, { "name": "softfloat", - "version": "3.0.0#2" + "version": "3.0.0#3" }, { "name": "wire-sys-vm",