Skip to content

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

Closed

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

Activity

  1. ghost added
    untriaged
    on Nov 25, 2023
  2. added this to the 9.0.0 milestone on Nov 27, 2023
  3. ghost removed
    untriaged
    on Nov 27, 2023
  4. ghost added
    in-pr
    on Nov 28, 2023
  5. am11 commented on Nov 28, 2023

    @am11
    Member

    I think <LinkerArg Include="--target=x86_64-linux-android21" /> in your csproj file will fix workaround this issue.

    Possible fix for upstream #95312

  6. MichalStrehovsky commented on Nov 28, 2023

    @MichalStrehovsky
    Member

    I think <LinkerArg Include="--target=x86_64-linux-android21" /> in your csproj file will fix workaround this issue.

    It will only get you one step further to hit #93942.

  7. added a commit that references this issue on Nov 29, 2023
  8. MichalStrehovsky commented on Nov 30, 2023

    @MichalStrehovsky
    Member

    This is fixed (and the other bug too) in the latest .NET 9 builds. I'm trying to get this backported to 8.0. If #95382 merges, this should be available in the February .NET 8 servicing release.

  9. ghost removed
    in-pr
    on Dec 1, 2023
  10. locked and limited conversation to collaborators on Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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