Osx_image xcode12.2 does not come with macos 11 SDK (no way to compile for ARM)

I try to build “universal” binary with XCode 12.2 osx_image but it looks like the correct SDK is missing.

Here a “ls” run from inside of the osx_image:

$ ls -al /Library/Developer/CommandLineTools/SDKs

drwxr-xr-x  5 root  wheel  160 May  5  2020 .
drwxr-xr-x  5 root  wheel  160 Feb 11  2020 ..
lrwxr-xr-x  1 root  wheel   15 May  5  2020 MacOSX.sdk -> MacOSX10.15.sdk
drwxr-xr-x  7 root  wheel  224 May  5  2020 MacOSX10.14.sdk
drwxr-xr-x  8 root  wheel  256 May  5  2020 MacOSX10.15.sdk

Only MacOSX10.15 and MacOSX10.14 SDK is installed (default pointing to 10.15).

When I try to compile something for ARM (apple silicon) I get errors from SDK telling me that the architecture is not supported (of course MacOSX10.15 SDK only supports 386 and x86_64):

...
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:68:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
 ^

You need to add “-target arm64-apple-macos11” to CFLAGS to compile ARM64 on command line (according to apple documentation: https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary )

EDIT: Looks like installation of “Command Line Tools for Xcode 12.2” is missing in this image. Right now just an older version is present.

Could you try using osx_image: xcode12u?

Tried that already. 100% same. No macos11 SDK inside.

$ xcrun --sdk macosx --show-sdk-path
/Applications/Xcode-12.for.macOS.Universal.Apps.beta.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk

Is this not what you want?

1 Like

Hi,

I want to compile using command line tools (not xcode by itself). Therefor a component named “Command Line Tools for Xcode 12.2” needs to be installed. This will setup the SDK into the well known folder: “/Library/Developer/CommandLineTools/SDKs”.

The current osx_images with xcode 12 seems to contain incomplete setups (of pre releases?) of Xcode 12.

On a fresh local macos and an installation of the release version of XCode 12.2 + “Command Line Tools for Xcode 12.2” : ( on shell execute “xcode-select --install” (will popup a UI dialog to accept license) I can see the macos11 SDK in the “/Library/Developer/CommandLineTools/SDKs” folder and compilation is working fine.

1 Like

I found that I could work around this issue by simply getting rid of those SDKs like this:

sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*

When not able to use its default SDK, clang seems to fall back automatically on /Applications/Xcode-12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk

Thanks, @saudet!

Also, we released Xcode 12.3 (12C33) running on Big Sur, @MaikStohn you may want to check it out!

2 Likes

Thanks @cesar-cs !

I can confirm that xcode12.3 image can build x64 and arm executables from command line.

And I “only” spent 10% of the free credits to get the solution.

Not sure how to continue with travis and OSS (will find out in next few months when the rest of the credits are gone).

Thanks anyway,

Maik

1 Like