-
Notifications
You must be signed in to change notification settings - Fork 533
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
Audit AndroidNdkDirectory Use #7599
Comments
One thing that needs to be done, is detection of LLVM version used by the NDK pointed to by LLVM version can be checked by reading
|
My guess is that it was the lack of LLVM version detection which caused the difference between |
@grendello, @jonathanpeppers : my previous comment raises a closely related question: Given an environment in which an NDK is installed & configured (e.g. likely most of our machines, AzDO Pipeline builds for customers, etc.), how do we prefer use of our bundled binutils and avoid use of the external NDK? The "post- 346a933 world order" is "use Should we add a new |
@jonpryor if it's for building our stuff only (our shared libraries + AOT) then we should definitely prefer our bundled binutils, agreed. We neeed to consider a case when an app builds a native library of its own - in which case it's very likely they need to use the NDK, since we provide no headers, no static libraries etc - if they do it within the context of |
If we have |
…y rather than AndroidNdkDirectory (dotnet/android#7599)
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.), Android for .NET (net6.0-android, etc.)
Affected platform version
VS 17.4, .NET 7
Description
Context: 346a933
Context: e1f2198
Context: #7588
For our own sanity, we need to audit
src/Xamarin.Android.Build.Tasks
to ensure that we consistently use$(_AndroidNdkDirectory)
everywhere, not$(AndroidNdkDirectory)
. Currently some task invocations use$(_AndroidNdkDirectory)
(e.g.<BuildApk/>
), while others use$(AndroidNdkDirectory)
(e.g.<GetAotAssemblies/>
,<Aot/>
). This inconsistency results in confusion.We need to standardize on
$(_AndroidNdkDirectory)
everywhere.Rationale:
$(AndroidNdkDirectory)
is the documented way to specify/override the NDK directory. (TODO: actually document it! It's not listed in the build-properties docs! 🤦)In particular, this means that it may be specified on the command line:
However, properties specified on the command line are "global", and global properties cannot be changed. Consequently, any MSBuild property which we need to validate and replace (if invalid) must be a "private" (
_
-prefixed) MSBuild property. This "validate and possibly replace" logic is done for properties such as$(AndroidSdkDirectory)
and$(AndroidNdkDirectory)
; if the "starting" values are unset or invalid (non-existent directory, etc.), then we will attempt to update/replace them with values from e.g.$HOME/.config/xbuild/monodroid-config.xml
.Aside: if you attempt to write to a global property, you will see messages such as the following in MSBuild diagnostic logs:
Steps to Reproduce
Instructions are for .NET 7, though Classic is approximately equivalent; Classic just needs to have
$(AndroidAot)
=True as well. (Profiled AOT is enabled by default in .NET 7.)Configure your build environment so that the NDK is installed, and it is configured within Visual Studio.
Create a new project:
Build it in Release configuration:
Review
b-no-ndk-override.txt
; in particular:The
AndroidNdkDirectory
property is never set.The
_AndroidNdkDirectory
property is set:The
<GetAotAssemblies/>
invocation (a) doesn't find an NDK (?!), and (b)$(_LdFlags)
contains--no-relax
:(3) in particular is required in some circumstances in order to avoid a runtime assert, fixed in e1f2198 (by adding
--no-relax
).Next, edit
aot-no-relax.csproj
and add an<AndroidNdkDirectory/>
property, e.g.Nuke the
bin
andobj
directories, and rebuild:In contrast to the
b-no-ndk-override.txt
build:The
AndroidNdkDirectory
property is set:The
$(_AndroidNdkDirectory)
property continues to be set by the<ResolveSdks/>
task, unchanged from theb-no-ndk-override.txt
output.Note: If
$(AndroidNdkDirectory)
is a valid NDK, and it differs from what VS has configured, then the$(_AndroidNdkDirectory)
property should match the input$(AndroidNdkDirectory)
property, not whatever VS has configured. The command-line override "wins".The
<GetAotAssemblies/>
invocation containsTask Parameter:AndroidNdkDirectory
-- which wasn't the case withb-no-ndk-override.txt
-- and the$(_LdFlags)
output property does not have--no-relax
:This is a difference in behavior which shouldn't exist: if
$(AndroidNdkDirectory)
isn't set and an NDK is appropriately configured, then the build should behave as if it were set. This can only be done if we use$(_AndroidNdkDirectory)
consistently everywhere for Task properties.Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: