|
2 | 2 | using System.IO; |
3 | 3 | using System.Linq; |
4 | 4 | using System.Text; |
| 5 | +using System.Text.RegularExpressions; |
5 | 6 | using System.Xml.Linq; |
6 | 7 | using Microsoft.Build.Framework; |
7 | 8 | using NUnit.Framework; |
@@ -209,12 +210,29 @@ public void BuildAotApplication (string supportedAbis, bool enableLLVM, bool exp |
209 | 210 | proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1"); |
210 | 211 | proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis); |
211 | 212 | proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); |
| 213 | + if (enableLLVM) { |
| 214 | + // Set //uses-sdk/@android:minSdkVersion so that LLVM uses the right libc.so |
| 215 | + proj.AndroidManifest = $@"<?xml version=""1.0"" encoding=""utf-8""?> |
| 216 | +<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" android:versionCode=""1"" android:versionName=""1.0"" package=""{proj.PackageName}""> |
| 217 | + <uses-sdk android:minSdkVersion=""10"" /> |
| 218 | + <application android:label=""{proj.ProjectName}""> |
| 219 | + </application> |
| 220 | +</manifest>"; |
| 221 | + } |
212 | 222 | using (var b = CreateApkBuilder (path)) { |
213 | 223 | b.ThrowOnBuildFailure = false; |
214 | 224 | b.Verbosity = LoggerVerbosity.Diagnostic; |
215 | 225 | Assert.AreEqual (expectedResult, b.Build (proj), "Build should have {0}.", expectedResult ? "succeeded" : "failed"); |
216 | 226 | if (!expectedResult) |
217 | 227 | return; |
| 228 | + if (enableLLVM) { |
| 229 | + // LLVM passes a direct path to libc.so, and we need to use the libc.so |
| 230 | + // which corresponds to the *minimum* SDK version specified in AndroidManifest.xml |
| 231 | + // Since we overrode minSdkVersion=10, that means we should use libc.so from android-9. |
| 232 | + var rightLibc = new Regex (@"^\s*\[AOT\].*cross-.*--llvm.*,ld-flags=.*android-9.arch-.*.usr.lib.libc\.so", RegexOptions.Multiline); |
| 233 | + var m = rightLibc.Match (b.LastBuildOutput); |
| 234 | + Assert.IsTrue (m.Success, "AOT+LLVM should use libc.so from minSdkVersion!"); |
| 235 | + } |
218 | 236 | foreach (var abi in supportedAbis.Split (new char [] { ';' })) { |
219 | 237 | var libapp = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, |
220 | 238 | "bundles", abi, "libmonodroid_bundle_app.so"); |
|
0 commit comments