-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Set -no_weak_imports linker flag for Xcode 8 on OS X 10.11 #3727
Comments
Could you note this in #1957? Would be interested in @mistydemeo and @DomT4's opinions, too. |
It sounds perfectly sane to me, but I'll defer to @mistydemeo who is far more comfortable with compilers than I am if Misty has a differing opinion. |
I think this is a good idea, I'd like to apply this when Xcode 8 or later is installed (regardless of OS version). |
Makes sense to me too 👍. Probably worth doing in both stdenv and superenv. |
Shouldn't it be added to LDFLAGS? |
@AmirIHz Yes, I believe you are correct there. I've updated the problem description accordingly. |
Implemented in Homebrew/brew#721. Thanks for the clearly phrased issue, @achivetta, made it easy to implement. |
Breaks |
Issue Homebrew/homebrew-core#3727 suggested we set -no_weak_imports for new versions of Xcode to ensure that e.g. building on 10.11 against the 10.12 SDK doesn't result in a situation where autotools thinks symbols exist that don't actually exist on the current platform. Further discussion in golang/go#16770 revealed that some packages require weak imports to build normally.
I can't comment in the original issue #2674, so I'll do it here. As a side note for those digging into the issue, the main problem is that Apple is incorrectly using their own availabilty checks. For example in time.h, clock_gettime is defined this way:
While it should be defined this way:
In the second case, the compiller correctly undefines the clock_gettime function when using -macosx-version-min=10.7 whith a lower version than 10.12 and all configure checks would fail as expected. |
@ylatuya I'm not sure I follow. You are saying having a new line after the availability attribute before the return type causes issues for you? Or is there some other difference I'm not seeing? In either case, availability checks have never undefined the symbols — they just cause the import to be a weak link. (Hence the need for the -no_weak_link option.) |
@achivetta For one moment I though it was just an issue with the attribute position, but it's not... I was testing too many things at the same time. I now understand how the availability attributes work, sorry for the noise |
A general note that if we lock issues like that it's because people are posting stuff that's not relevant to Homebrew on them and, kindly, that's not an invitation to post the same elsewhere. Thanks! |
@achivetta I am facing a similar problem using the 10.12 SDK to compile VLC and its dependencies. I tried your suggestion adding This is how I compiled it:
Because it succeeds, the tests are all ok but later on, when the actual program is linked, it fails due to the Right now as a workaround I just continue using the 10.11 SDK, spent a whole day trying different suggestions, none of them working. |
@ePirat Does it work if you pass 10.11? If so, this is expected: the If not, then there's some other bug you are hitting: please file a radar and let me know the number. It's absolutely intended that the autoconf check fails when targeting 10.11. (Edit: Also, please try 10.11 plus moving aside usr/lib/system/libsystem_c.tbd in your SDK.) |
@achivetta Why would it not work with 10.7 as target, given that 10.7 is even older than 10.11? Anyway I tried compiling the test program targeting 10.11:
and it still succeeded. When moving away
|
@ePirat Your issue seems unrelated to Homebrew so please discuss it elsewhere, thanks. |
@MikeMcQuaid Sure. It affects many packages in Homebrew that are autotools-based and use such tests, so I thought I would bring up that problem here, but you are right that it's not really related to Homebrew and I will continue this elsewhere, sorry. |
@ePirat That's ok, thanks for the apology ❤️ |
See #2674 for some background, but the gist of it is this:
When building on OS X 10.11 with Xcode 8 against the macOS 10.12 SDK, you'll see the symbols added in macOS 10.12 e.g. clock_gettime and getentropy. This will cause many autoconf using projects to enable code that uses them. The built products will then fail with dynamic linker errors at runtime because the symbols aren't available on the 10.11 host system.
Xcode 8 beta 4 adds a new linker flag -no_weak_imports that will cause the linker to:
$ld$weak$
symbols that indicate the OS version the symbol was added in, failing if it is newer than the supplied OS.Homebrew should consider adding
-Wl,-no_weak_imports
to the LDFLAGS by default to enable this behavior, since it's almost always the desired behavior when building to run locally. Or, at least, it should be adopted those formula not currently building correctly in the Xcode 8 + 10.11 configuration. (e.g. xz and python)The text was updated successfully, but these errors were encountered: