Skip to content

Commit 5b86dca

Browse files
authored
Revert "Migrate to zlib-ng, part 2: consume it in runtime (#102403)" (#104414)
This reverts commit f5c9a5e.
1 parent 2a72651 commit 5b86dca

33 files changed

+183
-267
lines changed

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@
324324
<NoTargetFrameworkFiltering>true</NoTargetFrameworkFiltering>
325325

326326
<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;ClrDebugSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs;CxxStandardLibrary;CxxStandardLibraryStatic;CxxAbiLibrary</NativeBuildPartitionPropertiesToRemove>
327-
<UseSystemZlib Condition="'$(TargetsAppleMobile)' == 'true' or '$(TargetOS)' == 'android' or '$(TargetArchitecture)' == 'armv6'">true</UseSystemZlib>
328327
</PropertyGroup>
329328

330329
<!-- RepositoryEngineeringDir isn't set when Installer tests import this file. -->

eng/native/configurecompiler.cmake

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
1212
set(CMAKE_CXX_STANDARD 11)
1313
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1414

15-
# We need to set this to Release as there's no way to intercept configuration-specific linker flags
16-
# for try_compile-style tests (like check_c_source_compiles) and some of the default Debug flags
17-
# (ie. /INCREMENTAL) conflict with our own flags.
18-
set(CMAKE_TRY_COMPILE_CONFIGURATION Release)
19-
2015
include(CheckCCompilerFlag)
2116
include(CheckCXXCompilerFlag)
2217
include(CheckLinkerFlag)
@@ -63,7 +58,6 @@ if (MSVC)
6358
define_property(TARGET PROPERTY CLR_CONTROL_FLOW_GUARD INHERITED BRIEF_DOCS "Controls the /guard:cf flag presence" FULL_DOCS "Set this property to ON or OFF to indicate if the /guard:cf compiler and linker flag should be present")
6459
define_property(TARGET PROPERTY CLR_EH_CONTINUATION INHERITED BRIEF_DOCS "Controls the /guard:ehcont flag presence" FULL_DOCS "Set this property to ON or OFF to indicate if the /guard:ehcont compiler flag should be present")
6560
define_property(TARGET PROPERTY CLR_EH_OPTION INHERITED BRIEF_DOCS "Defines the value of the /EH option" FULL_DOCS "Set this property to one of the valid /EHxx options (/EHa, /EHsc, /EHa-, ...)")
66-
define_property(TARGET PROPERTY MSVC_WARNING_LEVEL INHERITED BRIEF_DOCS "Define the warning level for the /Wn option" FULL_DOCS "Set this property to one of the valid /Wn options (/W0, /W1, /W2, /W3, /W4)")
6761

6862
set_property(GLOBAL PROPERTY CLR_CONTROL_FLOW_GUARD ON)
6963

@@ -785,8 +779,7 @@ if (MSVC)
785779

786780
# [[! Microsoft.Security.SystemsADM.10086 !]] - SDL required warnings
787781
# set default warning level to 4 but allow targets to override it.
788-
set_property(GLOBAL PROPERTY MSVC_WARNING_LEVEL 4)
789-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>>)
782+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W$<GENEX_EVAL:$<IF:$<BOOL:$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>>,$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>,4>>>)
790783
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
791784
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oi>) # enable intrinsics
792785
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oy->) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls

eng/native/configureplatform.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,3 @@ if(LOWERCASE_CMAKE_BUILD_TYPE STREQUAL debug)
500500
string(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
501501
string(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
502502
endif()
503-
504-
if (CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_HOST_ARCH_ARMV6)
505-
# Our zlib-ng copy should only be used in non-mobile platforms only.
506-
# In mobile platforms we should use the zlib package provided by the system.
507-
set(CLR_CMAKE_USE_SYSTEM_ZLIB 1)
508-
endif()

eng/native/functions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function(preprocess_file inputFilename outputFilename)
221221
get_compile_definitions(PREPROCESS_DEFINITIONS)
222222
get_include_directories(PREPROCESS_INCLUDE_DIRECTORIES)
223223
get_source_file_property(SOURCE_FILE_DEFINITIONS ${inputFilename} COMPILE_DEFINITIONS)
224-
224+
225225
foreach(DEFINITION IN LISTS SOURCE_FILE_DEFINITIONS)
226226
list(APPEND PREPROCESS_DEFINITIONS -D${DEFINITION})
227227
endforeach()
@@ -508,7 +508,7 @@ function(install_static_library targetName destination component)
508508
if (WIN32)
509509
set_target_properties(${targetName} PROPERTIES
510510
COMPILE_PDB_NAME "${targetName}"
511-
COMPILE_PDB_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:${targetName}>"
511+
COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}"
512512
)
513513
install (FILES "$<TARGET_FILE_DIR:${targetName}>/${targetName}.pdb" DESTINATION ${destination} COMPONENT ${component})
514514
endif()

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ 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="!Exists('$(IlcSdkPath)libz.a')">true</UseSystemZlib>
2827
</PropertyGroup>
2928

3029
<Target Name="SetupOSSpecificProps" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
@@ -130,7 +129,6 @@ The .NET Foundation licenses this file to you under the MIT license.
130129
<NativeLibrary Condition="'$(_targetArchitecture)' == 'x64'" Include="$(IlcSdkPath)$(VxSortSupportName)$(LibFileExt)" />
131130
<NativeLibrary Include="$(IlcSdkPath)$(StandaloneGCSupportName)$(LibFileExt)" />
132131
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
133-
<NativeLibrary Condition="'$(UseSystemZlib)' != 'true'" Include="$(IlcSdkPath)libz.a" />
134132
</ItemGroup>
135133

136134
<ItemGroup>
@@ -190,7 +188,7 @@ The .NET Foundation licenses this file to you under the MIT license.
190188
<NativeSystemLibrary Include="objc" Condition="'$(_IsApplePlatform)' == 'true'" />
191189
<NativeSystemLibrary Include="swiftCore" Condition="'$(_targetOS)' == 'osx'" />
192190
<NativeSystemLibrary Include="swiftFoundation" Condition="'$(_targetOS)' == 'osx'" />
193-
<NativeSystemLibrary Include="z" Condition="'$(UseSystemZlib)' == 'true'" />
191+
<NativeSystemLibrary Include="z" />
194192
<NativeSystemLibrary Include="rt" Condition="'$(_IsApplePlatform)' != 'true' and '$(_linuxLibcFlavor)' != 'bionic'" />
195193
<NativeSystemLibrary Include="log" Condition="'$(_linuxLibcFlavor)' == 'bionic'" />
196194
<NativeSystemLibrary Include="icucore" Condition="'$(_IsApplePlatform)' == 'true'" />

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ The .NET Foundation licenses this file to you under the MIT license.
4646
<NativeLibrary Condition="'$(_targetArchitecture)' == 'x64'" Include="$(IlcSdkPath)$(VxSortSupportName)$(LibrarySuffix)" />
4747
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
4848
<NativeLibrary Include="$(IlcSdkPath)$(StandaloneGCSupportName)$(LibrarySuffix)" />
49-
<NativeLibrary Include="$(IlcSdkPath)zlibstatic$(LibFileExt)" />
5049
</ItemGroup>
5150

5251
<ItemGroup>

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@
277277
<PlatformManifestFileEntry Include="libicudata.a" IsNative="true" />
278278
<PlatformManifestFileEntry Include="libicui18n.a" IsNative="true" />
279279
<PlatformManifestFileEntry Include="libicuuc.a" IsNative="true" />
280-
<!-- zlib-specific files -->
281-
<PlatformManifestFileEntry Include="libz.a" IsNative="true" />
282280
</ItemGroup>
283281

284282
<ItemGroup>

src/mono/CMakeLists.txt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "emscripten")
249249
set(DISABLE_SHARED_LIBS 1)
250250
# sys/random.h exists, but its not found
251251
set(HAVE_SYS_RANDOM_H 1)
252+
set(INTERNAL_ZLIB 1)
252253
elseif(CLR_CMAKE_HOST_OS STREQUAL "wasi")
253254
set(HOST_WASI 1)
254255
add_definitions(-D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI)
@@ -260,6 +261,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "wasi")
260261
add_compile_options(-Wno-unused-but-set-variable)
261262
set(ENABLE_PERFTRACING 0)
262263
set(DISABLE_SHARED_LIBS 1)
264+
set(INTERNAL_ZLIB 1)
263265
set(DISABLE_EXECUTABLES 1)
264266
set(STATIC_COMPONENTS 1)
265267
elseif(CLR_CMAKE_HOST_OS STREQUAL "windows")
@@ -268,6 +270,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "windows")
268270
set(HOST_NO_SYMLINKS 1)
269271
set(MONO_KEYWORD_THREAD "__declspec (thread)")
270272
set(MONO_ZERO_LEN_ARRAY 1)
273+
set(INTERNAL_ZLIB 1)
271274
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # statically link VC runtime library
272275
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W4>) # set warning level 4
273276
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
@@ -508,15 +511,16 @@ if ((HOST_MACCAT AND HOST_ARM64) OR (TARGET_MACCAT AND TARGET_ARM64))
508511
set(TARGET_APPLE_MOBILE 1)
509512
endif()
510513

