Skip to content

Fix CMake builds on Apple that use the Ninja generator#5769

Merged
martin-frbg merged 2 commits intoOpenMathLib:developfrom
martin-frbg:issue5768
Apr 22, 2026
Merged

Fix CMake builds on Apple that use the Ninja generator#5769
martin-frbg merged 2 commits intoOpenMathLib:developfrom
martin-frbg:issue5768

Conversation

@martin-frbg
Copy link
Copy Markdown
Collaborator

fixes #5768 as suggested there

@martin-frbg martin-frbg added this to the 0.3.33 milestone Apr 22, 2026
@chris-se
Copy link
Copy Markdown

Note that this doesn't actually fix the issue, because the issue is not the CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS, which is ignored with cmake -G Ninja, but the fact that the lines

set(CREATE_STATIC_LIBRARY_COMMAND
    "sh -c 'cat ${CMAKE_BINARY_DIR}/CMakeFiles/${OpenBLAS_LIBNAME}_static.dir/objects*.rsp | xargs -n 1024 ${CMAKE_AR} -ru ${STATIC_PATH} && exit 0' "
    "sh -c '${CMAKE_AR} -rs ${STATIC_PATH} ${CMAKE_BINARY_DIR}/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o && exit 0' ")

won't work, because no objects*.rsp exist with CMake+Ninja -- they are only written out with CMake + UNIX Makefiles or similar.

But the thing is: because Ninja can handle long command lines directly, the static linking commands don't need to be changed regardless here, so the whole workaround is completely unnecessary. That's why I suggested in #5768 to simply replace the entire if (APPLE) section.

I just tested your variant of the patch and it fails the same as if that change wasn't there.

@martin-frbg
Copy link
Copy Markdown
Collaborator Author

Ah, I see. Didn't want to exclude the whole section as there appear to be unrelated settings in it, but didn't take a closer look

@chris-se
Copy link
Copy Markdown

chris-se commented Apr 22, 2026

As far as I can tell the entire section is just for the workaround, and it's just that complicated because basically the whole linking logic inside CMake for up to two libraries (the static one and potentially the shared one) has to be written by hand to make the workaround work properly.

I can't test this on [edit] other [/edit] Macs, but at least on the M1 I have access to simply replacing the entire if (as I suggested) and having macOS use the same library linking logic as the other platforms "just works" for me.

@chris-se
Copy link
Copy Markdown

(But irrespective of this, many thanks for the very quick response to this. 😄)

@martin-frbg martin-frbg merged commit 07e7594 into OpenMathLib:develop Apr 22, 2026
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure on macOS with CMake + Ninja

2 participants