Skip to content

Commit d13f85d

Browse files
authored
Merge pull request #5994 from martin-frbg/issue5943
Restore parts of the pre-PR5776 use of response files on OSX
2 parents c3c6b29 + 32775ca commit d13f85d

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ if (NOT BUILD_STATIC_LIBS)
8989
endif ()
9090
endif()
9191

92+
if (APPLE AND NOT BUILD_STATIC_LIBS)
93+
set (BUILD_STATIC_LIBS ON CACHE BOOL "Build static library" FORCE)
94+
endif()
9295

9396
#######
9497
if(BUILD_WITHOUT_LAPACK)
@@ -341,22 +344,25 @@ if (USE_OPENMP)
341344
endif()
342345
endif()
343346

344-
# Second part of "Argument list too long" fix when static libraries are
345-
# built. See above for details.
346-
if(APPLE AND BUILD_STATIC_LIBS)
347+
# Fix "Argument list too long" for macOS - mostly seen with older OS versions on POWERPC or Intel CPUs
348+
if(APPLE)
349+
# Use response files
350+
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
347351
# Always build static library first
348352
set(STATIC_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${OpenBLAS_LIBNAME}.a")
353+
349354
# Handle differences in how many response files are generated and/or where
350355
# they are stored for Ninja / Unix Makefiles.
351356
if("${CMAKE_GENERATOR}" MATCHES "Ninja")
352357
set(CREATE_STATIC_LIBRARY_COMMAND
353358
"sh -c 'cat ${CMAKE_BINARY_DIR}/CMakeFiles/openblas_static.rsp | xargs -n 1024 ${CMAKE_AR} -ru ${STATIC_PATH} && exit 0' "
354359
"sh -c '${CMAKE_AR} -rs ${STATIC_PATH} ${CMAKE_BINARY_DIR}/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o && exit 0' ")
355360
else()
356-
set(CREATE_STATIC_LIBRARY_COMMAND
357-
"sh -c 'cat ${CMAKE_BINARY_DIR}/CMakeFiles/${OpenBLAS_LIBNAME}_static.dir/objects*.rsp | xargs -n 1024 ${CMAKE_AR} -ru ${STATIC_PATH} && exit 0' "
358-
"sh -c '${CMAKE_AR} -rs ${STATIC_PATH} ${CMAKE_BINARY_DIR}/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o && exit 0' ")
361+
set(STATIC_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${OpenBLAS_LIBNAME}.a")
359362
endif()
363+
set(CREATE_STATIC_LIBRARY_COMMAND
364+
"sh -c 'cat ${CMAKE_BINARY_DIR}/CMakeFiles/${OpenBLAS_LIBNAME}_static.dir/objects*.rsp | xargs -n 1024 ${CMAKE_AR} -ru ${STATIC_PATH} && exit 0' "
365+
"sh -c '${CMAKE_AR} -rs ${STATIC_PATH} ${CMAKE_BINARY_DIR}/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o && exit 0' ")
360366
if(BUILD_SHARED_LIBS)
361367
add_dependencies(${OpenBLAS_LIBNAME}_shared ${OpenBLAS_LIBNAME}_static)
362368
set(SHARED_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopenblas.${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.dylib")
@@ -369,6 +375,9 @@ if(APPLE AND BUILD_STATIC_LIBS)
369375
if(NOT NOFORTRAN)
370376
set(CMAKE_Fortran_CREATE_STATIC_LIBRARY ${CREATE_STATIC_LIBRARY_COMMAND})
371377
if(BUILD_SHARED_LIBS)
378+
if (CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
379+
set_target_properties (${OpenBLAS_LIBNAME}_shared PROPERTIES LINKER_LANGUAGE C)
380+
endif()
372381
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
373382
set(CMAKE_Fortran_CREATE_SHARED_LIBRARY
374383
"sh -c 'echo \"\" | ${CMAKE_Fortran_COMPILER} -o dummy.o -c -x f95-cpp-input - '"

0 commit comments

Comments
 (0)