[Development] OSX: building against the 10.6 SDK with Qt 5.1?

Tor Arne Vestbø tor.arne.vestbo at digia.com
Thu Apr 4 12:24:59 CEST 2013


>> On Wed, Apr 3, 2013 at 11:21 AM, Jake Thomas Petroules
>> <jake.petroules at petroules.com
>> <mailto:jake.petroules at petroules.com>> wrote:
>>
>> Can't you just set __MAC_OS_X_VERSION_MAX_ALLOWED to 1060 with the
>>  10.8 SDK?

On 4/3/13 20:29 , Josh Faust wrote:
> No, the Apple API headers don't use that to compile-out API based on
> the max-allowed version. It's only for user code.

Yes and no. The Apple headers are sprinkled with eg:

   __attribute__((availability(macosx,introduced=10.7)));

And passing -D__MAC_OS_X_VERSION_MAX_ALLOWED=1060 results clang building
with -triple x86_64-apple-macosx10.6.0.

But, LLVM's current behavior is to _not_ error out if the 'introduced'
clause is higher than the current max version. This doesn't match the
behavior of the 'obsoleted' clause, and is possibly a bug.

AvailabilityInternal.h has another code path when the availability
attribute is not available, which ends up adding the following to any
10.7+ APIs:

   __attribute__((unavailable))

But unfortunately the Apple headers are not 100% guarded against this
use-case and will fail on eg. enums such as NSWeekOfMonthCalendarUnit.

So, yes, in effect you have to build against the 10.6 SDK if you want to
compile test API usage. This is something we do in the CI for Qt, so
that's already covered. You can do this as well, with 10.6 and Xcode 4.2 
in a VM.

> (and, despite what you say, it does generally work).

'Generally' is unfortunately not good enough.

If you really want to do this it's of course possible to create your own
makespec that builds on one of the existing OSX makespecs, but disables
the 'sdk' CONFIG option and adds a manual sysroot path. This should be
fairly simple, but not something we want to support, seeing that Apple 
themselves don't support it.

> We started building Qt with it because various configuration options
> can make Qt build binaries that are incompatible with 10.6 (such as
> building with clang, which always uses libc++, which is not
> available on 10.6).

Bulding with clang does not automatically enable libc++ AFAIK. libc++ is 
only used with the macx-clang-libc++* makespecs. Which configure line 
caused this?

 > Now that we have the correct configure options I guess we can rely
 > on the minimum version, but it's painful finding out only at runtime
 > that the version you built is actually not 10.6 compatible.

You still have to check that the binary runs as expected on 10.6, as I
assume you're building against the latest SDK for the final build to 
take advantage of new APIs? In which case you'll need to verify that all 
features above the deployment target version are runtime-checked.

This part is missing in the Qt CI AFAIK.

tor arne



More information about the Development mailing list