Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Add support for ABI-specific NDK app platforms #1889

Closed
wants to merge 3 commits into from

Conversation

LegNeato
Copy link
Contributor

Fixes #1836.

@LegNeato
Copy link
Contributor Author

CI failures look unrelated.

@facebook-github-bot
Copy link
Contributor

@LegNeato has updated the pull request.

Copy link
Contributor

@bobyangyf bobyangyf left a comment

Choose a reason for hiding this comment

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

@styurin You seem to have more context on the corresponding issue :)

@@ -0,0 +1,88 @@
/*
* Copyright 2017-present Facebook, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

2018

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@LegNeato LegNeato force-pushed the ndk_abi_platform branch from a3764d3 to 0f2b098 Compare May 17, 2018 03:32
@facebook-github-bot
Copy link
Contributor

@LegNeato has updated the pull request.

@kageiit
Copy link
Contributor

kageiit commented May 17, 2018

Does this also fix #1890 potentially?

@LegNeato
Copy link
Contributor Author

LegNeato commented May 17, 2018

@kageiit haven't 100% looked into it, but I believe so from a quick glance.

That being said, I think there is more work to do as it would be pretty crappy for buck to not work by default and need to be configured in order to work with the latest ndk.

@LegNeato
Copy link
Contributor Author

Friendly poke 👉 @styurin

@@ -268,6 +264,7 @@ public static boolean isSupportedConfiguration(Path ndkRoot, NdkCxxRuntime cxxRu

// ARM Platform
Copy link
Contributor

Choose a reason for hiding this comment

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

Github is not letting me comment on the actual code line in this file, but can we change

  public static final ImmutableSet<String> DEFAULT_CPU_ABIS =
      ImmutableSet.of("arm", "armv7", "x86");

to

  public static final ImmutableSet<String> DEFAULT_CPU_ABIS =
      ImmutableSet.of("armv7", "x86");

That will make buck work by default with the latest ndk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, though that is a different change. I'll put up another PR. Also, it would be a breaking change for people not using the latest ndk so I am not sure if that is acceptable or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LegNeato LegNeato force-pushed the ndk_abi_platform branch from 0f2b098 to beaf18f Compare May 24, 2018 23:41
@facebook-github-bot
Copy link
Contributor

@LegNeato has updated the pull request.

@LegNeato
Copy link
Contributor Author

Fixed formatting to pass Travis.

Copy link

@styurin styurin left a comment

Choose a reason for hiding this comment

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

We have lots of integration tests for Android rules. Can you add integration tests for this logic?

{literal}<pre class="prettyprint lang-ini">
[ndk]
app_platform = android-19
app_platform-arm64 = android-21
Copy link

Choose a reason for hiding this comment

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

Can we have a map instead? Buck configuration supports keeping maps in a single option. For example:

app_platform_per_abi = arm64 => android-21, armv7 => android-23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, though I did it this way to try to generally be consistent with https://buckbuild.com/concept/buckconfig.html#halide.target. Still want me to change it?

Copy link

Choose a reason for hiding this comment

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

Yeah, could you change that to using a map?

@@ -65,7 +68,7 @@ public Integer getAdbTimeout() {
return delegate.getValue("ndk", "ndk_repository_path");
}

public Optional<String> getNdkAppPlatform() {
public Optional<String> getNdkCpuAbiAgnosticAppPlatform() {
Copy link

Choose a reason for hiding this comment

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

I'd call it getDefaultAppPlatform

Copy link
Contributor Author

@LegNeato LegNeato May 25, 2018

Choose a reason for hiding this comment

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

I thought "default" might be confusing as it isn't actually a providing real default in the config sense, that happens further down in the stack. So "default" is kinda ambiguous here for callers. I guess I could have used "fallback", which feels more correct than default to me as well (getFallbackAppPlatform or getNdkCpuAbiFallbackAppPlatform). Happy to change it to whatever you want.

@LegNeato
Copy link
Contributor Author

LegNeato commented May 25, 2018

@styurin Any pointers on how to check that a particular app platform is used when building? I can definitely write integration tests I just can't reason about how to go about it. I guess I can use this to build for arm64...but then running the tests will require a min version of the NDK installed...is that acceptable? Right now it looks like travis uses r10e.

@styurin
Copy link

styurin commented May 25, 2018

Check this class, it has some check for Android SDK: https://github.com/facebook/buck/blob/master/test/com/facebook/buck/android/AssumeAndroidPlatform.java

@facebook-github-bot
Copy link
Contributor

@LegNeato has updated the pull request. View: changes

@LegNeato
Copy link
Contributor Author

LegNeato commented May 25, 2018

@styurin Added integration tests that compile and check the symbols. Let me know about your responses to the naming and map stuff and I'll change them if needed...otherwise this is good to go. Not sure what is going on with Travis, it all passes locally.

Copy link
Contributor

@bobyangyf bobyangyf left a comment

Choose a reason for hiding this comment

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

Looks like builds are failing. Are you doing buck build on master locally?
Travis will build with ant and buck itself.
https://travis-ci.org/facebook/buck/builds/383549665?utm_source=github_status&utm_medium=notification

Can you make sure the BUCK files have the correct dependencies listed.
This looks like it might also be a merge conflict somewhere.

@LegNeato
Copy link
Contributor Author

Travis failure is unrelated and fixed by #1925.

@LegNeato
Copy link
Contributor Author

@styurin @bobyangyf this should be ready now!

@bobyangyf
Copy link
Contributor

Thanks. We'll import it now.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@bobyangyf has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -0,0 +1,36 @@
#ifdef __ANDROID__
# include <android/api-level.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Internally, the NdkIntegration tests are failing due to this import being missing.

Are you expecting some specific installation of android?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bobyangyf not exactly sure, can't find an answer as to when that was introduced or removed. Does using # include <sys/cdefs.h> instead fix it with your version? What version of the ndk are you building with?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like only ndk20+ has this header file.
https://android.googlesource.com/platform/development/+/73a5a3b/ndk/platforms

We can change it so that
#ifdef __ANDROID_NDK__ #include <android/api-level.h> #endif

However, this breaks your tests at the places that I am highlighting on your code review.

zipInspector.assertFileExists("lib/armeabi-v7a/libnative_app_platform_lib.so");

info = syms.getSymbolsAndDtNeeded(apkPath, "lib/x86/libnative_app_platform_lib.so");
assertThat(info.symbols.global, Matchers.hasItem("Android16"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This fails

zipInspector.assertFileExists("lib/armeabi-v7a/libnative_app_platform_lib.so");

info = syms.getSymbolsAndDtNeeded(apkPath, "lib/x86/libnative_app_platform_lib.so");
assertThat(info.symbols.global, Matchers.hasItem("Android18"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This fails.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants