Skip to content

Commit e21e634

Browse files
committed
Package actual NDK libs instead of stubs
The NativeLinker helper and the LinkNativeRuntime tasks need to be modified slightly to allow more control over order of link items on the linker command line.
1 parent 5d2334a commit e21e634

File tree

13 files changed

+123
-33
lines changed

13 files changed

+123
-33
lines changed

Configuration.props

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
<PropertyGroup>
233233
<_MonoRuntimeFlavorDirName>mono</_MonoRuntimeFlavorDirName>
234234
<_CLRRuntimeFlavorDirName>clr</_CLRRuntimeFlavorDirName>
235+
<_RuntimeRedistDirName>redist</_RuntimeRedistDirName>
235236
</PropertyGroup>
236237

237238

build-tools/create-packs/Microsoft.Android.Runtime.proj

+15-11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ projects that use the Microsoft.Android framework in .NET 6+.
3333
<FrameworkListFile Condition="'$(FrameworkListFile)' == ''">$(IntermediateOutputPath)$(AndroidRID)\RuntimeList.xml</FrameworkListFile>
3434
<_RuntimeFlavorDirName Condition=" '$(AndroidRuntime)' == 'CoreCLR' ">$(_CLRRuntimeFlavorDirName)</_RuntimeFlavorDirName>
3535
<_RuntimeFlavorDirName Condition=" '$(AndroidRuntime)' == 'Mono' Or '$(AndroidRuntime)' == '' ">$(_MonoRuntimeFlavorDirName)</_RuntimeFlavorDirName>
36+
<_ClangArch Condition=" '$(AndroidRID)' == 'android-arm64' ">aarch64</_ClangArch>
37+
<_ClangArch Condition=" '$(AndroidRID)' == 'android-arm' ">arm</_ClangArch>
38+
<_ClangArch Condition=" '$(AndroidRID)' == 'android-x64' ">x86_64</_ClangArch>
39+
<_ClangArch Condition=" '$(AndroidRID)' == 'android-x86' ">i686</_ClangArch>
3640
</PropertyGroup>
3741

3842
<ItemGroup>
@@ -72,12 +76,12 @@ projects that use the Microsoft.Android framework in .NET 6+.
7276
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libxamarin-startup-debug.a') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libxamarin-startup-debug.a" />
7377
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libxamarin-startup-release.a') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libxamarin-startup-release.a" />
7478

75-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\crtbegin_so.o') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\crtbegin_so.o" />
76-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\crtend_so.o') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\crtend_so.o" />
77-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc++_static.a') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc++_static.a" />
78-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc++abi.a') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc++abi.a" />
79-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libclang_rt.builtins-aarch64-android.a') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libclang_rt.builtins-aarch64-android.a" />
80-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libclang_rt.builtins-x86_64-android.a') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libclang_rt.builtins-x86_64-android.a" />
79+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\crtbegin_so.o" />
80+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\crtend_so.o" />
81+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libc++_static.a" />
82+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libc++abi.a" />
83+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libclang_rt.builtins-$(_ClangArch)-android.a" />
84+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libunwind.a" />
8185
</ItemGroup>
8286

8387
<ItemGroup Condition=" '$(AndroidRuntime)' == 'Mono' ">
@@ -90,11 +94,11 @@ projects that use the Microsoft.Android framework in .NET 6+.
9094

9195
<ItemGroup Condition=" '$(AndroidRuntime)' != 'NativeAOT' ">
9296
<!-- TODO: the Exists() checks must go away once we build CoreCLR host for all the targets -->
93-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc.so" />
94-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libdl.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libdl.so" />
95-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\liblog.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\liblog.so" />
96-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libm.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libm.so" />
97-
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libz.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libz.so" />
97+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libc.so" />
98+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libdl.so" />
99+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\liblog.so" />
100+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libm.so" />
101+
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\$(AndroidRID)\libz.so" />
98102
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libarchive-dso-stub.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libarchive-dso-stub.so" />
99103
</ItemGroup>
100104

build-tools/xaprepare/xaprepare/Application/KnownProperties.cs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static class KnownProperties
5353
public const string Pkg7Zip_CommandLine = "Pkg7-Zip_CommandLine";
5454
public const string PkgXamarin_LibZipSharp = "PkgXamarin_LibZipSharp";
5555
public const string ProductVersion = "ProductVersion";
56+
public const string RuntimeRedistDirName = "_RuntimeRedistDirName";
5657
public const string XABuildToolsFolder = "XABuildToolsFolder";
5758
public const string XABuildToolsVersion = "XABuildToolsVersion";
5859
public const string XABuildToolsPackagePrefixMacOS = "XABuildToolsPackagePrefixMacOS";

build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace Xamarin.Android.Prepare
5757
properties.Add (KnownProperties.Pkg7Zip_CommandLine, StripQuotes (@"@Pkg7-Zip_CommandLine@"));
5858
properties.Add (KnownProperties.PkgXamarin_LibZipSharp, StripQuotes (@"@PkgXamarin_LibZipSharp@"));
5959
properties.Add (KnownProperties.ProductVersion, StripQuotes ("@ProductVersion@"));
60+
properties.Add (KnownProperties.RuntimeRedistDirName, StripQuotes ("@_RuntimeRedistDirName@"));
6061
properties.Add (KnownProperties.XABuildToolsFolder, StripQuotes (@"@XABuildToolsFolder@"));
6162
properties.Add (KnownProperties.XABuildToolsVersion, StripQuotes ("@XABuildToolsVersion@"));
6263
properties.Add (KnownProperties.XABuildToolsPackagePrefixMacOS, StripQuotes ("@XABuildToolsPackagePrefixMacOS@"));

build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs

+32-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ sealed class AndroidPackage
2323
}
2424
#nullable enable
2525

26+
static readonly string[] CRTFiles = {
27+
"crtbegin_so.o",
28+
"crtend_so.o",
29+
"libc.so",
30+
"libdl.so",
31+
"liblog.so",
32+
"libm.so",
33+
"libz.so",
34+
};
35+
36+
static readonly string[] CPPAbiFiles = {
37+
"libc++_static.a",
38+
"libc++abi.a",
39+
};
40+
41+
static readonly string[] ClangArchFiles = {
42+
"libunwind.a",
43+
};
44+
2645
bool RefreshSdk = false;
2746
bool RefreshNdk = false;
2847
AndroidToolchainComponentType DependencyTypeToInstall = AndroidToolchainComponentType.All;
@@ -194,20 +213,25 @@ bool CopyRedistributableFiles (Context context)
194213
string crtFilesPath = Path.Combine (abiDir, BuildAndroidPlatforms.NdkMinimumAPI.ToString (CultureInfo.InvariantCulture));
195214
string clangArch = Configurables.Defaults.AbiToClangArch[abi];
196215

197-
CopyFile (abi, crtFilesPath, "crtbegin_so.o");
198-
CopyFile (abi, crtFilesPath, "crtend_so.o");
216+
foreach (string file in CRTFiles) {
217+
CopyFile (abi, crtFilesPath, file);
218+
}
219+
220+
foreach (string file in CPPAbiFiles) {
221+
CopyFile (abi, abiDir, file);
222+
}
223+
199224
CopyFile (abi, clangLibPath, $"libclang_rt.builtins-{clangArch}-android.a");
200225

201226
// Yay, consistency
202227
if (String.Compare (clangArch, "i686", StringComparison.Ordinal) == 0) {
203228
clangArch = "i386";
204229
}
230+
string clangArchLibPath = Path.Combine (clangLibPath, clangArch);
205231

206-
CopyFile (abi, abiDir, "libc++_static.a");
207-
CopyFile (abi, abiDir, "libc++abi.a");
208-
209-
// Remove once https://github.com/dotnet/runtime/pull/107615 is merged and released
210-
CopyFile (abi, Path.Combine (clangLibPath, clangArch), "libunwind.a");
232+
foreach (string file in ClangArchFiles) {
233+
CopyFile (abi, clangArchLibPath, file);
234+
}
211235
}
212236

