Skip to content
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

[4.0] fix -fnative linking on macOS #223

Merged
merged 2 commits into from
Sep 20, 2023
Merged

[4.0] fix -fnative linking on macOS #223

merged 2 commits into from
Sep 20, 2023

Conversation

spoonincode
Copy link
Member

When building cdt on macOS, it would error out about not being able to find the Foundation framework. This was because when cdt's ld driver was run with -fnative it didn't tell ld the system's SDK path.

The current SDK can be discovered via xcrun --show-sdk-path. I'm not sure any other way, so call off to that when creating the command line arguments to pass to ld. You can find something a little similar when cmake initializes its environment, so I'm not completely out of whack: https://github.com/Kitware/CMake/blob/123cdf981661c8ae32335d4ae7e1ddcbcffd09cc/Modules/Platform/Darwin-Initialize.cmake#L144

I also removed -Bstatic as that isn't accepted by macOS's linker any longer. afaict that is unneeded since -static will be passed anyways.

@spoonincode spoonincode linked an issue Sep 15, 2023 that may be closed by this pull request
@spoonincode spoonincode changed the title 4.0 - fix -fnative linking on macOS [4.0] fix -fnative linking on macOS Sep 16, 2023
@@ -546,14 +547,31 @@ static void GetLdDefaults(std::vector<std::string>& ldopts) {
} else {
#ifdef __APPLE__
ldopts.insert(ldopts.end(), {"-arch", "x86_64", "-macosx_version_min", "10.13", "-framework", "Foundation", "-framework", "System"});

llvm::SmallString<256> Output;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep naming according to the file. Rest of file has snake case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call; it's a tough mix because LLVM's naming standard is different than ours..

Copy link
Contributor

@ericpassmore ericpassmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@spoonincode
Copy link
Member Author

disappointed to discover this only resolves building on macOS up through Xcode 13.4. Xcode 14 & 15 will not build cdt due to other issues (unrelated to anything macOS related, but rather clang compiler related). oh well, at least it is an improvement

@spoonincode spoonincode merged commit d970278 into release/4.0 Sep 20, 2023
5 checks passed
@spoonincode spoonincode deleted the macos_4x branch September 20, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Or Fix Support for Apple and MacOS Compilation
4 participants