Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/dotnet-host/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ TERMUX_PKG_HOMEPAGE=https://dotnet.microsoft.com/en-us/
TERMUX_PKG_DESCRIPTION="A metapackage for .NET Host"
TERMUX_PKG_LICENSE="Public Domain"
TERMUX_PKG_MAINTAINER="@truboxl"
TERMUX_PKG_VERSION="9.0"
TERMUX_PKG_REVISION=2
TERMUX_PKG_DEPENDS="dotnet-host-9.0 | dotnet-host-8.0"
TERMUX_PKG_ANTI_BUILD_DEPENDS="dotnet-host-9.0, dotnet-host-8.0"
TERMUX_PKG_VERSION="10.0"
TERMUX_PKG_DEPENDS="dotnet-host-10.0 | dotnet-host-9.0 | dotnet-host-8.0"
TERMUX_PKG_ANTI_BUILD_DEPENDS="dotnet-host-10.0, dotnet-host-9.0, dotnet-host-8.0"
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_METAPACKAGE=true
TERMUX_PKG_SKIP_SRC_EXTRACT=true
Expand Down
18 changes: 18 additions & 0 deletions packages/dotnet10.0/0001-build-all-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/src/runtime/src/native/libs/CMakeLists.txt b/src/runtime/src/native/libs/CMakeLists.txt
index cf8b2b47f..2aee2d51d 100644
--- a/src/runtime/src/native/libs/CMakeLists.txt
+++ b/src/runtime/src/native/libs/CMakeLists.txt
@@ -156,12 +156,9 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
endif ()

add_subdirectory(System.Security.Cryptography.Native.Apple)
- 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 ()
endif ()
30 changes: 30 additions & 0 deletions packages/dotnet10.0/0002-define-memfd_create.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Always provide memfd_create syscall fallback on Linux/Android.

The iltools/cdac host build in .NET 10 compiles doublemapping.cpp with
TARGET_LINUX defined but not TARGET_ANDROID. When the host glibc defines
MFD_CLOEXEC (glibc 2.27+), the original fallback branch doesn't fire,
and memfd_create may not be available as a function if the build uses
the Bionic sysroot. This ensures the syscall wrapper is always provided.

diff --git a/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp b/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp
index 205a2cac7..973a696b3 100644
--- a/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp
+++ b/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp
@@ -16,13 +16,12 @@
#include <limits.h>
#include <errno.h>
#include <sys/resource.h>
-#if defined(TARGET_LINUX) && !defined(MFD_CLOEXEC)
+#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
+#if !defined(MFD_CLOEXEC)
#include <linux/memfd.h>
+#endif
#include <sys/syscall.h> // __NR_memfd_create
#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__)
-#elif defined(TARGET_ANDROID)
-#include <sys/syscall.h> // __NR_memfd_create
-#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__)
-#endif // TARGET_LINUX && !MFD_CLOEXEC
+#endif // TARGET_LINUX || TARGET_ANDROID
#include "minipal.h"
#include "minipal/cpufeatures.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt
index 0adecdad8..7e6a29704 100644
--- a/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt
+++ b/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt
@@ -73,7 +73,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
target_include_directories(System.IO.Compression.Native PRIVATE ${BROTLI_INCLUDE_DIRS})
target_link_libraries(System.IO.Compression.Native PRIVATE ${BROTLI_LIBRARIES})

- if (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_USE_SYSTEM_BROTLI)
+ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_USE_SYSTEM_BROTLI)
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})
@@ -153,7 +153,7 @@ else ()
target_link_libraries(System.IO.Compression.Native PUBLIC ${BROTLI_LIBRARIES})
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 ()

diff --git 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
index 03b40533e..6c9d6c1be 100644
--- 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
@@ -16,7 +16,7 @@ macro(append_extra_compression_libs NativeLibsExtra)
# 'zlib' represents our in-tree zlib, and is used in all other platforms
# that don't meet any of the previous special requirements, like most
# regular Unix and Windows builds.
- list(APPEND ZLIB_LIBRARIES $<IF:$<BOOL:${CLR_CMAKE_USE_SYSTEM_ZLIB}>,z,zlib>)
+ list(APPEND ZLIB_LIBRARIES $<IF:$<BOOL:${CLR_CMAKE_USE_SYSTEM_ZLIB}>,z,zlib> m)
endif ()
list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES})

24 changes: 24 additions & 0 deletions packages/dotnet10.0/0004-disable-lttng-fatal-error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Make lttng-ust optional instead of required.

The iltools/cdac host build in .NET 10 goes through coreclr PAL
which checks for lttng-ust-dev. This is not available in the Termux
build container nor on Android. Convert the FATAL_ERROR to a WARNING
so the build can proceed without tracing support.

