Skip to content

NativeAOT library fails to load on linux-bionic-arm64 due to missing symbol #116327

@TrevTV

Description

@TrevTV

Description

Newer versions of the .NET SDK require the symbol __aarch64_cas16_acq_rel on linux-bionic-arm64 NativeAOT builds, however that doesn't exist so the libraries are unable to be loaded.

Reproduction Steps

A reproduction project is available in this repo. The library (in the NAOTLib folder) can be compiled using these commands, with the environment variable ANDROID_NDK_ROOT set to a folder path containing NDK r21e.

dotnet restore
dotnet publish -r linux-bionic-arm64 -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true

The loader side (in the LoaderApp folder) is compiled with gradlew installDebug though any other loading method should have the same result.
global.json can be changed to see the different results per version.
https://github.com/TrevTV/LinuxBionicSymbolExample

Expected behavior

The library loads without error.

Actual behavior

This error occurs.

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aarch64_cas16_acq_rel" referenced by "/data/app/~~Y6IeYBqGjhnjqVvMUKAG_g==/app.trev.naotloader-X9_xowBAe5-seTAfiyJzXQ==/lib/arm64/libnaotlib.so"...

Regression?

I was able to narrow down the failure to .NET 9.0.103 and versions after.
.NET 9.0.102 and .NET 9.0.200-preview.0.25057.12 are both versions I know work correctly.

Known Workarounds

Use .NET 9.0.102 or older when compiling.

Configuration

The library is compiled on Windows 11 24H2 (64-bit), but is cross-compiled for arm64-v8a using Android NDK r21e.
It was tested on my Pixel 9 Pro running Android 15.
I have not tested other architectures.

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions