Skip to content

Commit ea09355

Browse files
authored
Fix DYNAMIC_ARCH builds with CMAKE on OSX and add corresponding test to Azure CI (#3409)
* Use linker response files and a custom link command to get around ARG_MAX limitations on OSX * Reconfigure a redundant job on Azure to test shared library builds with CMAKE and DYNAMIC_ARCH on OSX
1 parent 54d321d commit ea09355

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,22 @@ if(ANDROID)
244244
endif()
245245
endif()
246246

247+
if (APPLE AND DYNAMIC_ARCH AND BUILD_SHARED_LIBS)
248+
set (CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
249+
if (NOT NOFORTRAN)
250+
set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1)
251+
set (CMAKE_Fortran_CREATE_SHARED_LIBRARY
252+
"sh -c 'cat ${CMAKE_BINARY_DIR}/CMakeFiles/openblas_shared.dir/objects*.rsp | xargs -n 1024 ar -ru libopenblas.a && exit 0' "
253+
"sh -c 'echo \"\" | ${CMAKE_Fortran_COMPILER} -o dummy.o -c -x f95-cpp-input - '"
254+
"sh -c '${CMAKE_Fortran_COMPILER} -fpic -shared -Wl,-all_load -Wl,-force_load,libopenblas.a -Wl,-noall_load dummy.o -o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopenblas.${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.dylib'"
255+
"sh -c 'ls -l ${CMAKE_BINARY_DIR}/lib'")
256+
else ()
257+
set (CMAKE_C_CREATE_SHARED_LIBRARY
258+
"sh -c 'cat ${CMAKE_BINARY_DIR}/CMakeFiles/openblas_shared.dir/objects*.rsp | xargs -n 1024 ar -ru libopenblas.a && exit 0' "
259+
"sh -c '${CMAKE_C_COMPILER} -fpic -shared -Wl,-all_load -Wl,-force_load,libopenblas.a -Wl,-noall_load -o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopenblas.${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.dylib'")
260+
endif ()
261+
endif()
262+
247263
# Handle MSVC exports
248264
if(MSVC AND BUILD_SHARED_LIBS)
249265
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.4)

azure-pipelines.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,20 @@ jobs:
165165
make
166166
ctest
167167
168-
- job: OSX_OpenMP_Clang_gf_cmake
168+
- job: OSX_dynarch_cmake
169169
pool:
170170
vmImage: 'macOS-10.15'
171171
variables:
172172
LD_LIBRARY_PATH: /usr/local/opt/llvm/lib
173173
LIBRARY_PATH: /usr/local/opt/llvm/lib
174174
steps:
175175
- script: |
176-
brew update
177-
brew install llvm libomp
178176
mkdir build
179177
cd build
180-
cmake -DTARGET=CORE2 -DUSE_OPENMP=1 -DINTERFACE64=1 -DDYNAMIC_ARCH=1 -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DNO_AVX512=1 ..
181-
make
178+
cmake -DTARGET=CORE2 -DDYNAMIC_ARCH=1 -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_Fortran_COMPILER=gfortran-10 -DBUILD_SHARED_LIBS=ON ..
179+
cmake --build .
182180
ctest
183-
181+
184182
- job: OSX_Ifort_Clang
185183
pool:
186184
vmImage: 'macOS-10.15'

0 commit comments

Comments
 (0)