Skip to content

Commit

Permalink
Update zlib to 1.3.1 (#37593)
Browse files Browse the repository at this point in the history
also update `bazel/foreign_cc/zlib.patch`

Risk Level: low
Testing: CI

Fix #31949

Signed-off-by: Alejandro R. Sedeño <[email protected]>
  • Loading branch information
asedeno authored Dec 9, 2024
1 parent a73835b commit 6445d0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 46 deletions.
53 changes: 10 additions & 43 deletions bazel/foreign_cc/zlib.patch
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b412dc7..658a109 100644
index 15ceebe..4785d61 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -147,10 +147,15 @@ if(MINGW)
@@ -149,12 +149,17 @@ if(MINGW)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)

-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
-set_target_properties(zlib PROPERTIES SOVERSION 1)
+if(NOT DEFINED BUILD_SHARED_LIBS)
+ add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+ target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+ add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+ target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+ set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
+ set_target_properties(zlib PROPERTIES SOVERSION 1)
+else()
+ add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+ add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+ set(ZLIB_INSTALL_LIBRARIES zlib)
+endif()

if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
@@ -160,22 +165,22 @@ if(NOT CYGWIN)
@@ -164,22 +169,22 @@ if(NOT CYGWIN)
#
# This has no effect with MSVC, on that platform the version info for
# the DLL comes from the resource file win32/zlib1.rc
Expand All @@ -34,9 +38,9 @@ index b412dc7..658a109 100644
# On unix-like platforms the library is almost always called libz
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
+ set_target_properties(${ZLIB_INSTALL_LIBRARIES} PROPERTIES OUTPUT_NAME z)
if(NOT APPLE)
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
- set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
+ set_target_properties(${ZLIB_INSTALL_LIBRARIES} PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
+ set_target_properties(${ZLIB_INSTALL_LIBRARIES} PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
Expand All @@ -50,40 +54,3 @@ index b412dc7..658a109 100644
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
@@ -194,20 +199,22 @@ endif()
# Example binaries
#============================================================================

-add_executable(example test/example.c)
-target_link_libraries(example zlib)
-add_test(example example)
+if(NOT SKIP_BUILD_EXAMPLES)
+ add_executable(example test/example.c)
+ target_link_libraries(example zlib)
+ add_test(example example)

-add_executable(minigzip test/minigzip.c)
-target_link_libraries(minigzip zlib)
+ add_executable(minigzip test/minigzip.c)
+ target_link_libraries(minigzip zlib)

-if(HAVE_OFF64_T)
- add_executable(example64 test/example.c)
- target_link_libraries(example64 zlib)
- set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
- add_test(example64 example64)
-
- add_executable(minigzip64 test/minigzip.c)
- target_link_libraries(minigzip64 zlib)
- set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+ if(HAVE_OFF64_T)
+ add_executable(example64 test/example.c)
+ target_link_libraries(example64 zlib)
+ set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+ add_test(example64 example64)
+
+ add_executable(minigzip64 test/minigzip.c)
+ target_link_libraries(minigzip64 zlib)
+ set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+ endif()
endif()
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,12 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "zlib",
project_desc = "zlib compression library",
project_url = "https://zlib.net",
version = "1.2.13",
sha256 = "1525952a0a567581792613a9723333d7f8cc20b87a81f920fb8bc7e3f2251428",
version = "1.3.1",
sha256 = "17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c",
strip_prefix = "zlib-{version}",
urls = ["https://github.com/madler/zlib/archive/v{version}.tar.gz"],
use_category = ["controlplane", "dataplane_core"],
release_date = "2022-10-14",
release_date = "2024-01-22",
cpe = "cpe:2.3:a:gnu:zlib:*",
license = "zlib",
license_url = "https://github.com/madler/zlib/blob/v{version}/zlib.h",
Expand Down

0 comments on commit 6445d0d

Please sign in to comment.