diff --git a/src/runtime/src/coreclr/pal/src/configure.cmake b/src/runtime/src/coreclr/pal/src/configure.cmake
index 3d89ba2f5..dbce1ce32 100644
--- a/src/runtime/src/coreclr/pal/src/configure.cmake
+++ b/src/runtime/src/coreclr/pal/src/configure.cmake
@@ -926,9 +926,10 @@ elseif(CLR_CMAKE_TARGET_BROWSER)
else() # Anything else is Linux
# LTTNG is not available on Android, so don't error out
if(FEATURE_EVENTSOURCE_XPLAT AND NOT HAVE_LTTNG_TRACEPOINT_H)
- unset(HAVE_LTTNG_TRACEPOINT_H CACHE)
- message(FATAL_ERROR "Cannot find liblttng-ust-dev. Try installing liblttng-ust-dev (or the appropriate packages for your platform)")
+ message(WARNING "Cannot find liblttng-ust-dev, disabling FEATURE_EVENTSOURCE_XPLAT")
+ set(FEATURE_EVENTSOURCE_XPLAT 0)
endif()
+
set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
set(PAL_PTRACE "ptrace((cmd), (pid), (void*)(addr), (data))")
set(HAVE_SCHED_OTHER_ASSIGNABLE 1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c
index d99f9fd91..0caae26d3 100644
--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c
+++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c
@@ -89,14 +89,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,57 @@
diff --git a/src/runtime/eng/common/cross/toolchain.cmake b/src/runtime/eng/common/cross/toolchain.cmake
index 0ff85cf03..875df5c47 100644
--- 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)
@@ -85,6 +89,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")
if(TIZEN)
@@ -102,6 +108,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)
@@ -118,6 +126,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()
@@ -230,6 +240,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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would want for dotnet10.0 to enable CoreCLR. If this can't be done now, we can keep this patch and review the option later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this answers the question: dotnet/runtime#111491

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Description: Set TargetsLinuxBionic from TargetRid and override DefaultSubsets for source-build
When building for linux-bionic via the VMR, TargetOS is 'linux' (not
'linux-bionic'), so TargetsLinuxBionic is never set. This causes two
problems: (1) The Mono native build uses cross/toolchain.cmake which
targets linux-gnu instead of the Android NDK toolchain, causing CRT
link failures (Scrt1.o, crti.o, -lgcc_s not found). (2) The default
subset includes NativeAOT components that set RuntimeFlavor=CoreCLR,
mismatching PrimaryRuntimeFlavor=Mono and breaking tarball packaging.
Fix by deriving TargetsLinuxBionic from TargetRid and adding a
source-build override that uses mono+libs+host+packs (no NativeAOT).

diff --git a/src/runtime/eng/Subsets.props b/src/runtime/eng/Subsets.props
index 5770eec31..a1b2c3d4e 100644
--- a/src/runtime/eng/Subsets.props
+++ b/src/runtime/eng/Subsets.props
@@ -26,6 +26,10 @@
platforms (like s390x) where only Mono is supported. The primary runtime
flavor is used to decide when to build the hosts and installers. -->
<PropertyGroup>
+ <!-- When building from the VMR, TargetOS is 'linux' but TargetRid is 'linux-bionic-*'.
+ Ensure TargetsLinuxBionic is set so the correct subset defaults are used. -->
+ <TargetsLinuxBionic Condition="'$(TargetsLinuxBionic)' != 'true' and $(TargetRid.StartsWith('linux-bionic'))">true</TargetsLinuxBionic>
+
<!-- Determine if the CoreCLR runtime can build/run for the specified target. -->
<_CoreCLRSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true</_CoreCLRSupportedOS>

@@ -77,6 +81,8 @@
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' != 'true'">clr.nativeaotruntime+clr.nativeaotlibs+libs+packs</DefaultSubsets>
<!-- In source build, mono is only supported as primary runtime flavor. -->
<DefaultSubsets Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(PrimaryRuntimeFlavor)' != 'Mono'">clr+libs+tools+host+packs</DefaultSubsets>
+ <!-- For linux-bionic source-build with Mono, skip NativeAOT subsets to keep RuntimeFlavor=Mono. -->
+ <DefaultSubsets Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(TargetsLinuxBionic)' == 'true' and '$(PrimaryRuntimeFlavor)' == 'Mono'">mono+libs+tools.illink+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(DotNetBuildMonoCrossAOT)' == 'true'">mono+packs</DefaultSubsets>

<!-- In the Win-x86 BuildPass2 job in the VMR, we want to build the cross-OS DACs and pack them. -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Description: Add prebuilt baseline for Mono LLVM packages
When TargetsLinuxBionic is set, the Mono build initializes LLVM
which downloads prebuilt LLVM packages. The source-build validation
in finish-source-only.proj flags these as new prebuilts not in the
baseline. Add a prebuilt-baseline.xml to whitelist them.

diff --git a/eng/tools/prebuilt-baseline.xml b/eng/tools/prebuilt-baseline.xml
new file mode 100644
index 000000000..000000001
--- /dev/null
+++ b/eng/tools/prebuilt-baseline.xml
@@ -0,0 +1,7 @@
+<UsageData>
+ <Usages>
+ <Usage Id="runtime.placeholder-rid.Microsoft.NETCore.Runtime.Mono.LLVM.Libclang" Version="19.1.0-alpha.1.25461.1" />
+ <Usage Id="runtime.placeholder-rid.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="19.1.0-alpha.1.25461.1" />
+ <Usage Id="runtime.placeholder-rid.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="19.1.0-alpha.1.25461.1" />
+ </Usages>
+</UsageData>
Loading