Skip to content

Commit

Permalink
addpkg(main): dotnet8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
truboxl committed Jan 7, 2025
1 parent bbe875e commit f4e2602
Show file tree
Hide file tree
Showing 22 changed files with 582 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/dotnet8.0/0001-build-all-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/src/runtime/src/native/libs/CMakeLists.txt
+++ b/src/runtime/src/native/libs/CMakeLists.txt
@@ -115,7 +115,7 @@ add_subdirectory(System.IO.Compression.Native)
if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
include(configure.cmake)

- if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID)
+ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
add_subdirectory(System.IO.Ports.Native)
endif ()

@@ -152,13 +152,10 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
#add_subdirectory(System.Net.Security.Native) # no gssapi on tvOS, see https://developer.apple.com/documentation/gss
# System.Security.Cryptography.Native is intentionally disabled on tvOS
# it is only used for interacting with OpenSSL which isn't useful there
- elseif (CLR_CMAKE_TARGET_ANDROID AND NOT FORCE_ANDROID_OPENSSL)
- add_subdirectory(System.Security.Cryptography.Native.Android)
- elseif (FORCE_ANDROID_OPENSSL)
- add_subdirectory(System.Security.Cryptography.Native)
else ()
add_subdirectory(System.Net.Security.Native)
add_subdirectory(System.Security.Cryptography.Native)
+ add_subdirectory(System.Security.Cryptography.Native.Android)
endif ()

if (CLR_CMAKE_TARGET_APPLE)
11 changes: 11 additions & 0 deletions packages/dotnet8.0/0002-define-memfd_create.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp
+++ b/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp
@@ -14,7 +14,7 @@
#include <assert.h>
#include <limits.h>
#include <errno.h>
-#if defined(TARGET_LINUX) && !defined(MFD_CLOEXEC)
+#if (defined(TARGET_LINUX) && !defined(MFD_CLOEXEC)) || defined(TARGET_ANDROID)
#include <linux/memfd.h>
#include <sys/syscall.h> // __NR_memfd_create
#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- a/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt
+++ b/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt
@@ -64,7 +64,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
${NATIVE_LIBS_EXTRA}
)

- if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID)
+ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/System.IO.Compression.Native_unixexports.src)
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/System.IO.Compression.Native.exports)
generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
@@ -122,7 +122,7 @@ else ()
)
endif ()

- if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI)
+ if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI)
set(NATIVECOMPRESSION_SOURCES ${NATIVECOMPRESSION_SOURCES} entrypoints.c)
endif ()

--- a/src/runtime/src/native/libs/System.IO.Compression.Native/extra_libs.cmake
+++ b/src/runtime/src/native/libs/System.IO.Compression.Native/extra_libs.cmake
@@ -5,7 +5,7 @@ macro(append_extra_compression_libs NativeLibsExtra)
# nothing special to link
elseif (CLR_CMAKE_TARGET_ANDROID OR HOST_ANDROID)
# need special case here since we want to link against libz.so but find_package() would resolve libz.a
- set(ZLIB_LIBRARIES z)
+ set(ZLIB_LIBRARIES z m)
elseif (CLR_CMAKE_TARGET_SUNOS OR HOST_SOLARIS)
set(ZLIB_LIBRARIES z m)
else ()
92 changes: 92 additions & 0 deletions packages/dotnet8.0/0004-ndk-r26.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
https://github.com/dotnet/runtime/commit/be5c2a28cc4a61e271d8e2c340ced5923dc7e9c1

From be5c2a28cc4a61e271d8e2c340ced5923dc7e9c1 Mon Sep 17 00:00:00 2001
From: Filip Navara <filip.navara@gmail.com>
Date: Mon, 12 Feb 2024 12:29:14 +0100
Subject: [PATCH] Fix build with Android 26 NDK (which has some nullability
annotations) (#97976)

* Fix build with Android 26 NDK (which has some nullability annotations)

* One more error in System.Security.Cryptography.Native.Android
---
.../System.Native/pal_interfaceaddresses.c | 23 +++++++++++++------
.../pal_cipher.c | 2 +-
2 files changed, 17 insertions(+), 8 deletions(-)

--- a/src/runtime/src/native/libs/System.Native/pal_interfaceaddresses.c
+++ b/src/runtime/src/native/libs/System.Native/pal_interfaceaddresses.c
@@ -117,7 +117,7 @@ static inline uint8_t mask2prefix(uint8_t* mask, int length)
static int (*getifaddrs)(struct ifaddrs**) = NULL;
static void (*freeifaddrs)(struct ifaddrs*) = NULL;

-static void try_loading_getifaddrs()
+static void try_loading_getifaddrs(void)
{
if (android_get_device_api_level() >= 24)
{
@@ -139,7 +139,7 @@ static void try_loading_getifaddrs()
}
}

-static bool ensure_getifaddrs_is_loaded()
+static bool ensure_getifaddrs_is_loaded(void)
{
static pthread_once_t getifaddrs_is_loaded = PTHREAD_ONCE_INIT;
pthread_once(&getifaddrs_is_loaded, try_loading_getifaddrs);
@@ -169,11 +169,12 @@ int32_t SystemNative_EnumerateInterfaceAddresses(void* context,

for (struct ifaddrs* current = headAddr; current != NULL; current = current->ifa_next)
{
- if (current->ifa_addr == NULL)
+ char *ifa_name = current->ifa_name;
+ if (current->ifa_addr == NULL || ifa_name == NULL)
{
continue;
}
- uint32_t interfaceIndex = if_nametoindex(current->ifa_name);
+ uint32_t interfaceIndex = if_nametoindex(ifa_name);
// ifa_name may be an aliased interface name.
// Use if_indextoname to map back to the true device name.
char actualName[IF_NAMESIZE];
@@ -376,9 +377,17 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter

while (ifaddrsEntry != NULL)
{
+ char *ifa_name = ifaddrsEntry->ifa_name;
+
+ if (ifa_name == NULL)
+ {
+ ifaddrsEntry = ifaddrsEntry->ifa_next;
+ continue;
+ }
+
//current = NULL;
nii = NULL;
- uint ifindex = if_nametoindex(ifaddrsEntry->ifa_name);
+ uint ifindex = if_nametoindex(ifa_name);
for (index = 0; index < (int)ifcount; index ++)
{
if (((NetworkInterfaceInfo*)memoryBlock)[index].InterfaceIndex == ifindex)
@@ -393,8 +402,8 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter
// We git new interface.
nii = &((NetworkInterfaceInfo*)memoryBlock)[ifcount++];

- memcpy(nii->Name, ifaddrsEntry->ifa_name, sizeof(nii->Name));
- nii->InterfaceIndex = if_nametoindex(ifaddrsEntry->ifa_name);
+ memcpy(nii->Name, ifa_name, sizeof(nii->Name));
+ nii->InterfaceIndex = ifindex;
nii->Speed = -1;
nii->HardwareType = ((ifaddrsEntry->ifa_flags & IFF_LOOPBACK) == IFF_LOOPBACK) ? NetworkInterfaceType_Loopback : NetworkInterfaceType_Unknown;

--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native.Android/pal_cipher.c
+++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native.Android/pal_cipher.c
@@ -20,7 +20,7 @@ typedef struct CipherInfo
} CipherInfo;

#define DEFINE_CIPHER(cipherId, width, javaName, flags) \
-CipherInfo* AndroidCryptoNative_ ## cipherId() \
+CipherInfo* AndroidCryptoNative_ ## cipherId(void) \
{ \
static CipherInfo info = { flags, width, javaName }; \
return &info; \
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c
+++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c
@@ -77,14 +77,6 @@ static void OpenLibraryOnce(void)
DlOpen(soName);
}

-#ifdef TARGET_ANDROID
- if (libssl == NULL)
- {
- // Android OpenSSL has no soname
- DlOpen(LIBNAME);
- }
-#endif
-
if (libssl == NULL)
{
// Prefer OpenSSL 3.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--- a/src/runtime/eng/common/cross/toolchain.cmake
+++ b/src/runtime/eng/common/cross/toolchain.cmake
@@ -36,6 +36,8 @@ if(TARGET_ARCH_NAME STREQUAL "arm")
set(TOOLCHAIN "armv7-alpine-linux-musleabihf")
elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf)
set(TOOLCHAIN "armv6-alpine-linux-musleabihf")
+ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/arm-linux-androideabi)
+ set(TOOLCHAIN "armv7-linux-androideabi")
else()
set(TOOLCHAIN "arm-linux-gnueabihf")
endif()
@@ -46,6 +48,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "arm64")
set(CMAKE_SYSTEM_PROCESSOR aarch64)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl)
set(TOOLCHAIN "aarch64-alpine-linux-musl")
+ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/aarch64-linux-android)
+ set(TOOLCHAIN "aarch64-linux-android")
elseif(LINUX)
set(TOOLCHAIN "aarch64-linux-gnu")
if(TIZEN)
@@ -78,6 +82,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "riscv64")
set(CMAKE_SYSTEM_PROCESSOR riscv64)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl)
set(TOOLCHAIN "riscv64-alpine-linux-musl")
+ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/riscv64-linux-android)
+ set(TOOLCHAIN "riscv64-linux-android")
else()
set(TOOLCHAIN "riscv64-linux-gnu")
endif()
@@ -92,6 +98,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "x64")
set(CMAKE_SYSTEM_PROCESSOR x86_64)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl)
set(TOOLCHAIN "x86_64-alpine-linux-musl")
+ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/x86_64-linux-android)
+ set(TOOLCHAIN "x86_64-linux-android")
elseif(LINUX)
set(TOOLCHAIN "x86_64-linux-gnu")
if(TIZEN)
@@ -108,6 +116,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "x86")
set(CMAKE_SYSTEM_PROCESSOR i686)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl)
set(TOOLCHAIN "i586-alpine-linux-musl")
+ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/i686-linux-android)
+ set(TOOLCHAIN "i686-linux-android")
else()
set(TOOLCHAIN "i686-linux-gnu")
endif()
@@ -244,6 +254,7 @@ else()
set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr")
set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr")
set(CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr")
+ include(${CROSS_ROOTFS}/../build/cmake/android.toolchain.cmake)
endif()

# Specify link flags
20 changes: 20 additions & 0 deletions packages/dotnet8.0/0007-aspire_fix-gitinfo-target.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
https://git.alpinelinux.org/aports/plain/community/dotnet8-runtime/aspire_fix-gitinfo-target.patch

--- a/src/aspire/Directory.Build.targets.orig
+++ b/src/aspire/Directory.Build.targets
@@ -6,13 +6,12 @@
<PackageReadmeFile Condition="'$(PackageReadmeFile)' == '' And '$(ReadMeExists)' == 'true'">README.md</PackageReadmeFile>
</PropertyGroup>

- <Import Condition="'$(SampleProject)' == 'true' or '$(CI)' != 'true' " Project="eng\Versions.dev.targets" />
- <Import Condition="'$(SampleProject)' != 'true' and '$(CI)' == 'true' " Project="eng\Versions.targets" />
+ <Import Project="eng\Versions.dev.targets" />

<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />

<ItemGroup Condition="'$(ReadMeExists)' == 'true'">
<None Include="$(ReadMePath)" Pack="true" PackagePath="\" />
</ItemGroup>
-
+
</Project>
4 changes: 4 additions & 0 deletions packages/dotnet8.0/aspnetcore-runtime-8.0.subpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 8.0 Runtime"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-runtime-8.0"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}/aspnetcore-runtime.txt")
4 changes: 4 additions & 0 deletions packages/dotnet8.0/aspnetcore-runtime-dbg-8.0.subpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="Managed debug symbols for ASP.NET Core 8.0 Runtime"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-8.0"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}/aspnetcore-runtime-dbg.txt")
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TERMUX_SUBPKG_DESCRIPTION="Targeting Pack for ASP.NET Core 8.0"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_INCLUDE="
lib/dotnet/packs/Microsoft.AspNetCore.App.Ref
"
Loading

0 comments on commit f4e2602

Please sign in to comment.