unity-dotnet: BinaryFormatter from the out-of-band Formatters package

build.sh's new formatters step restores System.Runtime.Serialization.Formatters
(NuGet, 10.0.*) and puts its net8.0+ assembly in OUT/lib-extra; muck-dotnet.sh
copies lib-extra over the framework's stub in the BCL directory. Hollow Knight's
save code no longer throws PlatformNotSupportedException (hk102).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_461fe3ff06374ecba693831148697ba6
This commit is contained in:
velzieandClaude Opus 5.5 committed 2026-10-06 10:34:55 -04:00
1 parent 4605398d7a
commit 63c7f5da70
2 files changed
+21 -1

No files matched your search

+2
View File
@@ -36,6 +36,8 @@ mkdir -p "$RUN/bcl" "$RUN/home"
[ -n "${HOME_SEED:-}" ] && cp -a "$HOME_SEED/." "$RUN/home/"
cp "$FW"/*.dll "$RUN/bcl/"
cp "$OUT/lib/System.Private.CoreLib.dll" "$RUN/bcl/"
# Out-of-band assemblies over the framework's (build.sh formatters: BinaryFormatter).
[ -d "$OUT/lib-extra" ] && cp "$OUT"/lib-extra/*.dll "$RUN/bcl/"
# The framework's x86-64 natives that have no wasm64 build in the provider: P/Invokes to them go to
# the guest (the provider's dl fallback), which loads them beside the BCL with the host's OpenSSL/zlib.
cp "$FW"/libSystem.Security.Cryptography.Native.OpenSsl.so "$FW"/libSystem.IO.Compression.Native.so "$RUN/bcl/"
+19 -1
View File
@@ -14,6 +14,10 @@
# interpreter only, coop suspend -> OUT/obj
# native libSystem.Native for the same target -> OUT/objnative
# corelib System.Private.CoreLib (linux-x64 Mono flavour) -> OUT/lib
# formatters the out-of-band System.Runtime.Serialization.Formatters (NuGet, FORMATTERS_VERSION,
# default 10.0.*): BinaryFormatter, which the shared framework only stubs since .NET 9 and
# Unity games still use for saves -> OUT/lib-extra (tests/games/muck-dotnet.sh puts it in
# the BCL directory, over the framework's stub)
# provider OUT/provider/mono.wasm: the runtime, System.Native, the adapters for every
# public mono_* function it defines (host/gen-adapters.py, SysV x86-64) and the glue
# (host/gexmono-provider.c), linked as a position-independent wasm64 module
@@ -30,7 +34,7 @@ COMMIT=6812ea26ff228b8f4c132a7bad0b6a24c5653c2e
HERE=$(cd "$(dirname "$0")" && pwd)
UD=$(cd "$HERE/.." && pwd)
OUT=$(realpath -m "$1"); shift
STEPS=${*:-src sysroot runtime native corelib provider}
STEPS=${*:-src sysroot runtime native corelib formatters provider}
MUSL_SRC=${MUSL_SRC:-$(realpath -m "$UD/../../../musl-wasm64")}
RUN="nice -n 19"
JOBS=${JOBS:-12} # gooner rules: a heavy nice-19 build may use 12 jobs
@@ -77,6 +81,20 @@ step_native() {
$RUN ninja -j"$JOBS" System.Native/libSystem.Native.a > "$OUT/native-build.log"
}
step_formatters() {
local W="$OUT/formatters-restore"
rm -rf "$W"; mkdir -p "$W" "$OUT/lib-extra"
cat > "$W/f.csproj" <<P
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><TargetFramework>net10.0</TargetFramework></PropertyGroup>
<ItemGroup><PackageReference Include="System.Runtime.Serialization.Formatters" Version="${FORMATTERS_VERSION:-10.0.*}" /></ItemGroup>
</Project>
P
dotnet restore "$W/f.csproj" --packages "$W/pkgs" > "$OUT/formatters.log"
cp "$(find "$W/pkgs/system.runtime.serialization.formatters" -path '*/lib/net[0-9]*/System.Runtime.Serialization.Formatters.dll' | sort -V | tail -1)" "$OUT/lib-extra/"
echo "formatters: $(ls "$OUT/lib-extra")"
}
step_corelib() {
cd "$OUT/src"
$RUN ./build.sh -subset mono.corelib -os linux -arch x64 -c Release > "$OUT/corelib-build.log"