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

Set the minimum macOS deployment target to 10.13 for the test target #476

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kateinoigakukun
Copy link
Member

The lit test suite respects MACOSX_DEPLOYMENT_TARGET to determine the -target option passed to compilers. However, the SwiftXCTestFunctionalTests target and the XCTest project do not set MACOSX_DEPLOYMENT_TARGET in their build settings, so the default value (14.2 in the current Xcode installed on the CI) is used and the macOS version of the CI machine is older than it. This patch fixes the issue by setting MACOSX_DEPLOYMENT_TARGET to 10.13, which is currently used as the minimum macOS version requirement in ci.swift.org.

The lit test suite respects `MACOSX_DEPLOYMENT_TARGET` to determine the
`-target` option passed to compilers. However, the `SwiftXCTestFunctionalTests`
target and the `XCTest` project do not set `MACOSX_DEPLOYMENT_TARGET` in their
build settings, so the default value (14.2 in the current Xcode installed on the
CI) is used and the macOS version of the CI machine is older than it.
This patch fixes the issue by setting `MACOSX_DEPLOYMENT_TARGET` to 10.13, which
is currently used as the minimum macOS version requirement in ci.swift.org.
@kateinoigakukun
Copy link
Member Author

@swift-ci test

@kateinoigakukun
Copy link
Member Author

@swift-ci test macOS

@kateinoigakukun
Copy link
Member Author

objc[11791]: Class _TtC10Foundation20_PropertyListDecoder is implemented in both /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (0x7ff847d9c528) and /Users/ec2-user/jenkins/workspace/swift-corelibs-xctest-PR-macos/branch-main/build/Ninja-DebugAssert/xctest-macosx-x86_64/Debug/SwiftFoundation.framework/Versions/A/SwiftFoundation (0x1071895c8). One of the two will be used. Which one is undefined.

Hmm, I guess some of the linker input uses system's Foundation instead of just built one... Not sure what brought it.

The use of CoreFoundation while building with corelibs-foundation
causes an unintentional dependency to the CoreFoundation framework due
to the lack of way to distinguish corelibs-foundation's CoreFoundation
from CoreFoundation.framework.

From macOS 13, CoreFoundation started to depend on CoreServicesInternal,
and it causes a transitive dependency from CoreFoundation.framework to
Foundation.framework.

  ┌-> CoreFoundation --[NEW]--> CoreServicesInternal -┐
  └-- Foundation <------------- CFNetwork ------------┘

Thus corelibs-xctest started to depend on Foundation.framework unintentionally
from macOS 13.

This unintentional dependency is problematic because it causes a duplicate
loading of the Objective-C classes of Foundation from the corelibs-foundation
and Foundation.framework even though we explicitly imports corelibs-foundation
by `import SwiftFoundation`.

This patch removes the use of CoreFoundation when building with
corelibs-foundation based on the `USE_FOUNDATION_FRAMEWORK` definition.
@kateinoigakukun
Copy link
Member Author

@swift-ci test

@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented Feb 22, 2024

I found CoreFoundation.framework now transitively depends on Foundation.framework from macOS 13... See commit message on a6fc1e2

The Foundation.framework is usually implicitly linked by the Clang
linker driver. However, we do not want to link it in XCTest because we
use just built SwiftFoundation instead or we explicitly link it when
USE_FOUNDATION_FRAMEWORK is on.
@kateinoigakukun
Copy link
Member Author

@swift-ci test

* Disable autolinking of swiftCoreFoundation
* Add `-nodefaultlibs` to the linker flags in tests
@kateinoigakukun
Copy link
Member Author

Hmm, I managed to get rid of CoreFoundation.framework dependency from the corelibs-foundation (In fact, we used to depend on it implicitly for a long!). However, it looks like TARGET_OS_MAC code paths have several subtle assumptions that work only with CoreFoundation.framework, so test suites crashed around memory management stuff.
IIUC macOS support of swift-corelibs-foundation and swift-corelibs-xctest is just for compatibility checks, so I gave up repairing the build for now.

For those who want to fix this, I pushed my WIP fixes to the following branches:

@parkera Do you think it's worth maintaining macOS build and checking on CI?

@parkera
Copy link
Member

parkera commented Feb 22, 2024

On Darwin the "upward" dependency of CoreFoundation.framework on Foundation has been there since the release of macOS 14 and aligned releases. That is how we're achieving our promise of a single unified implementation written in Swift (e.g., all calendar calculations are now calling into the same open source implementation).

In parallel with your effort here we've been considering how to migrate everyone using swift-corelibs-foundation to this new implementation. I don't have a full answer yet, but it seems reasonable in the short term to focus this project on building correctly for non-Darwin platforms.

@MaxDesiatov
Copy link
Member

@swift-ci test

@MaxDesiatov
Copy link
Member

@swift-ci test windows

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.

None yet

4 participants