Skip to content

Commit 0bf8d1e

Browse files
Include libz.a in native aot packages (#106673)
Fixes #106566 Co-authored-by: Jan Kotas <[email protected]>
1 parent f028127 commit 0bf8d1e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The .NET Foundation licenses this file to you under the MIT license.
2424
<LinkerFlavor Condition="'$(LinkerFlavor)' == '' and '$(_linuxLibcFlavor)' == 'bionic'">lld</LinkerFlavor>
2525
<LinkerFlavor Condition="'$(LinkerFlavor)' == '' and '$(_targetOS)' == 'linux'">bfd</LinkerFlavor>
2626
<IlcDefaultStackSize Condition="'$(IlcDefaultStackSize)' == '' and '$(_linuxLibcFlavor)' == 'musl'">1572864</IlcDefaultStackSize>
27-
<UseSystemZlib Condition="'$(UseSystemZlib)' == '' and !Exists('$(IlcFrameworkNativePath)libz.a')">true</UseSystemZlib>
27+
<UseSystemZlib Condition="'$(UseSystemZlib)' == '' and !Exists('$(IlcSdkPath)libz.a')">true</UseSystemZlib>
2828
</PropertyGroup>
2929

3030
<Target Name="SetupOSSpecificProps" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
@@ -136,7 +136,6 @@ The .NET Foundation licenses this file to you under the MIT license.
136136
<NetCoreAppNativeLibrary Include="System.Native" />
137137
<NetCoreAppNativeLibrary Include="System.Globalization.Native" Condition="'$(StaticICULinking)' != 'true' and '$(InvariantGlobalization)' != 'true'" />
138138
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
139-
<NetCoreAppNativeLibrary Include="z" Condition="'$(UseSystemZlib)' != 'true'" /> <!-- zlib must be added after System.IO.Compression.Native, order matters. -->
140139
<NetCoreAppNativeLibrary Include="System.Net.Security.Native" Condition="!$(_targetOS.StartsWith('tvos')) and '$(_linuxLibcFlavor)' != 'bionic'" />
141140
<NetCoreAppNativeLibrary Include="System.Security.Cryptography.Native.Apple" Condition="'$(_IsApplePlatform)' == 'true'" />
142141
<!-- Not compliant for iOS-like platforms -->
@@ -151,6 +150,11 @@ The .NET Foundation licenses this file to you under the MIT license.
151150
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'%(EscapedPath)')" />
152151
</ItemGroup>
153152

153+
<ItemGroup>
154+
<!-- zlib must be added after System.IO.Compression.Native, order matters. -->
155+
<NativeLibrary Condition="'$(UseSystemZlib)' != 'true'" Include="$(IlcSdkPath)libz.a" />
156+
</ItemGroup>
157+
154158
<ItemGroup Condition="'$(StaticICULinking)' == 'true' and '$(NativeLib)' != 'Static' and '$(InvariantGlobalization)' != 'true'">
155159
<NativeLibrary Include="$(IntermediateOutputPath)libs/System.Globalization.Native/build/libSystem.Globalization.Native.a" />
156160
<DirectPInvoke Include="libSystem.Globalization.Native" />

src/native/libs/System.IO.Compression.Native/CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,7 @@ else ()
184184
endif ()
185185

186186
if((NOT CLR_CMAKE_USE_SYSTEM_ZLIB) AND STATIC_LIBS_ONLY)
187-
if (CLR_CMAKE_TARGET_UNIX)
188-
# zlib on Unix needs to be installed in the same location as System.IO.Compression.Native so that we can then treat is as a 'z' native library.
189-
install_static_library(zlib ${STATIC_LIB_DESTINATION} nativeaot)
190-
else()
191-
install_static_library(zlib aotsdk nativeaot)
192-
endif()
187+
install_static_library(zlib aotsdk nativeaot)
193188
endif()
194189

195190
install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs)

0 commit comments

Comments
 (0)