Skip to content

Publishing for linux-bionix-x64 using NativeAOT fails #95223

@emmauss

Description

@emmauss

Description

Publishing a .net class library with the linux-bionic-x64 rid using NativeAOT fails with a clang error. Publishing with linux-bionic-arm64 works fine. The following is the command output with both targets;

D:\natTest>dotnet publish . -r linux-bionic-arm64 -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored D:\natTest\natTest.csproj (in 360 ms).
  natTest -> D:\natTest\bin\Release\net8.0\linux-bionic-arm64\natTest.dll
  Generating native code
  natTest -> D:\natTest\bin\Release\net8.0\linux-bionic-arm64\publish\

D:\natTest>dotnet publish . -r linux-bionic-x64 -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored D:\natTest\natTest.csproj (in 304 ms).
  natTest -> D:\natTest\bin\Release\net8.0\linux-bionic-x64\natTest.dll
  Generating native code
lld : error : unknown argument: --version-script=obj\Release\net8.0\linux-bionic-x64\native\natTest.exports [D:\natTest\natTest.csproj]
lld : error : unknown argument: -rpath [D:\natTest\natTest.csproj]
lld : error : unknown argument: --build-id=sha1 [D:\natTest\natTest.csproj]
lld : error : unknown argument: -z [D:\natTest\natTest.csproj]
lld : error : unknown argument: -z [D:\natTest\natTest.csproj]
lld : error : unknown argument: --eh-frame-hdr [D:\natTest\natTest.csproj]
lld : error : unknown argument: --discard-all [D:\natTest\natTest.csproj]
lld : error : unknown argument: -T [D:\natTest\natTest.csproj]
clang : error : linker command failed with exit code 1 (use -v to see invocation) [D:\natTest\natTest.csproj]
C:\nuget\packages\microsoft.dotnet.ilcompiler\8.0.0\build\Microsoft.NETCore.Native.targets(364,5): error MSB3073: The command ""clang" "obj\Release\net8.0\linux-bionic-x
64\native\natTest.o" -o "bin\Release\net8.0\linux-bionic-x64\native\natTest.so" -Wl,--version-script=obj\Release\net8.0\linux-bionic-x64\native\natTest.exports -gz=zlib
-fuse-ld=lld C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libbootstrapperdll.o C:\nuget\packages\mi
crosoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libRuntime.WorkstationGC.a C:\nuget\packages\microsoft.netcore.app.runtime
.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libeventpipe-disabled.a C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.
0.0/runtimes/linux-bionic-x64/\native\libstdc++compat.a C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\nativ
e\libSystem.Native.a C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libSystem.IO.Compression.Native.a
 C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libSystem.Security.Cryptography.Native.OpenSsl.a -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,--discard-all -Wl,--
gc-sections -Wl,-T,"obj\Release\net8.0\linux-bionic-x64\native\sections.ld"" exited with code 1. [D:\natTest\natTest.csproj]

A reproduction can be found here, https://github.com/emmauss/natTest .

Reproduction Steps

  1. Create a Class Library project
  2. Set the following project properties;
<NativeLib>Shared</NativeLib>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
  1. Set the top of the PATH environmental variable to the android ndk: set path=C:\Android\android-sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin;%path%
  2. Publish with linux-bionic-x64 target: dotnet publish . -r linux-bionic-x64 -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true

Expected behavior

Publishing with linux-bionic-x64 should succeed like linux-bionic-arm64 does.

Actual behavior

clang fails with this error;

lld : error : unknown argument: -rpath [D:\natTest\natTest.csproj]
lld : error : unknown argument: --build-id=sha1 [D:\natTest\natTest.csproj]
lld : error : unknown argument: -z [D:\natTest\natTest.csproj]
lld : error : unknown argument: -z [D:\natTest\natTest.csproj]
lld : error : unknown argument: --eh-frame-hdr [D:\natTest\natTest.csproj]
lld : error : unknown argument: --discard-all [D:\natTest\natTest.csproj]
lld : error : unknown argument: -T [D:\natTest\natTest.csproj]
clang : error : linker command failed with exit code 1 (use -v to see invocation) [D:\natTest\natTest.csproj]
C:\nuget\packages\microsoft.dotnet.ilcompiler\8.0.0\build\Microsoft.NETCore.Native.targets(364,5): error MSB3073: The command ""clang" "obj\Release\net8.0\linux-bionic-x
64\native\natTest.o" -o "bin\Release\net8.0\linux-bionic-x64\native\natTest.so" -Wl,--version-script=obj\Release\net8.0\linux-bionic-x64\native\natTest.exports -gz=zlib
-fuse-ld=lld C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libbootstrapperdll.o C:\nuget\packages\mi
crosoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libRuntime.WorkstationGC.a C:\nuget\packages\microsoft.netcore.app.runtime
.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libeventpipe-disabled.a C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.
0.0/runtimes/linux-bionic-x64/\native\libstdc++compat.a C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\nativ
e\libSystem.Native.a C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libSystem.IO.Compression.Native.a
 C:\nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-x64\8.0.0/runtimes/linux-bionic-x64/\native\libSystem.Security.Cryptography.Native.OpenSsl.a -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,--discard-all -Wl,--
gc-sections -Wl,-T,"obj\Release\net8.0\linux-bionic-x64\native\sections.ld"" exited with code 1. [D:\natTest\natTest.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

OS: Windows 11 x86-64
.Net Version: 8.0.0 Release

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions