Skip to content

[android] Update to NDK 23b #39921

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 1 commit into from
Nov 18, 2021
Merged

[android] Update to NDK 23b #39921

merged 1 commit into from
Nov 18, 2021

Conversation

finagolfin
Copy link
Member

The latest Long Term Support NDK finally removed binutils, including the bfd/gold linkers and libgcc. This simplifies our Android support, including making lld the default linker for Android. Disable three reflection tests that now fail, likely related to issues with swift-reflection-dump and switching to lld.

@drodriguez, this tweaks the now-reverted #39045 to work with the just-released LTS NDK 23b and pass the Windows CI. I also removed the libatomic addition on armv7, because NDK 23 just uses libcompiler-rt instead. You can diff this against #39045 to see the few tweaks I made.

The latest Long Term Support NDK finally removed binutils, including the bfd/gold
linkers and libgcc. This simplifies our Android support, including making lld the
default linker for Android. Disable three reflection tests that now fail, likely
related to issues with swift-reflection-dump and switching to lld.
@finagolfin
Copy link
Member Author

Rebased and switched from ar to llvm-ar too.

@finagolfin
Copy link
Member Author

@CodaFi, would you run the CI on this?

@artemcm
Copy link
Contributor

artemcm commented Nov 9, 2021

@swift-ci please test

Comment on lines +390 to +395
const char *AR;
// Configure the toolchain.
const char *AR =
context.OI.LTOVariant != OutputInfo::LTOKind::None ? "llvm-ar" : "ar";
if (getTriple().isAndroid())
AR = "llvm-ar";
else
AR = context.OI.LTOVariant != OutputInfo::LTOKind::None ? "llvm-ar" : "ar";
Copy link
Contributor

Choose a reason for hiding this comment

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

It is still my opinion that if we are going to keep adding isAndroid() branches to the GenericUnix toolchain, it would be better to add a Android toolchain (like OpenBSD and Cygwin already have) and stop adding special branches for Android. Not something to hold the PR, but something you should think about if these special cases keep popping 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.

Sure, I'll look into spinning that out.

Comment on lines +66 to +68
if 'ANDROID_DATA' in os.environ:
_register("ranlib", "llvm-ranlib")
_register("ar", "llvm-ar")
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, this is just things needed for your specific environment. LLVM can install symlinks with the unprefixed name if you ask. You can create this symlinks in your machine. The LLVM reimplementations are supposed to be command-line compatible with the GNU counterparts most of the time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes and no, this checks if the build-script is running natively on Android itself, which means it's almost certainly running in the Termux app. With the switch to NDK 23b, I've switched both the native clang and swift toolchains in Termux to use llvm-ar directly, as that's what the NDK 23b does without providing a symlink to ar. This keeps everything consistent across the NDK and the Termux app.

Since it keeps everything consistent and only ever affects those few people building the Swift toolchain natively on Android, this shouldn't affect anybody else but makes native compilation on Android work out of the box.

@drodriguez drodriguez merged commit 30c292c into swiftlang:main Nov 18, 2021
@finagolfin
Copy link
Member Author

Android AArch64 CI just passed, armv7 should pass in a couple minutes, glad to see the CI on the latest NDK. 🧨

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