Skip to content

CMake translation handling macOS frameworks incorrectly #8045

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

Closed
CoffeeFlux opened this issue Nov 28, 2020 · 8 comments
Closed

CMake translation handling macOS frameworks incorrectly #8045

CoffeeFlux opened this issue Nov 28, 2020 · 8 comments
Labels
dependency:cmake Issues related to `dependency` with the `cmake` method OS:macos Issues specific to Apple Operating Systems like MacOS and iOS subprojects/wraps
Milestone

Comments

@CoffeeFlux
Copy link
Contributor

I'm attempting to compile cURL as a subproject and getting linker errors for the final executable. The issue appears to be the following snippet in the final linker call:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/CoreFoundation.framework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Security.framework

This should instead just be -framework CoreFoundation -framework Security, and substituting appropriately causes the build to succeed.

This appears to come from the generated meson files. In subprojects/curl/meson.build:

  link_args : ['/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/CoreFoundation.framework', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Security.framework', '/usr/local/lib/libssh2.dylib', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib/libz.tbd'],

The equivalent CMake appears to just be something like:

find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation")
list(APPEND CURL_LIBS "${COREFOUNDATION_FRAMEWORK}")

I assume that macOS frameworks need to be special-cased for this to work.

Meson version: 0.56.0
CMake version: 3.19.0
MacOS version: 11.0.1

How I'm invoking the CMake module: https://github.com/TypesettingTools/ffi-experiments/blob/3b9efd7a8b4e93386e0bcbe84acf33a7a9ef8615/meson.build#L16-L41

@mensinda mensinda added dependency:cmake Issues related to `dependency` with the `cmake` method subprojects/wraps labels Nov 28, 2020
@mensinda
Copy link
Member

Unfortunately, I don't have access to an OSX system. So, could you please provide the complete generated meson.build, fileAPI.json and __CMake_build/cmake_trace.txt for further diagnosis?

@CoffeeFlux
Copy link
Contributor Author

Happily! Thanks for the prompt response.
cmake_framework_bug_logs.zip

@coelle
Copy link

coelle commented Dec 14, 2020

Hm, maybe it relates to a finding of nevyn Bengtsson:

Goddammit. Remember when I complained months ago how bad it would be for everyone if Big Sur really did ship without system library binaries? Less open, harder to develop, etc etc. Well, now even the latest version of CMake doesn't understand how to make Big Sur apps, it seems.

Here's the solution. Replace -framework AVFoundation with FIND_LIBRARIES. Now it finds the .tbd and links with that INSTEAD.

@coelle
Copy link

coelle commented Dec 14, 2020

btw. I have the same problem without a CMake dependency. Both happen on macOS 11.0.1 and both try to use an Apple framework.

I think something changed in the Apple development stack and Apple did not documented/announced it properly...

one of 'OBJCXX_LD' are defined in the environment, not changing global flags.
None of 'OBJCPP_LD' are defined in the environment, not changing global flags.
Running compile:
Working directory:  .../core/build/apple-iphonesimulator13.0-x86_64-x86_64-little/meson-private/tmpnk1byvz5
Command line:  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ .../core/build/apple-iphonesimulator13.0-x86_64-x86_64-little/meson-private/tmpnk1byvz5/testfile.mm -o .../core/build/apple-iphonesimulator13.0-x86_64-x86_64-little/meson-private/tmpnk1byvz5/output.exe -pipe -O0 -framework LocalAuthentication 

Code:
 int main(void) { return 0; }
Compiler stdout:
 
Compiler stderr:
 ld: framework not found LocalAuthentication
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Run-time dependency appleframeworks found: NO (tried framework)

.../src/meson.build:2:0: Exception: Dependency "appleframeworks" not found, tried framework

@dcbaker
Copy link
Member

dcbaker commented Dec 14, 2020

If framework dependencies (ie, dependency(..., method : 'extraframeworks')) stopped working, file a separate bug for that. I'm not sure who has a Big Sur compatible machine, but you're more to get it solved in a separate bug.

@dcbaker dcbaker added the OS:macos Issues specific to Apple Operating Systems like MacOS and iOS label Dec 14, 2020
@CoffeeFlux
Copy link
Contributor Author

If there's anything I can do to further help with this, please let me know; I have a recent fully-updated MBP handy.

Additionally, if anyone knows of a workaround that doesn't involve manually editing the final linker invocation that would be much appreciated.

mensinda added a commit to mensinda/meson that referenced this issue Dec 26, 2020
@mensinda
Copy link
Member

Should (maybe) be fixed with #8134. @CoffeeFlux could you please test the PR on your system?

@mensinda mensinda added this to the 0.56.1 milestone Dec 26, 2020
@CoffeeFlux
Copy link
Contributor Author

The PR fixes the issue for me locally. No longer seeing references to the .framework files in the linker invocation, and instead the correct -framework calls are there. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency:cmake Issues related to `dependency` with the `cmake` method OS:macos Issues specific to Apple Operating Systems like MacOS and iOS subprojects/wraps
Projects
None yet
Development

No branches or pull requests

4 participants