511-
# Decide if we need zlib-ng.
514+
# Decide if we need zlib, and if so whether we want the system zlib or the in-tree copy.
512515
if(NOT DISABLE_EMBEDDED_PDB OR NOT DISABLE_LOG_PROFILER_GZ)
513-
if (CLR_CMAKE_USE_SYSTEM_ZLIB)
514-
# if we're not on a platform where we use the in-tree zlib-ng, require system zlib
516+
if(INTERNAL_ZLIB)
517+
# defines ZLIB_SOURCES
518+
include(${CLR_SRC_NATIVE_DIR}/external/zlib.cmake)
519+
else()
520+
# if we're not on a platform where we use the in-tree zlib, require system zlib
515521
include(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native/extra_libs.cmake)
516522
set(Z_LIBS)
517523
append_extra_compression_libs(Z_LIBS)
518-
else()
519-
include(${CLR_SRC_NATIVE_DIR}/external/zlib-ng.cmake)
520524
endif()
521525
endif()
522526

@@ -660,17 +664,12 @@ if(LLVM_PREFIX)
660664
endif()
661665
set(llvm_includedir "${LLVM_PREFIX}/include")
662666

663-
set(llvm_system_libs "")
664667
if(HOST_LINUX)
665668
# llvm-config --system-libs
666-
list(APPEND llvm_system_libs ${MONO_cxx_lib} "-lrt" "-ldl" "-lpthread" "-lm")
669+
set(llvm_system_libs ${MONO_cxx_lib} "-lz" "-lrt" "-ldl" "-lpthread" "-lm")
667670
elseif(HOST_OSX)
668671
# llvm-config --system-libs
669-
list(APPEND llvm_system_libs "-lm")
670-
endif()
671-
672-
if (CLR_CMAKE_USE_SYSTEM_ZLIB AND (HOST_LINUX OR HOST_OSX))
673-
list(APPEND llvm_system_libs "-lz")
672+
set(llvm_system_libs "-lz" "-lm")
674673
endif()
675674

676675
# llvm-config --libs analysis core bitwriter mcjit orcjit

src/mono/browser/browser.proj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
<WasmPInvokeModule Include="libSystem.Native" />
6464
<WasmPInvokeModule Include="libSystem.IO.Compression.Native" />
6565
<WasmPInvokeModule Include="libSystem.Globalization.Native" />
66-
<WasmPInvokeModule Include="libz" />
6766
<WasmPInvokeAssembly Include="@(LibrariesRuntimeFiles)" Condition="'%(Extension)' == '.dll' and '%(IsNative)' != 'true'" />
6867
</ItemGroup>
6968

