diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 0783ab21a46c0..a66080c16218e 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -240,6 +240,11 @@ The .NET Foundation licenses this file to you under the MIT license. + + + diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 2cf7aaca8f526..b8fa61cc56e7a 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -503,12 +503,6 @@ else() message(FATAL_ERROR "TARGET_ARCH='${TARGET_ARCH}' not supported.") endif() -if(HOST_ANDROID AND (HOST_AMD64 OR HOST_ARM64)) - # Google requires all the native libraries to be aligned to 16 bytes (for 16k memory page size) - # This applies only to 64-bit binaries - add_link_options(LINKER:-z,max-page-size=16384) -endif() - # arm64 MacCatalyst runtime host or AOT target is more like Apple mobile targets than x64 if ((HOST_MACCAT AND HOST_ARM64) OR (TARGET_MACCAT AND TARGET_ARM64)) set(TARGET_APPLE_MOBILE 1) @@ -903,6 +897,13 @@ if(CLR_CMAKE_HOST_APPLE) endif() endif() +if(HOST_ANDROID) + if(HOST_AMD64 OR HOST_ARM64) + # Google requires all the native libraries to be aligned to 16 bytes (for 16k memory page size) + # This applies only to 64-bit binaries + add_link_options(LINKER:-z,max-page-size=16384) + endif() +endif() ### End of OS specific checks include_directories("${CLR_SRC_NATIVE_DIR}") diff --git a/src/tasks/LibraryBuilder/LibraryBuilder.cs b/src/tasks/LibraryBuilder/LibraryBuilder.cs index f2be73ae9f5b5..fa181eb9c40c8 100644 --- a/src/tasks/LibraryBuilder/LibraryBuilder.cs +++ b/src/tasks/LibraryBuilder/LibraryBuilder.cs @@ -339,8 +339,10 @@ private string BuildAndroidLibrary(List sources, List libs, List buildOptions.LinkerArguments.Add($"--soname={libraryName}"); // Google requires all the native libraries to be aligned to 16 bytes (for 16k memory page size) - // This is required only for 64-bit binaries, but there's not much harm if it is also done for 32-bit ones. - buildOptions.LinkerArguments.Add($"-z,max-page-size=16384"); + // This is required only for 64-bit binaries. + if (string.CompareOrdinal ("android-arm64", RuntimeIdentifier) == 0 || string.CompareOrdinal ("android-x64", RuntimeIdentifier) == 0) { + buildOptions.LinkerArguments.Add($"-z,max-page-size=16384"); + } buildOptions.LinkerArguments.AddRange(linkerArgs); buildOptions.NativeLibraryPaths.AddRange(libs); buildOptions.Sources.AddRange(sources);