213237
return true;
@@ -218,7 +242,7 @@ void CopyFile (string abi, string sourceDir, string fileName)
218242
string rid = Configurables.Defaults.AbiToRID [abi];
219243
string outputDir = Path.Combine (
220244
context.Properties.GetRequiredValue (KnownProperties.NativeRuntimeOutputRootDir),
221-
context.Properties.GetRequiredValue (KnownProperties.CLRRuntimeFlavorDirName),
245+
context.Properties.GetRequiredValue (KnownProperties.RuntimeRedistDirName),
222246
rid
223247
);
224248

build-tools/xaprepare/xaprepare/xaprepare.targets

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<Replacement Include="@Pkg7-Zip_CommandLine@=$(Pkg7-Zip_CommandLine)" />
9191
<Replacement Include="@PkgXamarin_LibZipSharp@=$(PkgXamarin_LibZipSharp)" />
9292
<Replacement Include="@ProductVersion@=$(ProductVersion)" />
93+
<Replacement Include="@_RuntimeRedistDirName@=$(_RuntimeRedistDirName)" />
9394
<Replacement Include="@XABuildToolsFolder@=$(XABuildToolsFolder)" />
9495
<Replacement Include="@XABuildToolsVersion@=$(XABuildToolsVersion)" />
9596
<Replacement Include="@XABuildToolsPackagePrefixMacOS@=$(XABuildToolsPackagePrefixMacOS)" />

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeRuntime.targets

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@ Contains code to build and link the native runtime at application build time.
4343
Inputs="@(_NativeAssemblyTarget);@(_SelectedNativeArchive)"
4444
Outputs="@(_UnifiedNativeRuntime)"
4545
Condition=" '$(_AndroidEnableNativeRuntimeLinking)' == 'true' ">
46+
47+
<!-- AndroidApiLevel must be set to the same version our runtime, MonoVM and CoreCLR are built
48+
against -->
4649
<LinkNativeRuntime
4750
MonoComponents="@(_MonoComponent)"
4851
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
52+
AndroidNdkDirectory="$(_AndroidNdkDirectory)"
53+
AndroidApiLevel="$(AndroidMinimumSupportedApiLevel)"
4954
IntermediateOutputPath="$(IntermediateOutputPath)"
5055
NativeArchives="@(_SelectedNativeArchive)"
5156
NativeObjectFiles="@(_NativeAssemblyTarget)"
@@ -55,7 +60,8 @@ Contains code to build and link the native runtime at application build time.
5560
LinkLibraries="@(_RequiredLinkLibraries)"
5661
OutputRuntimes="@(_UnifiedNativeRuntime)"
5762
SupportedAbis="@(_BuildTargetAbis)"
58-
SaveDebugSymbols="true"
63+
SaveDebugSymbols="false"
64+
StripDebugSymbols="false"
5965
RuntimePackLibraryDirectories="@(_RuntimePackLibraryDirectory)" />
6066

6167
<ItemGroup>

src/Xamarin.Android.Build.Tasks/Tasks/GetNativeRuntimeComponents.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void HackMakeArchiveItem (NativeRuntimeComponents.Archive archive, List<ITaskIte
163163
var relativeArtifactPaths = new List<(string path, string abi)> ();
164164
string archiveName = Path.GetFileName (archive.Name);
165165
string commonClrObjDir = Path.Combine ("artifacts", "obj", "coreclr");
166-
const string config = "Release"; // or Debug
166+
const string config = "Debug"; // or Release
167167

168168
if (IsArchive ("libcoreclr.a")) {
169169
archiveName = "libcoreclr_static.a";

src/Xamarin.Android.Build.Tasks/Tasks/LinkNativeRuntime.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public class LinkNativeRuntime : AsyncTask
1818
[Required]
1919
public string AndroidBinUtilsDirectory { get; set; }
2020

21+
public string? AndroidNdkDirectory { get; set; }
22+
public string? AndroidApiLevel { get; set; }
23+
2124
[Required]
2225
public string IntermediateOutputPath { get; set; }
2326

@@ -48,7 +51,8 @@ public class LinkNativeRuntime : AsyncTask
4851
[Required]
4952
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
5053

51-
public bool SaveDebugSymbols { get; set; }
54+
public bool SaveDebugSymbols { get; set; } = true;
55+
public bool StripDebugSymbols { get; set; } = true;
5256

5357
public override System.Threading.Tasks.Task RunTaskAsync ()
5458
{
@@ -66,7 +70,11 @@ void LinkRuntime (ITaskItem abiItem)
6670
}
6771

6872
var linker = new NativeLinker (Log, abi, soname, AndroidBinUtilsDirectory, IntermediateOutputPath, RuntimePackLibraryDirectories, CancellationToken, Cancel) {
73+
StripDebugSymbols = StripDebugSymbols,
6974
SaveDebugSymbols = SaveDebugSymbols,
75+
UseNdkLibraries = true,
76+
NdkRootPath = AndroidNdkDirectory,
77+
NdkApiLevel = AndroidApiLevel,
7078
};
7179
linker.Link (
7280
outputRuntime,

src/Xamarin.Android.Build.Tasks/Utilities/NativeLinker.cs

+38-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class NativeLinker
1515
{
1616
static readonly List<string> standardArgs = new () {
1717
"--shared",
18-
"--allow-shlib-undefined",
1918
// TODO: need to enable zstd in binutils build
2019
// "--compress-debug-sections=zstd",
2120
// TODO: test the commented-out flags
@@ -42,8 +41,12 @@ class NativeLinker
4241
readonly CancellationToken? cancellationToken;
4342
readonly Action? cancelTask;
4443

45-
public bool StripDebugSymbols { get; set; }
46-
public bool SaveDebugSymbols { get; set; }
44+
public bool StripDebugSymbols { get; set; } = true;
45+
public bool SaveDebugSymbols { get; set; } = true;
46+
public bool AllowUndefinedSymbols { get; set; } = false;
47+
public bool UseNdkLibraries { get; set; } = false;
48+
public string? NdkRootPath { get; set; }
49+
public string? NdkApiLevel { get; set; }
4750

4851
public NativeLinker (TaskLoggingHelper log, string abi, string soname, string binutilsDir, string intermediateDir,
4952
IEnumerable<ITaskItem> runtimePackLibDirs, CancellationToken? cancellationToken = null, Action? cancelTask = null)
@@ -96,6 +99,16 @@ public NativeLinker (TaskLoggingHelper log, string abi, string soname, string bi
9699
public bool Link (ITaskItem outputLibraryPath, List<ITaskItem> objectFiles, List<ITaskItem> archives, List<ITaskItem> libraries,
97100
List<ITaskItem> linkStartFiles, List<ITaskItem> linkEndFiles, ICollection<ITaskItem>? exportDynamicSymbols = null)
98101
{
102+
if (UseNdkLibraries) {
103+
if (String.IsNullOrEmpty (NdkRootPath)) {
104+
throw new InvalidOperationException ("Internal error: request to use NDK libraries, but NDK root not specified.");
105+
}
106+
107+
if (String.IsNullOrEmpty (NdkApiLevel)) {
108+
throw new InvalidOperationException ("Internal error: request to use NDK libraries, but NDK API level not specified.");
109+
}
110+
}
111+
99112
log.LogDebugMessage ($"Linking: {outputLibraryPath}");
100113
EnsureCorrectAbi (outputLibraryPath);
101114
EnsureCorrectAbi (objectFiles);
@@ -113,6 +126,17 @@ public bool Link (ITaskItem outputLibraryPath, List<ITaskItem> objectFiles, List
113126
sw.WriteLine (arg);
114127
}
115128

129+
if (AllowUndefinedSymbols) {
130+
sw.WriteLine ("--allow-shlib-undefined");
131+
} else {
132+
sw.WriteLine ("--no-undefined");
133+
}
134+
135+
// This MUST go before extra args, since the NDK library path must take precedence over the path in extra args set in the ctor
136+
if (UseNdkLibraries) {
137+
sw.WriteLine ($"-L {MonoAndroidHelper.QuoteFileNameArgument (GetAbiNdkRootDir ())}");
138+
}
139+
116140
foreach (string arg in extraArgs) {
117141
sw.WriteLine (arg);
118142
}
@@ -160,8 +184,7 @@ public bool Link (ITaskItem outputLibraryPath, List<ITaskItem> objectFiles, List
160184
return ret;
161185
}
162186

163-
ret = ExtractDebugSymbols (outputLibraryPath);
164-
return ret;
187+
return ExtractDebugSymbols (outputLibraryPath);
165188

166189
void WriteFilesToResponseFile (StreamWriter sw, List<ITaskItem> files)
167190
{
@@ -202,6 +225,15 @@ bool ParseBooleanMetadata (ITaskItem item, string metadata)
202225
}
203226
}
204227

228+
string GetAbiNdkRootDir ()
229+
{
230+
// Let it throw if invalid
231+
int apiLevel = Int32.Parse (NdkApiLevel);
232+
NdkTools ndk = NdkTools.Create (NdkRootPath, logErrors: true, log: log);
233+
234+
return ndk.GetDirectoryPath (NdkToolchainDir.PlatformLib, MonoAndroidHelper.AbiToTargetArch (abi), apiLevel);
235+
}
236+
205237
void EnsureCorrectAbi (ITaskItem item)
206238
{
207239
// The exception is just a precaution, since the items passed to us should have already been checked
@@ -243,6 +275,7 @@ bool ExtractDebugSymbols (ITaskItem outputSharedLibrary)
243275

244276
stdoutLines.Clear ();
245277
stderrLines.Clear ();
278+
246279
args.Clear ();
247280
args.Add ("--strip-debug");
248281
args.Add ("--strip-unneeded");

src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public NativeRuntimeComponents (ITaskItem[] monoComponents)
135135
DontExportSymbols = true,
136136
},
137137

138-
// Remove once https://github.com/dotnet/runtime/pull/107615 is merged and released
139138
new Archive ("libunwind.a") {
140139
DontExportSymbols = true,
141140
},
@@ -146,12 +145,9 @@ public NativeRuntimeComponents (ITaskItem[] monoComponents)
146145
NativeLibraries = new () {
147146
"c",
148147
"dl",
148+
"log",
149149
"m",
150150
"z",
151-
"log",
152-
153-
// Atomic is a static library in clang, need to investigate if it's really needed
154-
// "atomic",
155151
};
156152

157153
// Files that will be linked before any other object/archive/library files

src/native/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ if(BUILD_ARCHIVE_DSO_STUB)
585585
add_subdirectory(common/archive-dso-stub)
586586
else()
587587
add_subdirectory(common/java-interop)
588-
add_subdirectory(common/libstub)
588+
# add_subdirectory(common/libstub)
589589
add_subdirectory(common/libunwind)
590590
add_subdirectory(common/lz4)
591591

src/native/native.targets

+15
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,24 @@
299299
AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)"
300300
AndroidRuntime="$(CMakeRuntimeFlavor)"
301301
RuntimePackName="$(_RuntimePackName)" />
302+
<_RuntimePackFiles Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\%(AndroidSupportedTargetJitAbi.AndroidRID)\*.so"
303+
AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)"
304+
AndroidRuntime="$(CMakeRuntimeFlavor)"
305+
RuntimePackName="$(_RuntimePackName)" />
302306
<!-- NOTE: not building native libraries for NativeAOT yet -->
303307
</ItemGroup>
304308

309+
<ItemGroup Condition=" '$(CMakeRuntimeFlavor)' == 'CoreCLR' ">
310+
<_RuntimePackFiles Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\%(AndroidSupportedTargetJitAbi.AndroidRID)\*.o"
311+
AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)"
312+
AndroidRuntime="$(CMakeRuntimeFlavor)"
313+
RuntimePackName="$(_RuntimePackName)" />
314+
<_RuntimePackFiles Include="$(NativeRuntimeOutputRootDir)$(_RuntimeRedistDirName)\%(AndroidSupportedTargetJitAbi.AndroidRID)\*.a"
315+
AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)"
316+
AndroidRuntime="$(CMakeRuntimeFlavor)"
317+
RuntimePackName="$(_RuntimePackName)" />
318+
</ItemGroup>
319+
305320
<Copy
306321
SourceFiles="%(_RuntimePackFiles.Identity)"
307322
DestinationFolder="$(MicrosoftAndroidPacksRootDir)Microsoft.Android.Runtime.%(_RuntimePackFiles.RuntimePackName).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\native"

0 commit comments

Comments
 (0)