From 614c328da3b0e06fdae684cced55aeaf69b88ac6 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Fri, 4 Dec 2026 12:26:45 +0100 Subject: [PATCH] Remove MSVC __assume from GECODE_ASSUME and fix Windows ARM64 build Release builds made with Visual Studio 2026 (MSVC 19.52.37029) lose solutions on basic integer constraints. On a 26-case reproducer from MiniZinc's FindMUS team, 21 cases return too few solutions, including length-1 comparisons such as x < y (0 of 3) and x == y (1 of 3) and a satisfiable 3x3 model that reports UNSATISFIABLE. gecode-test fails immediately on Int::Distinct::Bnd::Dense. Rebuilding Gecode 6.6.1 on GitHub Actions with MSVC 19.52 reproduces the same 21 failures on both windows-11-arm (ARM64) and windows-2025 (x64) when GECODE_ASSUME expands to __assume. Defining GECODE_ASSUME empty makes all 26 cases and the Int::Rel and Int::Distinct tests pass on both architectures. The asserted properties hold and are checked in Debug builds in per-PR CI, so this is an MSVC 19.52 optimizer bug triggered by __assume. It was only noticed on ARM64 because Gecode CI and MiniZinc's x64 package still build with Visual Studio 2022. Define GECODE_ASSUME(p) as assert((p)) on all compilers in gecode/support/macros.hpp; non-MSVC compilers never used an optimizer hint there. Pass /bigobj to MSVC C++ compiles in CMakeLists.txt so gecode/int/extensional-tuple-set.cpp builds on ARM64 without hitting C1128 (too many sections). Add a build-windows-arm64 job to .github/workflows/release-matrix.yml on windows-11-arm using the runner's default Visual Studio in a static Release build that runs the check target. That job would have caught both problems. --- .github/workflows/release-matrix.yml | 32 ++++++++++++++++++++++++++++ CMakeLists.txt | 6 ++++++ changelog.in | 20 +++++++++++++++++ gecode/support/macros.hpp | 16 ++++---------- 4 files changed, 62 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-matrix.yml b/.github/workflows/release-matrix.yml index bd4abba32f..b6823e5305 100644 --- a/.github/workflows/release-matrix.yml +++ b/.github/workflows/release-matrix.yml @@ -212,6 +212,38 @@ jobs: $env:PATH = "$prefix\bin;$env:PATH" ctest --test-dir $build -C $env:BUILD_TYPE --output-on-failure + # Windows on ARM64 with the runner's newest Visual Studio. It catches ARM64 + # build failures and miscompilation by newer MSVC releases than CI uses. + build-windows-arm64: + runs-on: windows-11-arm + + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + + - name: Install uv + uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 + with: + enable-cache: false + + - name: Configure CMake + shell: pwsh + run: > + cmake -S "${{ github.workspace }}" -B "${{ github.workspace }}\\build" + -A ARM64 + -DGECODE_ENABLE_QT=OFF + -DGECODE_ENABLE_GIST=OFF + -DGECODE_ENABLE_MPFR=OFF + -DGECODE_BUILD_SHARED=OFF + -DGECODE_BUILD_STATIC=ON + + - name: Build + shell: pwsh + run: cmake --build "${{ github.workspace }}\\build" --config ${{ env.BUILD_TYPE }} + + - name: Check + shell: pwsh + run: cmake --build "${{ github.workspace }}\\build" --config ${{ env.BUILD_TYPE }} --target check + build-windows-vcpkg: runs-on: windows-2022 diff --git a/CMakeLists.txt b/CMakeLists.txt index cfb588305f..b4d902b122 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,6 +248,12 @@ if(GECODE_SANITIZER_NORMALIZED) endif() endif() +# Some sources exceed MSVC's default object-file section limit when targeting +# ARM64 (C1128). +if(MSVC) + add_compile_options($<$:/bigobj>) +endif() + # Enable the dependencies required by higher-level modules. if(GECODE_ENABLE_SET_VARS) gecode_force_option_on(GECODE_ENABLE_INT_VARS "Set variables require int variables") diff --git a/changelog.in b/changelog.in index 543c60f69a..fd3b839529 100644 --- a/changelog.in +++ b/changelog.in @@ -722,6 +722,26 @@ Rank: minor The -replay test option now takes the complete random state printed for a failed iteration. +[ENTRY] +Module: support +What: bug +Rank: major +Thanks: Kevin Leo +[DESCRIPTION] +Fix wrong answers in Release builds made with Visual Studio 2026 (MSVC +19.52) on x64 and ARM64. Search lost solutions on basic integer constraints +such as x < y, x == y, and lexicographic order, and could report +satisfiable models as unsatisfiable. GECODE_ASSUME now expands to assert +instead of MSVC's __assume, which triggered the miscompilation. + +[ENTRY] +Module: other +What: bug +Rank: minor +[DESCRIPTION] +Fix Windows ARM64 builds under MSVC failing with C1128 (too many sections) +in gecode/int/extensional-tuple-set.cpp by passing /bigobj to C++ compiles. + [RELEASE] Version: 6.6.1 Date: 2026-11-29 diff --git a/gecode/support/macros.hpp b/gecode/support/macros.hpp index d7cef4ba5a..3240bf6d5d 100644 --- a/gecode/support/macros.hpp +++ b/gecode/support/macros.hpp @@ -98,20 +98,12 @@ * \def GECODE_ASSUME * \brief Assert certain property * - * This might be used for optimization as well (for example, - * Microsoft Visual C++), otherwise it behaves like any - * assert. + * Expands to \c assert on all compilers and is not given to the + * optimizer as an assumption. Under Visual Studio 2026 (MSVC 19.52) on + * x64 and ARM64, \c __assume causes Release builds to lose solutions on + * integer constraints. * */ - -#if defined(_MSC_VER) && defined(NDEBUG) - -#define GECODE_ASSUME(p) __assume((p)) - -#else - #define GECODE_ASSUME(p) assert((p)) -#endif - // STATISTICS: support-any