From cdb7eda54f416d242409047148077d1cf8633914 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Tue, 20 Oct 2026 19:52:44 +0800 Subject: [PATCH] Update GMP to 6.3.0 to Avoid the x18 Register on Apple Silicon (#16686) * Update GMP to 6.3.0 to Avoid the x18 Register on Apple Silicon GMP 6.2.1's arm64 assembly keeps loop counters in x18, which Apple reserves and macOS zeroes on every return to user space (syscalls, page faults, preemption). When that happens inside one of those loops the counter underflows and the routine walks the stack until the guard page: EXC_BAD_ACCESS / SIGBUS inside __gmpn_* whenever CGAL falls back to exact arithmetic (texture import boundary smoothing, text emboss cuts, mesh repair, mesh boolean). 6.3.0 moves those counters to ordinary temporaries (gmp-6.2 changeset f4ff6ff711ed); no x18 use remains under mpn/arm64. The GCC 15 patch applies unchanged apart from a line offset. The tarball comes from the GNU mirror, like MPFR. Windows is unaffected: MSVC copies the prebuilt libgmp-10 and the arm64 job stages MSYS2's GMP. Built with the deps recipe flags and ran make check on Linux x86_64 (clang 18, 200/200) and macOS arm64 (Apple clang, 199/199). * Add gmplib.org as a Fallback Download for GMP Same two-source pattern as MPFR: the GNU mirror first, the project's own server second, one hash for both. * Use the OrcaSlicer_deps Mirror as the GMP Fallback Download SoftFever published gmp-6.3.0.tar.xz in SoftFever/OrcaSlicer_deps, the same mirror 6.2.1 came from. Both sources serve the .tar.xz release file, byte-identical (one SHA-256): the GNU server first, the mirror as fallback. * Stage GMP 6.3.0 for the Flatpak Build The Flatpak sandbox has no network, so the manifest pre-downloads every dependency tarball into external-packages/. Point the GMP entry at the 6.3.0 .tar.xz the deps recipe now expects. --- deps/GMP/GMP.cmake | 8 ++++++-- scripts/flatpak/com.orcaslicer.OrcaSlicer.yml | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/deps/GMP/GMP.cmake b/deps/GMP/GMP.cmake index b3ba181753..4f2beedb4f 100644 --- a/deps/GMP/GMP.cmake +++ b/deps/GMP/GMP.cmake @@ -59,9 +59,13 @@ else () set(_cross_compile_arg --host=${TOOLCHAIN_PREFIX}) endif () + # 6.3.0 is the first release whose arm64 assembly avoids x18, which macOS + # reserves and zeroes on every return to user space; 6.2.1 crashes on Apple + # silicon whenever CGAL falls back to exact arithmetic. ExternalProject_Add(dep_GMP - URL https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2 - URL_HASH SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c + URL https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz + https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.3.0/gmp-6.3.0.tar.xz + URL_HASH SHA256=a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898 DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/GMP PATCH_COMMAND git apply ${GMP_DIRECTORY_FLAG} --verbose ${CMAKE_CURRENT_LIST_DIR}/0001-GMP_GCC15.patch BUILD_IN_SOURCE ON diff --git a/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml b/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml index cca417f735..27c9fcfdc2 100644 --- a/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml +++ b/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml @@ -226,10 +226,10 @@ modules: sha256: f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81 dest: external-packages/OpenVDB - # GMP 6.2.1 + # GMP 6.3.0 - type: file - url: https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2 - sha256: eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c + url: https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz + sha256: a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898 dest: external-packages/GMP # MPFR 4.2.2