Skip to content

.NET 8 RC1: NativeAOT fails to build for linux-bionic-arm64 when specifying project as library (Linker error) #92272

@LittleCodingFox

Description

@LittleCodingFox

Description

I was trying out .NET 8 RC1 for NativeAOT for android bionic, and I get an error regarding ld.lld with a missing symbol for _init and _fini.

Reproduction Steps

Using the default steps to make a NativeAOT project for android:

dotnet new console -o HelloBionic --aot

open the csproj and edit the type to Library instead of Exe

Finally, change the Program.cs file to not use top-level statements. Something empty such as an empty namespace and/or class should suffice.

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

Expected behavior

It should create the library rather than error. It creates the executable properly when it's set as Exe.

Actual behavior

Get error:

ld.lld : error : version script assignment of 'V1.0' to symbol '_init' failed: symbol not defined [HelloBionic\HelloBionic.csproj]
ld.lld : error : version script assignment of 'V1.0' to symbol '_fini' failed: symbol not defined [HelloBionic\HelloBionic.csproj]
clang : error : linker command failed with exit code 1 (use -v to see invocation) [HelloBionic\HelloBionic.csproj]

...\.nuget\packages\microsoft.dotnet.ilcompiler\8.0.0-rc.1.23419.4\build\Microsoft.NETCore.Native.targets(364
,5): error MSB3073: The command ""clang" "obj\Release\net8.0\linux-bionic-arm64\native\HelloBionic.o" -o "bin\Release\n
et8.0\linux-bionic-arm64\native\HelloBionic.so" -Wl,--version-script=obj\Release\net8.0\linux-bionic-arm64\native\Hello
Bionic.exports -gz=zlib -fuse-ld=lld ...\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic
-arm64\8.0.0-rc.1.23419.4/runtimes/linux-bionic-arm64/\native\libbootstrapperdll.o ...\.nuget\packages\micros
oft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-rc.1.23419.4/runtimes/linux-bionic-arm64/\native\libRuntime.
WorkstationGC.a ...\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-rc.1.234
19.4/runtimes/linux-bionic-arm64/\native\libeventpipe-disabled.a ...\.nuget\packages\microsoft.netcore.app.ru
ntime.nativeaot.linux-bionic-arm64\8.0.0-rc.1.23419.4/runtimes/linux-bionic-arm64/\native\libstdc++compat.a ...\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-rc.1.23419.4/runtimes/linux-bionic-
arm64/\native\libSystem.Native.a ...\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm
64\8.0.0-rc.1.23419.4/runtimes/linux-bionic-arm64/\native\libSystem.IO.Compression.Native.a ...\.nuget\packag
es\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-rc.1.23419.4/runtimes/linux-bionic-arm64/\native\li
bSystem.Security.Cryptography.Native.OpenSsl.a --target=aarch64-linux-android21 -g -Wl,-rpath,"$ORIGIN" -Wl,--build-id=
sha1 -Wl,--as-needed -Wl,-e0x0 -pthread -ldl -lz -llog -lm -shared -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,--dis
card-all -Wl,--gc-sections -Wl,-T,"obj\Release\net8.0\linux-bionic-arm64\native\sections.ld"" exited with code 1. [...\HelloBionic\HelloBionic.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

.NET version: 8.0.100-rc.1.23455.8
OS: Windows 10 (constantly updated so I assume latest version)
Architecture: x64
I'm not sure if it's specific to this configuration

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions