[Bug 772451] Broken clock_gettime and mkostemp detection with XCode 8
GStreamer (GNOME Bugzilla)
bugzilla at gnome.org
Tue Oct 25 08:46:30 UTC 2016
https://bugzilla.gnome.org/show_bug.cgi?id=772451
--- Comment #21 from Andoni Morales <ylatuya at gmail.com> ---
(In reply to Nirbheek Chauhan from comment #17)
> I forgot to add another thing (I wish you could edit bugzilla comments):
>
> Apple wants you to use the new symbols as weak imports so that you can
> compile a single binary that can run on multiple platforms. You are supposed
> to check if the symbol is available at runtime and use fallback code if it
> does not.
>
> I think this is a really cool feature, but they added it in a terrible way.
> They made it the default for all symbols. This means that people will
> compile their app with a new SDK and it will barf when they run it on an
> older OS X. This is most prominently visible on OS X 10.11.6 where if you
> build with the default XCode 8 SDK, your program will use symbols not
> available on your OS at all and fail at runtime.
>
> To mitigate this, they added a new option that forces the compiler to not
> assume that your symbol usage is proper, and error out if you have any
> references to symbols not available in your targetted OS X version:
> `-Wl,-no_weak_imports`.
>
> If you use that to compile your basic testcase, it will fail as follows:
>
> $ clang -Wl,-no_weak_imports -mmacosx-version-min=10.8 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/
> Developer/SDKs/MacOSX10.12.sdk test2.c
> ld: weak import of symbol '_clock_gettime' not supported because of option:
> -no_weak_imports for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> $
>
>
> And it will work fine if you target a newer OS X:
>
> $ clang -Wl,-no_weak_imports -mmacosx-version-min=10.12 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/
> Developer/SDKs/MacOSX10.12.sdk test2.c
> $
>
> BUT, this option relies on availability information in the prototype (time.h
> for clock_gettime). So if you don't use the prototype in the header provided
> by Apple, the symbol will always be "available" to the linker. This is why
> the Autoconf check is broken no matter what we do and we have to work around
> it manually -- it always uses its own broken prototype.
Thanks for the explanation, it was a crazy weekend trying to fix our builds :)
You are right, I think -Wl,-no_weak_imports is right now the best alternative
to, at least, make sure binaries are compatible with older versions.
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the gstreamer-bugs
mailing list