Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building universal 2 on macOS is broken #853

Open
hjmallon opened this issue Oct 13, 2020 · 5 comments
Open

Building universal 2 on macOS is broken #853

hjmallon opened this issue Oct 13, 2020 · 5 comments
Assignees
Labels
Bug A bug in the source code Build A problem with building or installing the library.

Comments

@hjmallon
Copy link
Contributor

hjmallon commented Oct 13, 2020

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.

@meshula
Copy link
Contributor

meshula commented Oct 14, 2020

Thanks for the report. To start, can I request that if you are on a release version of CMake, could you retest using CMake 3.19, which is now available as a release candidate? https://cmake.org/download/ 3.19 has fixes for Xcode 12, including moving CMake from the Xcode 3 (!!!??!!!!!) build system to Xcode's current build system. They did this specifically to address building universal binaries.

I don't expect this will fix the issues you've encountered, but I think we should start from a version of CMake that's intended to address Apple Silicon, and work with Xcode 12.

@meshula meshula self-assigned this Oct 14, 2020
@meshula meshula added Bug A bug in the source code Build A problem with building or installing the library. labels Oct 14, 2020
@hjmallon
Copy link
Contributor Author

hjmallon commented Oct 16, 2020

I have done some further testing with cmake release and 3.19 and have a PR here.
#854

Also I reproduced this with the normal Makefile generator, the Xcode build system changes only matter with -GXcode in the cmake command (makeing xcode project files).

@gregcotten
Copy link

gregcotten commented Nov 28, 2020

Hmmm Universal 2 builds seem to be broken again on master... Maybe something to do with the library split?

If I checkout master at this commit, I can totally cmake Ilmbase with universal 2, and then cmake OpenEXR with universal 2, pointing to the built Ilmbase by exporting IlmBase_DIR.

@meshula meshula reopened this Nov 28, 2020
@meshula
Copy link
Contributor

meshula commented Nov 28, 2020

Can you post the cmake command you are using to generate?

@gregcotten
Copy link

Sure thing (using cmake version 3.19.1):
cmake -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the source code Build A problem with building or installing the library.
Projects
None yet
Development

No branches or pull requests

3 participants