Skip to content

Building universal 2 on macOS is broken #853

Open
@hjmallon

Description

@hjmallon

CMake has a handy way to build Universal (fat) binaries with x86_64 and arm64 chunks. A recent change seems to break it (#772). This is with Xcode 12.2 beta 2.

I have found that trying to detect compiler support for CPU specific functions is really annoying when building universal binaries with cmake as what you want to ask is not does my compiler support AVX? as this will try to build AVX instructions for both x86_64 (fine) and then arm64 (fail), which then fails. What you needs is does my compiler support AVX in x86_64 mode?, then to use platform #defines to switch in the actual code.

% cmake -DPYILMBASE_ENABLE=OFF -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" ../
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configure ILMBASE Version: 2.5.3 Lib API: 25.0.2
-- Setting build type to 'Release' as none was specified.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Looking for include file ucontext.h
-- Looking for include file ucontext.h - not found
-- Configure OpenEXR Version: 2.5.3 Lib API: 25.0.2
-- Found ZLIB: /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib/libz.tbd (found version "1.2.11") 
-- Performing Test OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN
-- Performing Test OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN - Success
-- Performing Test OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
-- Performing Test OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX - Failed
CMake Error at OpenEXR/config/CMakeLists.txt:51 (if):
  if given arguments:

    "arm64" "x86_64" "MATCHES" "arm64"

  Unknown arguments specified

If I revert the PR linked above I can build univerally, but the AVX ASM is disabled, which is also not desirable.

Metadata

Metadata

Assignees

Labels

BugA bug in the source codeBuildA problem with building or installing the library.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions