Skip to content

SDL2_Image: Weird cross compile error on macOS arm64 building for x86_64 #537

Closed
@DominusExult

Description

@DominusExult

When I'm cross compiling for x86_64 on an Apple Silicon macOS I'm getting these errors:

In file included from /opt/x86_64/include/SDL2/SDL_cpuinfo.h:119:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/immintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/Dominus/Code/Uni/SDL2_image-2.8.8/src/IMG_bmp.c:33:
In file included from /Users/Dominus/Code/Uni/SDL2_image-2.8.8/include/SDL_image.h:32:
In file included from /opt/x86_64/include/SDL2/SDL.h:37:
In file included from /opt/x86_64/include/SDL2/SDL_cpuinfo.h:119:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/immintrin.h:17:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/x86gprintrin.h:14:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/hresetintrin.h:42:27: error: invalid input constraint 'a' in asm

and more and more.
This is puzzling me as I normally do not have problems cross compiling libraries and it happens both by using autotools and cmake.

Autotools environment:

OPT=' -O2 -m64 '
SDK=' -isysroot /opt/SDKs/MacOSX14.5.sdk -mmacosx-version-min=10.12'
export MACOSX_DEPLOYMENT_TARGET=10.12
export PATH=/opt/x86_64/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export CC="/usr/bin/clang -arch x86_64"
export CXX="/usr/bin/clang++ -arch x86_64"
export CPPFLAGS='-I/opt/x86_64/include '$SDK
export CFLAGS='-I/opt/x86_64/include '$SDK' '$OPT
export CXXFLAGS='-I/opt/x86_64/include '$SDK' '$OPT
export LDFLAGS='-L/opt/x86_64/lib '$SDK' '$OPT

Cmake toolchain file:

SET(CMAKE_FIND_ROOT_PATH "/opt/x86_64; /opt/SDKs/MacOSX14.5.sdk")
SET(CMAKE_OSX_SYSROOT "/opt/SDKs/MacOSX14.5.sdk")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment version")
SET(CMAKE_C_FLAGS "-arch x86_64")
SET(CMAKE_CXX_FLAGS "-arch x86_64")
SET(CMAKE_INSTALL_PREFIX "/opt/x86_64" CACHE PATH "" FORCE)

Any idea what I'm doing wrong?

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