Skip to content

CMake: ensure Swift host tools depend on HostCompatibilityLibs target #73065

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

Conversation

edymtt
Copy link
Contributor

@edymtt edymtt commented Apr 16, 2024

At the time I implemented #60728, I did not realize that in all the bootstrapping mode we need to depend on the compatibility libraries we build -- otherwise when targeting a low deployment target we risk failing because we are not able to find such libraries.

Addresses rdar://126552386

@edymtt edymtt force-pushed the edymtt/use-hostcompatibilitylibs-for-all-bootstrapping-modes branch from 9e17ac3 to 40f789b Compare April 16, 2024 21:05
@edymtt edymtt changed the title CMake: ensure Swift host tools depends on HostCompatibilityLibs target CMake: ensure Swift host tools depend on HostCompatibilityLibs target Apr 16, 2024
@edymtt
Copy link
Contributor Author

edymtt commented Apr 16, 2024

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Apr 16, 2024

@swift-ci please test WebAssembly

@edymtt
Copy link
Contributor Author

edymtt commented Apr 16, 2024

@swift-ci please test Apple Silicon

@edymtt
Copy link
Contributor Author

edymtt commented Apr 16, 2024

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Apr 16, 2024

@swift-ci Please Test Source Compatibility Release

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

target_link_libraries should almost always be universally preferred over target_link_directories. That ensures that the dependencies are wired up properly.

@etcwilde
Copy link
Member

I think this changes a subtle detail here and I'm still working out whether it will still be fine or not.

These libraries are part of the toolchain content and should only be linked under certain circumstances as decided by the driver/compiler, including info about the minimum version of the runtime you're backdeploying to. That is, these should only be linked when the driver/compiler decides to do so. In the case where the driver/compiler decides to link them, it will do so automatically, so I don't think target_link_libraries is correct here.

Now, that said, these are static archives, so if the generated binary doesn't have one of the compatibility FORCE_LOAD symbols that it needs to resolve, the lazy-link behavior of static archives should actually skip over the entire archive since it isn't needed.

I think add_dependencies is probably better in this case though.

@edymtt edymtt force-pushed the edymtt/use-hostcompatibilitylibs-for-all-bootstrapping-modes branch from 40f789b to 584dd98 Compare April 25, 2024 15:35
@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

@swift-ci please test WebAssembly

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

@swift-ci please test Apple Silicon

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

@swift-ci Please Test Source Compatibility Release

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

Updated the PR based on Evan's feedback.

@@ -466,6 +466,11 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)

set(sdk_dir "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift")
get_property(compatibility_libs
Copy link
Member

Choose a reason for hiding this comment

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

Did add_dependencies(${target} HostCompatibilityLibs) not work?

Copy link
Contributor Author

@edymtt edymtt Apr 25, 2024

Choose a reason for hiding this comment

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

In this case no, because HostCompatibilityLibs is defined as an interface library, so its dependencies would only be expanded if I used target_link_libraries -- this is the same approach I perused in #60728

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment about this in 4d14497 (as this is an aspect of interface libraries that is easy to forget)

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

@swift-ci please test Linux

@edymtt
Copy link
Contributor Author

edymtt commented Apr 25, 2024

Source Compatibility Suite results look good -- for some reason I got only 3 failures, a subset of the 5 found in the corresponding job

At the time I implemented swiftlang#60728, I did not realize that in all the
bootstrapping mode we need to depend on the compatibility libraries we
build -- otherwise when targeting a low deployment target we risk
failing because we are not able to find such libraries.

Addresses rdar://126552386
@edymtt edymtt force-pushed the edymtt/use-hostcompatibilitylibs-for-all-bootstrapping-modes branch from 584dd98 to 4d14497 Compare April 29, 2024 17:53
@edymtt
Copy link
Contributor Author

edymtt commented Apr 29, 2024

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Apr 29, 2024

@swift-ci please test WebAssembly

@edymtt
Copy link
Contributor Author

edymtt commented Apr 29, 2024

@swift-ci please test Apple Silicon

@edymtt
Copy link
Contributor Author

edymtt commented Apr 29, 2024

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Apr 29, 2024

@swift-ci Please Test Source Compatibility Release

@edymtt edymtt merged commit dbc8c4b into swiftlang:main Apr 30, 2024
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.

3 participants