Skip to content

[cxx-interop] Add infrastructure to build and run tests on multiple targets. #36082

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

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

Conversation

zoecarver
Copy link
Contributor

@zoecarver zoecarver commented Feb 22, 2021

Updates the build script, update checkout script, and lit config to support cross-compiling uswift to allow running tests on multiple targets locally. Introduces the %cxx-all-targets to run tests on several targets. Currently, this is only used on the C++ interop IRGen tests, but another lit substitution could be added for other tests.

Here are the targets we currently cross-compile to:

  • arm64-apple-macosx10.9
  • x86_64-apple-macosx10.9
  • armv7-unknown-linux-androideabi
  • x86_64-unknown-windows-msvc

Main changes:

  • Unconditionally builds LLD.
  • Adds dependency on uswift.

Link to the forum post.

@zoecarver zoecarver added the c++ interop Feature: Interoperability with C++ label Feb 22, 2021
@zoecarver
Copy link
Contributor Author

@swift-ci please test.

@zoecarver
Copy link
Contributor Author

@swift-ci please test windows.

@zoecarver
Copy link
Contributor Author

@swift-ci please test Windows platform.

@zoecarver
Copy link
Contributor Author

@swift-ci please test Windows.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b9265e79ee31810359229bfda9f20db5c303650c

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b9265e79ee31810359229bfda9f20db5c303650c

@zoecarver zoecarver force-pushed the cxx/cross-compile-stdlib branch from b9265e7 to 574004e Compare February 22, 2021 05:38
@zoecarver
Copy link
Contributor Author

@swift-ci please clean smoke test macOS.

@zoecarver
Copy link
Contributor Author

@swift-ci please clean smoke test macOS.

@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -enable-cxx-interop -I %S/Inputs %s -emit-ir | %FileCheck %s
// RUN: %cxx-all-targets(-I %S/Inputs %s -emit-ir | %FileCheck %s)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self: revert this change; it requires macos.

@zoecarver zoecarver force-pushed the cxx/cross-compile-stdlib branch 3 times, most recently from a55d466 to 73473c7 Compare September 21, 2021 23:13
@zoecarver
Copy link
Contributor Author

Once compnerd/uswift/pull/19 lands I should be able to run the bots here.

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test.

@zoecarver
Copy link
Contributor Author

@swift-ci please test Windows.

@zoecarver
Copy link
Contributor Author

@swift-ci please test windows

@zoecarver
Copy link
Contributor Author

@shahmishal no pressure, but would you like to review this?

@gottesmm @compnerd friendly ping.

@zoecarver
Copy link
Contributor Author

zoecarver commented Nov 29, 2021

@compnerd would you mind reviewing this patch? I'm about to push a rebased version but the logic is all the same.

I know you want us to support Windows better, specifically around IRGen. I think this patch will help that effort a lot. If we can test all platforms on any device, we will inevitably support all platforms better.

Edit: when I say "push a rebased version" I mean "push a rebased version to the PR for review." Sorry for not being more clear.

@zoecarver zoecarver force-pushed the cxx/cross-compile-stdlib branch from 73473c7 to 69b5ba5 Compare November 29, 2021 20:30
@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test.

)

# Build uswift for each target.
for (( i=1; i<${uswift_targets_length}+1; i+=2 ));
Copy link
Member

Choose a reason for hiding this comment

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

Why? Why not do:

for target in ${uswift_targets[@]} ; do
done

else
all_cmake_options=(
"${all_cmake_options[@]}"
-D CMAKE_Swift_FLAGS="-Xfrontend -disable-legacy-type-info"
Copy link
Member

Choose a reason for hiding this comment

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

Why not do this unconditionally?


Whether this product is produced by build-script-impl.
"""
return True
Copy link
Member

Choose a reason for hiding this comment

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

We really should not add a new build-script-impl product but rather move it here.

@@ -11,15 +11,15 @@
"swift-argument-parser": {
"remote": { "id": "apple/swift-argument-parser" } },
"swift-atomics": {
"remote": { "id": "apple/swift-atomics" } },
"remote": { "id": "apple/swift-atomics" } },
Copy link
Member

Choose a reason for hiding this comment

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

Could you split out and pre-apply the whitespace changes please?

@@ -2134,6 +2134,16 @@ if platform.system() != 'Darwin' or swift_test_mode == 'optimize_none_with_impli
#

config.substitutions.append(('%target-clangxx', '%s -std=c++11' % config.target_clang))
config.substitutions.append(('%cxx-all-targets\(([^)]+)\)',
Copy link
Member

Choose a reason for hiding this comment

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

I think that moving this to the next commit is better. Additionally, I'm not sure how I feel about this - this is a really really really complex way to do this. We already push lit well beyond what it should be used as, and this is particularly horrendous. Can we use a different approach for this? I think that adding the subdirectory as a multiple test suites in a lit.local.cfg might be better.

…e targets.

Updates the build script, update checkout script, and lit config to
support cross compiling uswift, then using uswift to cross compile and
run tests on multiple targets locally.
@zoecarver zoecarver force-pushed the cxx/cross-compile-stdlib branch from 69b5ba5 to 6779745 Compare February 18, 2022 23:46
…titution.

This patch updates most of the Interop/Cxx IRGen tests to use the
%cxx-all-targets lit substituion which will run these tests on several
targets. This commit only changes tests which didn't require further
modification to pass, there are still 11 tests which could use this
subsitution but would require some sort of change.
@zoecarver zoecarver force-pushed the cxx/cross-compile-stdlib branch from 6779745 to c18da8b Compare February 18, 2022 23:48
@zoecarver
Copy link
Contributor Author

@swift-ci please test.

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.

3 participants