Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Only add -DACCELERATE_NEW_LAPACK definition if linking the macOS Accelerate Framework #8626

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Nov 20, 2024

Description of proposed changes

In PRs conda-forge/gmt-feedstock#302 and conda-forge/gmt-feedstock#303, conda-forge is trying to rebuild GMT 6.5.0 and the master branch.

The builds fail on macOS, with errors like (see https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=1084283&view=logs&jobId=e0208569-136d-54da-4ec5-14d0e8771cbc&j=e0208569-136d-54da-4ec5-14d0e8771cbc&t=25992e30-3e2a-5788-2b3e-e373b0534bf7 for the detailed report):

/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1373:2: error: call to undeclared function 'dgemm_'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 1373 |         dgemm_ ((const char * _Nonnull)"t", (const char * _Nonnull)tr,
      |         ^
/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1374:20: error: unknown type name '__LAPACK_int'
 1374 |             (const __LAPACK_int * _Nonnull)&na, (const __LAPACK_int * _Nonnull)&nb, (const __LAPACK_int * _Nonnull)&nc,
      |                    ^
/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1374:56: error: unknown type name '__LAPACK_int'
 1374 |             (const __LAPACK_int * _Nonnull)&na, (const __LAPACK_int * _Nonnull)&nb, (const __LAPACK_int * _Nonnull)&nc,
      |                                                        ^
/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1374:92: error: unknown type name '__LAPACK_int'
 1374 |             (const __LAPACK_int * _Nonnull)&na, (const __LAPACK_int * _Nonnull)&nb, (const __LAPACK_int * _Nonnull)&nc,
      |                                                                                            ^
/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1375:81: error: unknown type name '__LAPACK_int'
 1375 |             (const double * _Nonnull)&one, (const double * _Nullable) A, (const __LAPACK_int * _Nonnull)&nd,
      |                                                                                 ^
/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1376:50: error: unknown type name '__LAPACK_int'
 1376 |             (const double * _Nullable) B, (const __LAPACK_int * _Nonnull)&ne,
      |                                                  ^
/Users/runner/miniforge3/conda-bld/gmt_1731987594754/work/src/gmt_vector.c:1377:75: error: unknown type name '__LAPACK_int'
 1377 |             (const double * _Nonnull)&zero, (double * _Nullable)C, (const __LAPACK_int * _Nonnull)&nf);
      |                                                                           ^
7 errors generated.

The failures are because:

  1. The CI job is using macOS with Darwin kernel 22.6.0
  2. As shown in PR Enable updated Accelerate headers for Darin kernel >= 22.4 #8099, for kernel>22.4, we add the ACCELERATE_NEW_LAPACK definition when linking the macOS Accelerate Framework.
  3. Since ACCELERATE_NEW_LAPACK is defined, then the dgemm_ function is not defined.

    gmt/src/gmt_vector.c

    Lines 1333 to 1339 in fa3eda0

    #ifndef ACCELERATE_NEW_LAPACK
    /* This BLAS function is updated on macos 22.4 and higher but still included in the Accelerate Framework header.
    * Otherwise we declare it as an extern function here. dsyev_ is not in BLAS so remains the same so far. */
    extern int dgemm_ (char* tra, char* trb, int* na, int* nb, int* nc, double* alpha, double* a, int *nd, double* b, int *ne, double* beta, double* c, int* nf);
    #endif

However, the conda-forge builds are linking GMT to the lapack library from conda-forge, not the one from macOS Accelerate Framework. In this case, we should not add ACCELERATE_NEW_LAPACK. This PR fixes the issue by checking if the LAPACK_LIBRARIES matches ".*Accelerate.*"

FYI, I've applied the same patch on the conda-forge recipe and the macOS builds now pass.

@seisman seisman added the bug Something isn't working label Nov 20, 2024
@seisman seisman added this to the 6.6.0 milestone Nov 20, 2024
Copy link
Contributor

@remkos remkos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very sensible solution!

@remkos remkos self-requested a review November 20, 2024 08:06
@seisman seisman merged commit 0cb6920 into master Nov 20, 2024
14 of 18 checks passed
@seisman seisman deleted the fix/lapack branch November 20, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants