Skip to content

Build failure on macOS with CMake + Ninja #5768

@chris-se

Description

@chris-se

When building OpenBLAS on macOS with Ninja as the generator the build will fail due to the response file workaround in CMakeLists.txt. This is because Ninja doesn't generate the same .rsp response files that a Makefile generated by CMake would. This then has two consequences:

  1. A warning is generated during build just before the libopenblas.a is generated:
cat: .../build/Release/CMakeFiles/openblas_static.dir/objects*.rsp: No such file or directory
ar: creating archive libopenblas.a
  1. The libopenblas.a (and also the libopenblas.0.3.dylib) don't contain any code except for xerbla_.

  2. Then the build fails because the tests that are built can't find the symbols of the actual functions of OpenBLAS:

Undefined symbols for architecture arm64:
  "_caxpby_", referenced from:
      ___ctest_axpby_caxpby_inc_0_run in test_axpby.c.o
      ___ctest_axpby_caxpby_inc_1_run in test_axpby.c.o
      ___ctest_axpby_caxpby_inc_2_run in test_axpby.c.o
  "_caxpy_", referenced from:
      ___ctest_axpy_caxpy_inc_0_run in test_axpy.c.o
      ___ctest_axpy_caxpy_incx_0_run in test_axpy.c.o
  "_cgemv_", referenced from:
      ___ctest_cgemv_0_nan_inf_run in test_gemv.c.o
      ___ctest_cgemv_0_nan_inf_incy_2_run in test_gemv.c.o
      ___ctest_cgemv_0_2_nan_1_inf_1_run in test_gemv.c.o
      ___ctest_cgemv_0_2_nan_1_inf_1_incy_2_run in test_gemv.c.o
      ___ctest_cgemv_2_0_nan_1_inf_1_run in test_gemv.c.o
      ___ctest_cgemv_2_0_nan_1_inf_1_incy_2_run in test_gemv.c.o
[...]

With Ninja the workaround that is present in the CMakeLists.txt is not actually required, because Ninja always uses response files anyway (but uses temporary files it removes again, so there will never be a .rsp file in a build folder).

I therefore suggest to replace:

if(APPLE)

in CMakeLists.txt (around line 310) with

if(APPLE AND "${CMAKE_GENERATOR}" MATCHES ".*Makefiles")

That will still keep the workaround in-place when make is used, but allows Ninja to just work out of the box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions