Skip to content
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

Native AOT Binaries still depend on libz.so #106566

Closed
hwoodiwiss opened this issue Aug 17, 2024 · 12 comments · Fixed by #106569 or #107666
Closed

Native AOT Binaries still depend on libz.so #106566

hwoodiwiss opened this issue Aug 17, 2024 · 12 comments · Fixed by #106569 or #107666
Labels
area-System.IO.Compression blocking-release in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@hwoodiwiss
Copy link
Contributor

hwoodiwiss commented Aug 17, 2024

Description

Based on dotnet/dotnet-docker#5792, libz.so has been removed from the runtime-deps image for .NET 9, however, when trying to run an application AOT compiled for ARM64 and containerized, an error is thrown:

/app/HwoodiwissHelper: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file

Which indicates that the build is still dependant on zlib as a shared library, rather than statically linked/included in the output executable as indicated by the discussion linked in the announcement.

Reproduction Steps

  1. Create a project with <PublishAot>true</PublishAot> and <EnableSdkContainerSupport>true</EnableSdkContainerSupport>
  2. Publish the container image with dotnet publish ./src/HwoodiwissHelper/HwoodiwissHelper.csproj --os linux --arch arm64 /t:PublishContainer
  3. Pull and attempt to run the container

Edit -
Mentioned in @jkotas comment, the containerization doesn't make a difference, I would guess it just provides a sterile enough environment for this issue to show itself.

Expected behavior

The container should start and run the native compiled binary

Actual behavior

App startup fails, with error message /app/HwoodiwissHelper: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file

Regression?

No response

Known Workarounds

Manually add <UseSystemZlib>false</UseSystemZlib> to your projects properties, to force libz.a to be statically linked.

Configuration

ARM64

.NET Version: .NET 9.0.0-preview.7.24405.7, 9.0.100-rc.1.24452.12
Container base image: mcr.microsoft.com/dotnet/nightly/runtime-deps:9.0.0-preview.7-noble-chiseled-aot (automatically pulled by SDK container publish on 2024-08-16), running on containerd on Debian GNU/Linux 12 (bookworm) (Raspberry Pi)

AMD64

.NET Version: .NET 9.0.0-preview.7.24405.7, 9.0.100-rc.1.24452.12
Tested on Docker (WSL) on Windows

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 17, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 17, 2024
@vcsjones vcsjones added area-System.IO.Compression and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 17, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@hwoodiwiss hwoodiwiss changed the title ARM64 AOT Builds still depend on libz.so ARM64 AOT Binaries still depend on libz.so Aug 17, 2024
@hwoodiwiss hwoodiwiss changed the title ARM64 AOT Binaries still depend on libz.so ARM64 Linux AOT Binaries still depend on libz.so Aug 17, 2024
@hwoodiwiss hwoodiwiss changed the title ARM64 Linux AOT Binaries still depend on libz.so AOT Binaries still depend on libz.so Aug 17, 2024
@hwoodiwiss hwoodiwiss changed the title AOT Binaries still depend on libz.so Native AOT Binaries still depend on libz.so Aug 17, 2024
@jkotas jkotas added this to the 9.0.0 milestone Aug 17, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Aug 17, 2024
@jkotas
Copy link
Member

jkotas commented Aug 17, 2024

@carlossanlop The problem is that libs.a is not included in the non-Windows native AOT packages. Could you please take a look?

It repros with simple Linux x64 publish. Arm64 and EnableSdkContainerSupport is not necessary for repro.

@jkotas
Copy link
Member

jkotas commented Aug 17, 2024

Regression introduced by #104750

@hwoodiwiss
Copy link
Contributor Author

hwoodiwiss commented Sep 10, 2024

This is unfortunately still an issue in RC1 (9.0.100-rc.1.24452.12), should this be reopened?

@jkotas jkotas reopened this Sep 10, 2024
@carlossanlop
Copy link
Member

@hwoodiwiss did you repro it again with the same instructions as in this issue's description?

@hwoodiwiss
Copy link
Contributor Author

Yeah, it's the same build workflows, just having updated the sdk and libraries for RC1

@martincostello
Copy link
Member

I'm failing to get some logs for some reason I need to investigate tomorrow, but I'm also getting startup failures in AWS Lambda for an AoT app using Amazon Linux 2023 with RC1 which might also be this issue.

@hwoodiwiss
Copy link
Contributor Author

hwoodiwiss commented Sep 10, 2024

I've generated binlogs for linux arm64 and amd64, as I wanted to look, happy to share if they would be helpful.

From what I can see UseSystemZlib is evaluted to true, even though looking in package explorer at runtime.linux-arm64.Microsoft.DotNet.ILCompiler, it looks like libz.a should be present, which should cause Microsoft.NETCore.Native.Unix.targets#L27 not to set UseSystemZlib to true.

@hwoodiwiss
Copy link
Contributor Author

hwoodiwiss commented Sep 10, 2024

Okay, just tested and confirmed a workaround for my usecase, manually setting <UseSystemZlib>false</UseSystemZlib> in my .csproj

@hwoodiwiss
Copy link
Contributor Author

I've raised #107666 based on a what I think it could be from the binlogs

martincostello added a commit to martincostello/alexa-london-travel that referenced this issue Sep 11, 2024
@martincostello
Copy link
Member

I'm failing to get some logs for some reason I need to investigate tomorrow, but I'm also getting startup failures in AWS Lambda for an AoT app using Amazon Linux 2023 with RC1 which might also be this issue.

I'm still getting startup failures with the stated workaround, so I think I'm having a different problem. Will raise a new issue if it turns out not to be an issue with my app.

@martincostello
Copy link
Member

I'm still getting startup failures with the stated workaround, so I think I'm having a different problem. Will raise a new issue if it turns out not to be an issue with my app.

I've established that whatever the issue I'm having is, it's not anything todo with zlib.

martincostello added a commit to martincostello/alexa-london-travel that referenced this issue Sep 11, 2024
martincostello added a commit to martincostello/alexa-london-travel that referenced this issue Sep 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression blocking-release in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
5 participants