Fix building with GCC 15 (#9643)

* Patch GMP to build on GCC15

* Add cstdint include - GCC15 defaults to C23

* Update GMP PATCH_COMMAND to work without a valid git repo

* Set GMP_DIRECTORY_FLAG
This commit is contained in:
Maciej Lisiewski 2025-05-16 17:48:59 +02:00 committed by GitHub
parent 9110dd51dc
commit 2490564f7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 6 deletions

32
deps/GMP/0001-GMP_GCC15.patch vendored Normal file
View File

@ -0,0 +1,32 @@
--- GMP/acinclude.m4 2025-05-14 18:50:11.396354745 -0400
+++ GMP/acinclude.m4.2 2025-05-14 18:57:20.757853503 -0400
@@ -609,7 +609,7 @@
#if defined (__GNUC__) && ! defined (__cplusplus)
typedef unsigned long long t1;typedef t1*t2;
-void g(){}
+void g(int,t1 const*,t1,t2,t1 const*,int){}
void h(){}
static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}
--- GMP/configure 2025-05-14 19:33:35.730593315 -0400
+++ GMP/configure 2025-05-14 19:35:37.805619186 -0400
@@ -6526,7 +6526,7 @@
#if defined (__GNUC__) && ! defined (__cplusplus)
typedef unsigned long long t1;typedef t1*t2;
-void g(){}
+void g(int,t1 const*,t1,t2,t1 const*,int){}
void h(){}
static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}
@@ -8145,7 +8145,7 @@
#if defined (__GNUC__) && ! defined (__cplusplus)
typedef unsigned long long t1;typedef t1*t2;
-void g(){}
+void g(int,t1 const*,t1,t2,t1 const*,int){}
void h(){}
static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}

13
deps/GMP/GMP.cmake vendored
View File

@ -1,9 +1,13 @@
set(_srcdir ${CMAKE_CURRENT_LIST_DIR}/gmp)
if (IN_GIT_REPO)
set(GMP_DIRECTORY_FLAG --directory ${BINARY_DIR_REL}/dep_GMP-prefix/src/dep_GMP)
endif ()
if (MSVC)
set(_output ${DESTDIR}/include/gmp.h
${DESTDIR}/lib/libgmp-10.lib
set(_output ${DESTDIR}/include/gmp.h
${DESTDIR}/lib/libgmp-10.lib
${DESTDIR}/bin/libgmp-10.dll)
add_custom_command(
@ -12,7 +16,7 @@ if (MSVC)
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.lib ${DESTDIR}/lib/
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.dll ${DESTDIR}/bin/
)
add_custom_target(dep_GMP SOURCES ${_output})
else ()
@ -59,7 +63,8 @@ else ()
URL https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2
URL_HASH SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/GMP
BUILD_IN_SOURCE ON
PATCH_COMMAND git apply ${GMP_DIRECTORY_FLAG} --verbose ${CMAKE_CURRENT_LIST_DIR}/0001-GMP_GCC15.patch
BUILD_IN_SOURCE ON
CONFIGURE_COMMAND env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure ${_cross_compile_arg} --enable-shared=no --enable-cxx=yes --enable-static=yes "--prefix=${DESTDIR}" ${_gmp_build_tgt}
BUILD_COMMAND make -j
INSTALL_COMMAND make install

View File

@ -24,6 +24,7 @@
#include <algorithm> // std::sort
#include <cstdlib>
#include <tuple> // std::make_tuple std::get<>
#include <cstdint>
double square_root(const double& number)
@ -716,7 +717,7 @@
vec2 pp; /*projected p */
#if 0
int k = 0;
for (int j = 0; j < 3; j++)
{ // for each component
if (j != polygon_plane_normal_largest_component)
@ -830,7 +831,7 @@
}
char compute_segment_intersection(
const vec2& a, const vec2& b, const vec2& c,
const vec2& a, const vec2& b, const vec2& c,
const vec2& d, vec2& p, double& s, double& t)
{
// double s, t; /* The two parameters of the parametric eqns. */