src/mono/browser/runtime/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ target_link_libraries(dotnet.native
2828
${MONO_ARTIFACTS_DIR}/libmono-wasm-${CONFIGURATION_INTERPSIMDTABLES_LIB}.a
2929
${MONO_ARTIFACTS_DIR}/libmono-profiler-aot.a
3030
${MONO_ARTIFACTS_DIR}/libmono-profiler-browser.a
31-
${MONO_ARTIFACTS_DIR}/libz.a
3231
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
3332
${NATIVE_BIN_DIR}/libSystem.Native.a
3433
${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a

src/mono/cmake/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@
168168
/* Define to 1 if you have the <unwind.h> header file. */
169169
#cmakedefine HAVE_UNWIND_H 1
170170

171+
/* Use in-tree zlib */
172+
#cmakedefine INTERNAL_ZLIB 1
173+
171174
/* Define to 1 if you have the <poll.h> header file. */
172175
#cmakedefine HAVE_POLL_H 1
173176

src/mono/mono.proj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,6 @@ JS_ENGINES = [NODE_JS]
11891189
<_MonoRuntimeArtifacts Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-wasm-nosimd.a">
11901190
<Destination>$(RuntimeBinDir)libmono-wasm-nosimd.a</Destination>
11911191
</_MonoRuntimeArtifacts>
1192-
<_MonoRuntimeArtifacts Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)_deps\fetchzlibng-build\libz.a">
1193-
<Destination>$(RuntimeBinDir)libz.a</Destination>
1194-
</_MonoRuntimeArtifacts>
11951192
<_MonoICorDebugArtifacts Condition="'$(MonoMsCorDbi)' == 'true'" Include="$(MonoObjDir)out\lib\$(LibPrefix)mscordbi$(LibSuffix)">
11961193
<Destination>$(RuntimeBinDir)$(LibPrefix)mscordbi$(LibSuffix)</Destination>
11971194
</_MonoICorDebugArtifacts>

src/mono/mono/eventpipe/test/CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,7 @@ if(ENABLE_PERFTRACING)
3939
set(CMAKE_SKIP_RPATH 1)
4040
add_executable(ep-test ${EVENTPIPE_TEST_SOURCES} ${EVENTPIPE_TEST_HEADERS})
4141
target_sources(ep-test PRIVATE "${mono-components-objects}")
42-
43-
set(EPTEST_LINKABLE_LIBS "")
44-
list(APPEND EPTEST_LINKABLE_LIBS eglib_api monosgen-static ${OS_LIBS} ${LLVM_LIBS} monoapi)
45-
if (CLR_CMAKE_USE_SYSTEM_ZLIB)
46-
list(APPEND EPTEST_LINKABLE_LIBS ${EPTEST_LINKABLE_LIBS} ${Z_LIBS})
47-
else()
48-
list(APPEND EPTEST_LINKABLE_LIBS ${EPTEST_LINKABLE_LIBS} zlib)
49-
endif()
50-
target_link_libraries(ep-test PRIVATE ${EPTEST_LINKABLE_LIBS})
51-
42+
target_link_libraries(ep-test PRIVATE eglib_api monosgen-static ${OS_LIBS} ${LLVM_LIBS} ${Z_LIBS} monoapi)
5243
install_with_stripped_symbols(ep-test TARGETS bin)
5344
else(ENABLE_EVENTPIPE_TEST AND STATIC_COMPONENTS AND (NOT DISABLE_COMPONENTS) AND (NOT DISABLE_LIBS) AND (NOT DISABLE_EXECUTABLES))
5445
message(VERBOSE "Skip building native EventPipe library test runner.")

src/mono/mono/metadata/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,7 @@ set(metadata_sources "${metadata_platform_sources};${metadata_common_sources};${
200200
if(HOST_WIN32 AND NOT DISABLE_SHARED_LIBS)
201201
add_library(metadata_objects_shared OBJECT ${metadata_sources})
202202
target_compile_definitions(metadata_objects_shared PRIVATE ${metadata_compile_definitions})
203-
204-
set(METADATAOBJECTSSHARED_LINKABLE_LIBS "")
205-
list(APPEND METADATAOBJECTSSHARED_LINKABLE_LIBS monoapi eglib_api utils_objects_shared)
206-
if (NOT CLR_CMAKE_USE_SYSTEM_ZLIB)
207-
list(APPEND METADATAOBJECTSSHARED_LINKABLE_LIBS zlib)
208-
endif()
209-
target_link_libraries(metadata_objects_shared PRIVATE ${METADATAOBJECTSSHARED_LINKABLE_LIBS})
210-
203+
target_link_libraries(metadata_objects_shared PRIVATE monoapi eglib_api utils_objects_shared)
211204
# note: metadata_objects is an object library, so this doesn't force linking with sgen,
212205
# it just adds the relevant include directories - which we need even with Boehm
213206
target_link_libraries(metadata_objects_shared PRIVATE sgen_objects_shared)
@@ -219,14 +212,7 @@ endif()
219212

220213
add_library(metadata_objects OBJECT ${metadata_sources})
221214
target_compile_definitions(metadata_objects PRIVATE ${metadata_compile_definitions})
222-
223-
set(METADATAOBJECTS_LINKABLE_LIBS "")
224-
list(APPEND METADATAOBJECTS_LINKABLE_LIBS monoapi eglib_api utils_objects)
225-
if (NOT CLR_CMAKE_USE_SYSTEM_ZLIB)
226-
list(APPEND METADATAOBJECTS_LINKABLE_LIBS zlib)
227-
endif()
228-
target_link_libraries(metadata_objects PRIVATE ${METADATAOBJECTS_LINKABLE_LIBS})
229-
215+
target_link_libraries(metadata_objects PRIVATE monoapi eglib_api utils_objects)
230216
# note: metadata_objects is an object library, so this doesn't force linking with sgen,
231217
# it just adds the relevant include directories - which we need even with Boehm
232218
target_link_libraries(metadata_objects PRIVATE sgen_objects)

src/mono/mono/metadata/debug-mono-ppdb.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@
3030
#include <mono/utils/mono-logger-internals.h>
3131

3232
#ifndef DISABLE_EMBEDDED_PDB
33+
#ifdef INTERNAL_ZLIB
34+
#include <external/zlib/zlib.h>
35+
#else
3336
#include <zlib.h>
34-
#endif // DISABLE_EMBEDDED_PDB
37+
#endif
38+
#endif
3539

3640
#include "debug-mono-ppdb.h"
3741

0 commit comments

Comments
 (0)