Skip to content

Publishing Native AOT fails on linux #37995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anpin opened this issue Jan 14, 2024 · 1 comment
Closed

Publishing Native AOT fails on linux #37995

anpin opened this issue Jan 14, 2024 · 1 comment
Labels
Area-NativeAOT Native AOT compilation untriaged Request triage from a team member

Comments

@anpin
Copy link

anpin commented Jan 14, 2024

Describe the bug

Publishing net8.0 console app with <PublishAot>true</PublishAot> fails on linux. I've tried both F# and C# on multiple flavors of linux: nixos and docker using mcr.microsoft.com/dotnet/sdk:8.0.101-alpine3.19-amd64 and mcr.microsoft.com/dotnet/sdk:8.0-jammy images.

To Reproduce

Pick your build falvour:

  • nix build github:anpin/dotnet-aot-on-nix
  • docker build https://github.com/anpin/dotnet-aot-on-nix.git
  • (clone the repo, enter its directory and then run) nix develop --command bash build.sh (this runs in the local shell and saves binlog which is already included in the repo)

Exceptions (if any)

MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored /app/CsharpAot.csproj (in 20.85 sec).
  CsharpAot -> /app/bin/Release/net8.0/linux-x64/CsharpAot.dll
  Generating native code
  /usr/bin/ld.bfd: cannot find -lz: No such file or directory
collect2 : error : ld returned 1 exit status [/app/CsharpAot.csproj]
/root/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.1/build/Microsoft.NETCore.Native.targets(364,5): error MSB3073: The command ""gcc" "obj/Release/net8.0/linux-x64/native/CsharpAot.o" -o "bin/Release/net8.0/linux-x64/native/CsharpAot" -gz=zlib -fuse-ld=bfd /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/sdk/libbootstrapper.o /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/sdk/libRuntime.WorkstationGC.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/sdk/libeventpipe-disabled.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/sdk/libstdc++compat.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/framework/libSystem.Native.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/framework/libSystem.Globalization.Native.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/framework/libSystem.IO.Compression.Native.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/framework/libSystem.Net.Security.Native.a /root/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/8.0.1/framework/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -ldl -lz -lrt -lm -pie -Wl,-pie -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/app/CsharpAot.csproj]
Error: building at STEP "RUN dotnet publish -c Release -o out": while running runtime: exit status 1

Further technical details

.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.6c33ef20

Runtime Environment:
 OS Name:     nixos
 OS Version:  24.05
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /nix/store/gm3ak3vgrx8qik40cnw28056i38hajsb-dotnet-sdk-8.0.100/sdk/8.0.100/

.NET workloads installed:
 Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

.NET SDKs installed:
  8.0.100 [/nix/store/gm3ak3vgrx8qik40cnw28056i38hajsb-dotnet-sdk-8.0.100/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.0 [/nix/store/gm3ak3vgrx8qik40cnw28056i38hajsb-dotnet-sdk-8.0.100/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.0 [/nix/store/gm3ak3vgrx8qik40cnw28056i38hajsb-dotnet-sdk-8.0.100/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
@ghost ghost added Area-NativeAOT Native AOT compilation untriaged Request triage from a team member labels Jan 14, 2024
@anpin
Copy link
Author

anpin commented Jan 14, 2024

fixed by installing zlib / zlib1g-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NativeAOT Native AOT compilation untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant