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 CMP0157 to OLD for Android #5180

Merged

Conversation

Steelskin
Copy link
Contributor

There is no early swift-driver build for the Windows toolchain. As a result, swift-collections fails to build properly when CMP0157 is set to NEW due to object files not being generated.

This sets CMP0157 to OLD when targetting Android until the early swift-driver is available on Windows.

There is no early swift-driver build for the Windows toolchain. As a
result, swift-collections fails to build properly when CMP0157 is set to
NEW due to object files not being generated.

This sets CMP0157 to OLD when targetting Android until the early
swift-driver is available on Windows.
@parkera parkera requested review from hyp and finagolfin February 27, 2025 19:39
@weliveindetail
Copy link
Member

Facing this issue as well. This sounds like a good compromise. Is it happening on other platforms too? Otherwise we might want to add CMAKE_HOST_SYSTEM_NAME STREQUAL Windows to the condition.

@Steelskin
Copy link
Contributor Author

Facing this issue as well. This sounds like a good compromise. Is it happening on other platforms too? Otherwise we might want to add CMAKE_HOST_SYSTEM_NAME STREQUAL Windows to the condition.

It works fine when building for Windows, but the Android build does not take kindly to not having the early swift-driver.

@weliveindetail
Copy link
Member

What I meant was: The issue doesn't reproduce when running Android build on Linux right?

@Steelskin
Copy link
Contributor Author

What I meant was: The issue doesn't reproduce when running Android build on Linux right?

Ah sorry, I have no idea. I am assuming there is no early swift-driver on Linux either since that requires a static build.

@finagolfin
Copy link
Member

I am not that familiar with this CMake policy, which appears to enable using the new CMAKE_Swift_COMPILATION_MODE flag, looks like it was just added with the Foundation rewrite merged last summer. Looking at the CMake config below it appears that configuring that new CMAKE_Swift_COMPILATION_MODE flag here is disabled on Windows hosts, so I'm not sure how it is affecting you.

Is it that CMake sets CMAKE_Swift_COMPILATION_MODE to some default value anyway if CMP0157 is enabled? If so, you'll want to narrow this pull to if(POLICY CMP0157 AND CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND CMAKE_SYSTEM_NAME STREQUAL Android), as Stefan says.

I am assuming there is no early swift-driver on Linux either since that requires a static build.

No, the linux CI builds and uses the early swift-driver, as you can see on any recent CI run (search for earlyswiftdriver), and you can always pass in a prebuilt linux toolchain that includes the new swift-driver to build this repo.

My Android CI builds this repo just fine from a linux host using such an official prebuilt linux toolchain.

Btw, what is up with @hyp, will he be back?

@Steelskin
Copy link
Contributor Author

I am not that familiar with this CMake policy, which appears to enable using the new CMAKE_Swift_COMPILATION_MODE flag, looks like it was just added with the Foundation rewrite merged last summer. Looking at the CMake config below it appears that configuring that new CMAKE_Swift_COMPILATION_MODE flag here is disabled on Windows hosts, so I'm not sure how it is affecting you.

When CMP0157 is set to OLD, the swiftmodule and static library are built in a single ninja step. The step also expects that the object files are built in the process but they are not consumed by any other target. When CMP0157 is set to NEW, the generated ninja file includes 2 targets: one to build the swiftmodule + object files and one to build the static library.
The problem occurs when swift-driver is not present (as is the case on Windows when building the toolchain). When targeting Android, the object files are not built, resulting in the target to build the static library failing. As a workaround, we are using an older CMake version in GHA swift-build.

Is it that CMake sets CMAKE_Swift_COMPILATION_MODE to some default value anyway if CMP0157 is enabled? If so, you'll want to narrow this pull to if(POLICY CMP0157 AND CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND CMAKE_SYSTEM_NAME STREQUAL Android), as Stefan says.

Thanks, I did that.

Btw, what is up with @hyp, will he be back?

He has gone to pursue a different field. He might pop up every once in a while, though :)

@finagolfin
Copy link
Member

@swift-ci please test

@finagolfin
Copy link
Member

He has gone to pursue a different field.

OK, only reason I asked is because Tony and I were still pinging him on recent pulls, we'll stop doing that. 😉

@finagolfin finagolfin removed the request for review from hyp March 4, 2025 05:56
@weliveindetail
Copy link
Member

The Windows build succeeded: https://ci-external.swift.org/job/swift-corelibs-foundation-PR-windows/618/ Any ideas why results were not reported?

@weliveindetail
Copy link
Member

The bot checked out the correct commit 4af0f8c, but then it reported the result for the outdated commit:

Adding one-line test results to commit status...
Setting status of a563acec95f721223859b2e704843f6ca78611e7 to SUCCESS with url https://ci-external.swift.org/job/swift-corelibs-foundation-PR-windows/618/ and message [...]

a563ace did actually get accepted 🤷‍♂️

@weliveindetail
Copy link
Member

Let's try that again.

@swift-ci please test Windows

@weliveindetail weliveindetail merged commit db6474a into swiftlang:main Mar 5, 2025
2 checks passed
grynspan pushed a commit to swiftlang/swift-testing that referenced this pull request Mar 10, 2025
…olchain (#1009)

There is no early swift-driver build for the Windows toolchain. As a
result, swift-testing fails to build properly when CMP0157 is set to NEW
due to object files not being generated.

This sets CMP0157 to OLD when targeting Android with the Windows
toolchain until the early swift-driver is available on Windows. This is
analog to
swiftlang/swift-corelibs-foundation#5180

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
hjyamauchi added a commit to hjyamauchi/swift-testing that referenced this pull request Mar 14, 2025
There is no early swift-driver build for the Windows toolchain. As a
result, swift-collections fails to build properly when CMP0157 is set to
NEW due to object files not being generated.

This sets CMP0157 to OLD when targetting Android until the early
swift-driver is available on Windows.

This is similar to swiftlang/swift-corelibs-foundation#5180
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