Skip to content

🍒[cxx-interop] Lower macOS deployment target version for the Cxx module #69605

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

Merged
merged 3 commits into from
Nov 8, 2023

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Nov 2, 2023

Explanation: The Cxx module does not rely on any modern OS features. It can be deployed to older macOS versions. Having a high deployment target blocks certain usage workflows of the Cxx module.
Scope: All of the code changes are on a C++ interop only code path.
Risk: Low, only takes effect when C++ interop is enabled.
Testing: Covered by LIT tests.

Original PR: #69512

rdar://117699474

The CMake flag `DEPLOYMENT_VERSION_OSX` is currently only passed to the C compiler. This change makes sure it is also passed to the Swift compiler, e.g. when building Swift-only targets like Cxx or CxxStdlib.

rdar://117699474

(cherry picked from commit e192ee2)
The Cxx module does not rely on any modern OS features. It can be deployed to older macOS versions.

rdar://117699474
(cherry picked from commit 00cdb66)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Nov 2, 2023
@egorzhdan egorzhdan requested a review from a team as a code owner November 2, 2023 12:54
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan requested a review from hyp November 2, 2023 17:15
@@ -23,6 +23,8 @@ add_swift_target_library(swiftCxx STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY IS
# For functionality that depends on the C++ stdlib, use C++ stdlib overlay (`swiftstd` module).
-Xcc -nostdinc++

DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
Copy link
Member

Choose a reason for hiding this comment

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

It seems like this needs to be done for all Apple OS's, as we do for the various compatibility libraries, e.g.,

  DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
  DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS}
  DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
  DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}

  MACCATALYST_BUILD_FLAVOR "zippered"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I added other Apple platforms here

@@ -49,6 +49,8 @@ add_swift_target_library(swiftCxxStdlib STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_O
SWIFT_COMPILE_FLAGS_LINUX
${SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS}

DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here about all Apple platforms

@@ -452,6 +457,7 @@ function(_compile_swift_files
"${SWIFT_STDLIB_BUILD_TYPE}"
"${SWIFT_STDLIB_ASSERTIONS}"
swift_flags
DEPLOYMENT_VERSION_OSX ${SWIFTFILE_DEPLOYMENT_VERSION_OSX}
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised that any of these changes are needed, given that add_swift_target_library is already being used with these DEPLOYMENT_VERSION_* options elsewhere. Are you sure these changes here are necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add_swift_target_library currently only applies these options for C/C++ source files. Here we're making it apply DEPLOYMENT_VERSION_* for Swift modules as well.

…rces

See #69512

rdar://117699474

(cherry picked from commit f8b5143)
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Looks good now, thank you!

@egorzhdan egorzhdan merged commit 714ff04 into release/5.10 Nov 8, 2023
@egorzhdan egorzhdan deleted the egorzhdan/5.10-cxx-lower-deployment-target branch November 8, 2023 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants