From a9d426a3dcc74803d0013836ecf0ab93a973a71e Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 1 May 2025 17:09:45 +0800 Subject: [PATCH] Fix Xcode 16.3 build (#9422) * Fix build with Xcode 16.3 * Simplify OpenVDB patch, from https://github.com/AcademySoftwareFoundation/openvdb/commit/930c3acb8e0c7c2f1373f3a70dc197f5d04dfe74#diff-bc3061cc2fe6c64a3d67c8350330bb3a530d01037faace6da27ad9a12aa03e29 * Fix CGAL header under clang 19 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281880 * Fix compile error due to removal of base template for `std::char_traits` in clang 19 https://releases.llvm.org/19.1.0/projects/libcxx/docs/ReleaseNotes.html#deprecations-and-removals --- deps/CGAL/0001-clang19.patch | 59 ++++++++++++++++++++++++++++ deps/CGAL/CGAL.cmake | 5 +++ deps/OpenCV/0002-clang19-macos.patch | 54 +++++++++++++++++++++++++ deps/OpenCV/OpenCV.cmake | 2 +- deps/OpenVDB/0001-clang19.patch | 29 ++++++++++++++ deps/OpenVDB/OpenVDB.cmake | 5 +++ deps/PNG/0002-clang19-macos.patch | 29 ++++++++++++++ deps/PNG/PNG.cmake | 4 +- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/ModelMall.cpp | 2 +- src/slic3r/GUI/Project.cpp | 2 +- src/slic3r/GUI/WebDownPluginDlg.cpp | 2 +- src/slic3r/GUI/WebGuideDialog.cpp | 2 +- 13 files changed, 189 insertions(+), 8 deletions(-) create mode 100644 deps/CGAL/0001-clang19.patch create mode 100644 deps/OpenCV/0002-clang19-macos.patch create mode 100644 deps/OpenVDB/0001-clang19.patch create mode 100644 deps/PNG/0002-clang19-macos.patch diff --git a/deps/CGAL/0001-clang19.patch b/deps/CGAL/0001-clang19.patch new file mode 100644 index 0000000000..92a0293735 --- /dev/null +++ b/deps/CGAL/0001-clang19.patch @@ -0,0 +1,59 @@ +--- a/BGL/include/CGAL/boost/graph/iterator.h 2022-10-07 19:04:41 UTC ++++ b/BGL/include/CGAL/boost/graph/iterator.h +@@ -213,18 +213,7 @@ class Halfedge_around_source_iterator { (public) + {} + + #ifndef DOXYGEN_RUNNING +- // design patter: "safe bool" +- // will be replaced by explicit operator bool with C++11 +- typedef void (Halfedge_around_source_iterator::*bool_type)() const; + +- void this_type_does_not_support_comparisons() const {} +- +- operator bool_type() const +- { +- return (! (this->base() == nullptr)) ? +- &Halfedge_around_source_iterator::this_type_does_not_support_comparisons : 0; +- } +- + bool operator==( const Self& i) const { + CGAL_assertion( anchor == anchor); + return ( g == i.g) && ( pos == i.pos) && ( winding == i.winding); +@@ -313,18 +302,7 @@ class Halfedge_around_target_iterator { (public) + {} + + #ifndef DOXYGEN_RUNNING +- // design patter: "safe bool" +- // will be replaced by explicit operator bool with C++11 +- typedef void (Halfedge_around_target_iterator::*bool_type)() const; + +- void this_type_does_not_support_comparisons() const {} +- +- operator bool_type() const +- { +- return (! (this->base() == nullptr)) ? +- &Halfedge_around_target_iterator::this_type_does_not_support_comparisons : 0; +- } +- + bool operator==( const Self& i) const { + CGAL_assertion( anchor == anchor); + return ( g == i.g) && ( pos == i.pos) && ( winding == i.winding); +@@ -411,18 +389,6 @@ class Halfedge_around_face_iterator { (public) + const value_type& operator * ( ) const { return pos; } + pointer operator -> ( ) { return &pos; } + const value_type* operator -> ( ) const { return &pos; } +- +- // design patter: "safe bool" +- // will be replaced by explicit operator bool with C++11 +- typedef void (Halfedge_around_face_iterator::*bool_type)() const; +- +- void this_type_does_not_support_comparisons() const {} +- +- operator bool_type() const +- { +- return (! (this->base() == nullptr)) ? +- &Halfedge_around_face_iterator::this_type_does_not_support_comparisons : 0; +- } + + bool operator==( const Self& i) const { + CGAL_assertion( anchor == anchor); diff --git a/deps/CGAL/CGAL.cmake b/deps/CGAL/CGAL.cmake index 18fee7c15e..73eee6701b 100644 --- a/deps/CGAL/CGAL.cmake +++ b/deps/CGAL/CGAL.cmake @@ -1,3 +1,7 @@ +if (IN_GIT_REPO) + set(CGAL_DIRECTORY_FLAG --directory ${BINARY_DIR_REL}/dep_CGAL-prefix/src/dep_CGAL) +endif () + orcaslicer_add_cmake_project( CGAL # GIT_REPOSITORY https://github.com/CGAL/cgal.git @@ -5,6 +9,7 @@ orcaslicer_add_cmake_project( # For whatever reason, this keeps downloading forever (repeats downloads if finished) URL https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip URL_HASH SHA256=d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0 + PATCH_COMMAND git apply ${CGAL_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-clang19.patch DEPENDS dep_Boost dep_GMP dep_MPFR ) diff --git a/deps/OpenCV/0002-clang19-macos.patch b/deps/OpenCV/0002-clang19-macos.patch new file mode 100644 index 0000000000..84eb522ea3 --- /dev/null +++ b/deps/OpenCV/0002-clang19-macos.patch @@ -0,0 +1,54 @@ +From 893b8113f04d408cc6177c6de19c9889a48faa24 Mon Sep 17 00:00:00 2001 +From: Zixu Wang +Date: Thu, 18 Jan 2024 11:12:00 -0800 +Subject: [PATCH] Fix unused platform check and configuration for macOS + +In a similar manner as zlib (https://github.com/madler/zlib/pull/895), +libpng contains a header configuration that's no longer valid and +hasn't been exercised for the macOS target. + +- The target OS conditional macros are misused. Specifically + `TARGET_OS_MAC` covers all Apple targets, including iOS, and it + should not be checked with `#if defined` as they would always be + defined (to either 1 or 0) on Apple platforms. +- `#include ` no longer works for the macOS target and results + in a compilation failure. macOS ships all required functions in + `math.h`, and clients should use `math.h` instead. + +This problem has not been noticed until a recent extension in clang +(https://github.com/llvm/llvm-project/pull/74676) exposed the issue +and broke libpng builds on Apple platforms. The failure can be +reproduced now by adding `#include ` before the +block. + +Signed-off-by: Cosmin Truta +--- + AUTHORS | 2 ++ + pngpriv.h | 14 ++------------ + 2 files changed, 4 insertions(+), 12 deletions(-) + +diff --git a/3rdparty/libpng/pngpriv.h b/3rdparty/libpng/pngpriv.h +index 6c7280cf53..190eb85cbf 100644 +--- a/3rdparty/libpng/pngpriv.h ++++ b/3rdparty/libpng/pngpriv.h +@@ -556,18 +556,8 @@ + */ + # include + +-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ +- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +- /* We need to check that hasn't already been included earlier +- * as it seems it doesn't agree with , yet we should really use +- * if possible. +- */ +-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +-# include +-# endif +-# else +-# include +-# endif ++# include ++ + # if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 diff --git a/deps/OpenCV/OpenCV.cmake b/deps/OpenCV/OpenCV.cmake index 23cbafa2a6..3794094fcf 100644 --- a/deps/OpenCV/OpenCV.cmake +++ b/deps/OpenCV/OpenCV.cmake @@ -11,7 +11,7 @@ endif () orcaslicer_add_cmake_project(OpenCV URL https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz URL_HASH SHA256=1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277 - PATCH_COMMAND git apply ${OpenCV_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-vs2022.patch + PATCH_COMMAND git apply ${OpenCV_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-vs2022.patch ${CMAKE_CURRENT_LIST_DIR}/0002-clang19-macos.patch CMAKE_ARGS -DBUILD_SHARED_LIBS=0 -DBUILD_PERE_TESTS=OFF diff --git a/deps/OpenVDB/0001-clang19.patch b/deps/OpenVDB/0001-clang19.patch new file mode 100644 index 0000000000..f9843ba267 --- /dev/null +++ b/deps/OpenVDB/0001-clang19.patch @@ -0,0 +1,29 @@ +--- a/openvdb/openvdb/tree/NodeManager.h 2023-11-01 20:31:11 UTC ++++ b/openvdb/openvdb/tree/NodeManager.h +@@ -327,7 +327,7 @@ class NodeList (private) + void operator()(const NodeRange& range) const + { + for (typename NodeRange::Iterator it = range.begin(); it; ++it) { +- OpT::template eval(mNodeOp, it); ++ OpT::eval(mNodeOp, it); + } + } + const NodeOp mNodeOp; +@@ -347,7 +347,7 @@ class NodeList (private) + void operator()(const NodeRange& range) const + { + for (typename NodeRange::Iterator it = range.begin(); it; ++it) { +- OpT::template eval(mNodeOp, it); ++ OpT::eval(mNodeOp, it); + } + } + const NodeOp& mNodeOp; +@@ -372,7 +372,7 @@ class NodeList (private) + void operator()(const NodeRange& range) + { + for (typename NodeRange::Iterator it = range.begin(); it; ++it) { +- OpT::template eval(*mNodeOp, it); ++ OpT::eval(*mNodeOp, it); + } + } + void join(const NodeReducer& other) diff --git a/deps/OpenVDB/OpenVDB.cmake b/deps/OpenVDB/OpenVDB.cmake index 7080b8b5d5..df6ad9c913 100644 --- a/deps/OpenVDB/OpenVDB.cmake +++ b/deps/OpenVDB/OpenVDB.cmake @@ -6,10 +6,15 @@ else() set(_build_static ON) endif() +if (IN_GIT_REPO) + set(OPENVDB_DIRECTORY_FLAG --directory ${BINARY_DIR_REL}/dep_OpenVDB-prefix/src/dep_OpenVDB) +endif () + orcaslicer_add_cmake_project(OpenVDB # support vs2022, update to 8.2 URL https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip URL_HASH SHA256=f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81 + PATCH_COMMAND git apply ${OPENVDB_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-clang19.patch DEPENDS dep_TBB dep_Blosc dep_OpenEXR dep_Boost CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON diff --git a/deps/PNG/0002-clang19-macos.patch b/deps/PNG/0002-clang19-macos.patch new file mode 100644 index 0000000000..69fd888a81 --- /dev/null +++ b/deps/PNG/0002-clang19-macos.patch @@ -0,0 +1,29 @@ +--- a/pngpriv.h 2025-04-20 19:36:04.000000000 ++++ b/pngpriv.h 2025-04-20 19:35:55.000000000 +@@ -511,24 +511,14 @@ + * DBL_DIG Maximum number of decimal digits (can be set to any constant) + * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) + * DBL_MAX Maximum floating point number (can be set to an arbitrary value) + */ + # include + +-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ +- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +- /* We need to check that hasn't already been included earlier +- * as it seems it doesn't agree with , yet we should really use +- * if possible. +- */ +-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +-# include +-# endif +-# else +-# include +-# endif ++# include ++ + # if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ + # include + # endif diff --git a/deps/PNG/PNG.cmake b/deps/PNG/PNG.cmake index 313a147bab..332fdfe274 100644 --- a/deps/PNG/PNG.cmake +++ b/deps/PNG/PNG.cmake @@ -12,7 +12,7 @@ if(APPLE AND IS_CROSS_COMPILE) GIT_TAG v1.6.35 DEPENDS ${ZLIB_PKG} PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df && - ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/macos-arm64.patch + ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/macos-arm64.patch ${CMAKE_CURRENT_LIST_DIR}/0002-clang19-macos.patch CMAKE_ARGS -DPNG_SHARED=OFF -DPNG_STATIC=ON @@ -24,7 +24,7 @@ if(APPLE AND IS_CROSS_COMPILE) else () set(_patch_step "") if (APPLE) - set(_patch_step PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/PNG.patch) + set(_patch_step PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/PNG.patch ${CMAKE_CURRENT_LIST_DIR}/0002-clang19-macos.patch) endif () orcaslicer_add_cmake_project(PNG # GIT_REPOSITORY https://github.com/glennrp/libpng.git diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index dbbf21ad2d..9c2d46512d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4053,7 +4053,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt) try { auto evt_str = evt.GetString(); if (!evt_str.empty()) { - json j = json::parse(evt_str); + json j = json::parse(evt_str.utf8_string()); if (j.contains("code")) { if (!j["code"].is_null()) code = j["code"].get(); diff --git a/src/slic3r/GUI/ModelMall.cpp b/src/slic3r/GUI/ModelMall.cpp index 45833ba80c..f5a6b6d4af 100644 --- a/src/slic3r/GUI/ModelMall.cpp +++ b/src/slic3r/GUI/ModelMall.cpp @@ -124,7 +124,7 @@ namespace GUI { { try { wxString strInput = evt.GetString(); - json j = json::parse(strInput); + json j = json::parse(strInput.utf8_string()); wxString strCmd = j["command"]; diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index e69ba143db..8e06180f4c 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -237,7 +237,7 @@ void ProjectPanel::OnScriptMessage(wxWebViewEvent& evt) { try { wxString strInput = evt.GetString(); - json j = json::parse(strInput); + json j = json::parse(strInput.utf8_string()); wxString strCmd = j["command"]; diff --git a/src/slic3r/GUI/WebDownPluginDlg.cpp b/src/slic3r/GUI/WebDownPluginDlg.cpp index a4f3cc93ce..aa61b07683 100644 --- a/src/slic3r/GUI/WebDownPluginDlg.cpp +++ b/src/slic3r/GUI/WebDownPluginDlg.cpp @@ -199,7 +199,7 @@ void DownPluginFrame::OnScriptMessage(wxWebViewEvent &evt) { try { wxString strInput = evt.GetString(); - json j = json::parse(strInput); + json j = json::parse(strInput.utf8_string()); wxString strCmd = j["command"]; diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index c4df177a53..95994e999b 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -373,7 +373,7 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) try { wxString strInput = evt.GetString(); BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;OnRecv:" << strInput.c_str(); - json j = json::parse(strInput); + json j = json::parse(strInput.utf8_string()); wxString strCmd = j["command"]; BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd;