Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[android] Enable several C++ Interop and other tests #74883

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

finagolfin
Copy link
Member

Also, update NDK and Ubuntu versions to the latest in the Android doc, enable inline bridging when building the compiler for Android, and update the default arch set by build-script to AArch64, as that is by far the most commonly used now.

These C++ Interop tests were all disabled over the years because of build errors with the Android NDK, but @hyp's recent pull #72161 adding a modularized Bionic module map fixed them and the inline bridging issue in the compiler itself. Alex, let me know if these tests all pass for you too.

@drodriguez, perhaps you'd like to take a look at this pull too.

@@ -4,7 +4,6 @@
// RUN: %FileCheck %s < %t/ir.ll

// UNSUPPORTED: OS=windows-msvc
// XFAIL: OS=linux-android, OS=linux-androideabi
Copy link
Member Author

Choose a reason for hiding this comment

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

I disabled this last year, 12f20ec, because it was failing with the clang 14 in NDK 25 at that time, but it builds fine with clang 17 in NDK 26 now.

@@ -1,8 +1,6 @@
// UNSUPPORTED: OS=windows-msvc
// static library is not well supported yet on Windows

// XFAIL: OS=linux-android, OS=linux-androideabi
Copy link
Member Author

Choose a reason for hiding this comment

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

Similarly, I disabled this last year because it didn't work with clang 14 in NDK 25, but it works with clang 17 in NDK 26 now.

test/lit.cfg Outdated
@@ -615,7 +615,7 @@ else:
config.swift_driver_test_options,
)
)
toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os)
toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', 'android' if kIsAndroid else host_os)
Copy link
Member Author

Choose a reason for hiding this comment

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

This path was just added late last year and broke building several macro tests natively on Android that have started using it.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, the host_os should be android if we are building for android right?

Copy link
Member Author

Choose a reason for hiding this comment

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

host_os is parsed from the host triple, which on Android is linux. That heuristic works on most platforms, but not for an Android host.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that is annoying. Thanks for the explanation!

test/lit.cfg Outdated
@@ -2428,8 +2428,12 @@ elif not kIsWindows and not run_os == 'wasi':
lit_config.note('Testing with the just-built libraries')

lit_config.note('Library load path: {0}'.format(os.path.pathsep.join(target_stdlib_path)))
env_path = "/usr/bin/env "
# Android doesn't have /usr/bin/, so just grab whatever `env` is in the PATH.
Copy link
Member

Choose a reason for hiding this comment

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

It does have /bin/env which is pretty standard, why not use that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll try running the tests with that instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -1403,7 +1403,7 @@ def create_argument_parser():

option('--android-arch', store,
choices=['armv7', 'aarch64', 'x86_64'],
default='armv7',
default='aarch64',
Copy link
Member

Choose a reason for hiding this comment

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

This seems unrelated? It's a welcome change, just seems not related to the test enablement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated to the title, yes, but these are all Android changes, and I specifically mention these non-test changes in the commit message.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, but it still helps to keep changes focused :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, this should probably be a separate patch, since it isn't just a test-only change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, this should probably be a separate patch, since it isn't just a test-only change.

It never says it's a test-only change, the label used is [android] and the commit message lists the non-test changes.

If you would like, I can split this into separate commits, but I see no reason to go farther.

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR title doesn't mention any non-test changes, which makes it confusing. I initially assumed that this is a test-only change.
I think the arch change should be its own commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I will split this commit up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@compnerd
Copy link
Member

compnerd commented Jul 3, 2024

@swift-ci please smoke test

@finagolfin
Copy link
Member Author

Sigh, File "/home/build-user/swift/test/lit.cfg", line 618, in <module> toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', 'android' if kIsAndroid else host_os) NameError: name 'kIsAndroid' is not defined.

I had simply hacked in make_path(config.swift_lib_dir, 'swift', 'android') in my local testing and then cleaned it up with the kIsAndroid check before submitting, without checking if that variable had been defined yet.

I'll clean that up and run the validation suite natively on Android on the entirety of this pull before asking for another CI run.

@finagolfin
Copy link
Member Author

finagolfin commented Jul 10, 2024

Alright, fixed the lit.cfg error and ran this entire pull through the compiler validation suite natively on Android, before splitting it up into narrower commits and rebasing it here.

This is ready for review and another CI run.

# Manually set the host OS on Android, because the host OS from the triple says
# `linux`.
if kIsAndroid:
host_os = 'android'
Copy link
Member Author

Choose a reason for hiding this comment

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

Rather than overriding this just for the new toolchain_lib_dir below, I overrode host_os itself on Android, as it is only used for that and target-same-as-host just below, which is only checked by a single macOS-only test, so changing this for Android hosts should be fine.

@@ -768,7 +768,7 @@ class BuildScriptImplOption(_BaseOption):
ChoicesOption('--swift-analyze-code-coverage',
choices=['false', 'not-merged', 'merged']),
ChoicesOption('--android-arch',
choices=['armv7', 'aarch64']),
choices=['armv7', 'aarch64', 'x86_64']),
Copy link
Member Author

Choose a reason for hiding this comment

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

This never triggered before because this just checks if it's a subset, so updating to all three arches supported now.

@finagolfin
Copy link
Member Author

@kateinoigakukun, need a CI run here.

@egorzhdan, maybe you can review.

@finagolfin
Copy link
Member Author

@rauhul, need a CI run here.

@finagolfin
Copy link
Member Author

@bnbarham, ready for a CI run here.

@bnbarham
Copy link
Contributor

@swift-ci please test

@finagolfin
Copy link
Member Author

Alright, passed CI, just need @egorzhdan or some one to review.

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

C++ interop changes LGTM

@finagolfin
Copy link
Member Author

@etcwilde, if you would review the few remaining Android changes, we can get this in.

@finagolfin
Copy link
Member Author

@bnbarham, ready for merge.

@finagolfin
Copy link
Member Author

@hyp, would you merge?

@bnbarham bnbarham merged commit d281fb8 into swiftlang:main Jul 26, 2024
5 checks passed
@bnbarham
Copy link
Contributor

Sorry, missed initial ping. Merged!

@finagolfin finagolfin deleted the droid branch July 27, 2024 03:00
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants