From 87f4a9782cda94da4f98b7753fa2127a7d61f847 Mon Sep 17 00:00:00 2001 From: AdwaithBatchu Date: Thu, 18 Dec 2025 16:23:56 +0530 Subject: [PATCH] Merge pull request #28203 from AdwaithBatchu:fix-macos-lapack-warnings core: suppress LAPACK deprecation warnings on macOS #28203 ### Description On macOS (Apple Silicon) with newer Xcode/Clang, the CLAPACK interface is deprecated. Compiling `hal_internal.cpp` triggers multiple warnings like: `warning: 'sgesv_' is deprecated: first deprecated in macOS 13.3 - The CLAPACK interface is deprecated. [-Wdeprecated-declarations]` Since migrating to the new Accelerate interface (Apple's recommended fix) requires significant changes to the HAL implementation and breaks the build if headers are mismatched, this PR takes the pragmatic approach. It suppresses the `-Wdeprecated-declarations` warning for this specific file using Clang pragmas to clean up the build output. ### Verification - [x] Verified build is silent on macOS (M3). - [x] Verified pragmas are correctly scoped within `HAVE_LAPACK` to prevent scope mismatch on non-LAPACK builds. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- modules/calib3d/src/usac/dls_solver.cpp | 8 ++++++++ modules/calib3d/src/usac/essential_solver.cpp | 8 ++++++++ modules/calib3d/src/usac/pnp_solver.cpp | 8 ++++++++ modules/core/src/hal_internal.cpp | 11 ++++++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/calib3d/src/usac/dls_solver.cpp b/modules/calib3d/src/usac/dls_solver.cpp index 76e7e5d645..1e1cf6c34d 100644 --- a/modules/calib3d/src/usac/dls_solver.cpp +++ b/modules/calib3d/src/usac/dls_solver.cpp @@ -44,6 +44,10 @@ #elif defined(HAVE_LAPACK) #include "opencv_lapack.h" #endif +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif namespace cv { namespace usac { class DLSPnPImpl : public DLSPnP { @@ -890,3 +894,7 @@ Ptr DLSPnP::create(const Mat &points_, const Mat &calib_norm_pts, const return makePtr(points_, calib_norm_pts, K); } }} + +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic pop +#endif diff --git a/modules/calib3d/src/usac/essential_solver.cpp b/modules/calib3d/src/usac/essential_solver.cpp index 8f9b5b9d33..dfff4b970b 100644 --- a/modules/calib3d/src/usac/essential_solver.cpp +++ b/modules/calib3d/src/usac/essential_solver.cpp @@ -9,6 +9,10 @@ #elif defined(HAVE_LAPACK) #include "opencv_lapack.h" #endif +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif namespace cv { namespace usac { /* @@ -354,3 +358,7 @@ Ptr EssentialMinimalSolver5pts::create return makePtr(points_, use_svd, is_nister); } }} + +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/modules/calib3d/src/usac/pnp_solver.cpp b/modules/calib3d/src/usac/pnp_solver.cpp index 24c06ac22b..044a7da9ff 100644 --- a/modules/calib3d/src/usac/pnp_solver.cpp +++ b/modules/calib3d/src/usac/pnp_solver.cpp @@ -11,6 +11,10 @@ #elif defined(HAVE_LAPACK) #include "opencv_lapack.h" #endif +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif namespace cv { namespace usac { class PnPMinimalSolver6PtsImpl : public PnPMinimalSolver6Pts { @@ -412,3 +416,7 @@ Ptr P3PSolver::create(const Mat &points_, const Mat &calib_norm_pts, return makePtr(points_, calib_norm_pts, K); } }} + +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/modules/core/src/hal_internal.cpp b/modules/core/src/hal_internal.cpp index f3f23a3b3c..d15cbb7ad3 100644 --- a/modules/core/src/hal_internal.cpp +++ b/modules/core/src/hal_internal.cpp @@ -77,6 +77,11 @@ __msan_unpoison(address, size) #define CV_ANNOTATE_NO_SANITIZE_MEMORY #endif +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + //lapack stores matrices in column-major order so transposing is needed everywhere template static inline void transpose_square_inplace(fptype *src, size_t src_ld, size_t m) @@ -701,4 +706,8 @@ int lapack_gemm64fc(const double *src1, size_t src1_step, const double *src2, si return lapack_gemm_c(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m, n, k, flags); } -#endif //HAVE_LAPACK +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic pop +#endif + +#endif //HAVE_LAPACK \ No newline at end of file