Skip to content

Commit

Permalink
Use zlib from the Bazel registry
Browse files Browse the repository at this point in the history
The main issue is that iostreams uses a quoted include for zlib, while
the Bazel Registry version requires system includes. Fix it by patching
the zlib header to be a system include.
  • Loading branch information
rockwood-openai authored and Vertexwahn committed Jun 10, 2024
1 parent 64bf481 commit 42859ed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 69 deletions.
3 changes: 1 addition & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ bazel_dep(name = "boringssl", version = "0.0.0-20240530-2db0eb3")
bazel_dep(name = "bzip2", version = "1.0.8")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "xz", version = "5.4.5.bcr.2")
# bazel_dep(name = "zlib", version = "1.3.1")
bazel_dep(name = "zlib", version = "1.3.1.bcr.1")
bazel_dep(name = "zstd", version = "1.5.6")

non_module_boost_repositories = use_extension("@com_github_nelhage_rules_boost//:boost/repositories.bzl", "non_module_dependencies")
use_repo(
non_module_boost_repositories,
"boost",
"zlib",
)
10 changes: 2 additions & 8 deletions boost/boost.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,9 @@ def boost_deps():
build_file = "@com_github_nelhage_rules_boost//:boost.BUILD",
patch_cmds = ["rm -f doc/pdf/BUILD"],
patch_cmds_win = ["Remove-Item -Force doc/pdf/BUILD"],
patches = ["@com_github_nelhage_rules_boost//:zlib.patch"],
patch_args = ["-p1"],
url = "https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz",
sha256 = "4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95",
strip_prefix = "boost-1.84.0",
)

http_archive(
name = "zlib",
build_file = "@com_github_nelhage_rules_boost//:zlib.BUILD",
url = "https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz",
sha256 = "ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e",
strip_prefix = "zlib-1.3",
)
59 changes: 0 additions & 59 deletions zlib.BUILD

This file was deleted.

15 changes: 15 additions & 0 deletions zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Use a system includes instead of a local includes for zlib, as the
Bazel Central Registry version of zlib enforces that only system
includes are used.

--- a/libs/iostreams/src/zlib.cpp
+++ b/libs/iostreams/src/zlib.cpp
@@ -17,7 +17,7 @@
#include <boost/throw_exception.hpp>
#include <boost/iostreams/detail/config/dyn_link.hpp>
#include <boost/iostreams/filter/zlib.hpp>
-#include "zlib.h" // Jean-loup Gailly's and Mark Adler's "zlib.h" header.
+#include <zlib.h> // Jean-loup Gailly's and Mark Adler's "zlib.h" header.
// To configure Boost to work with zlib, see the
// installation instructions here:
// https://boost.org/libs/iostreams/doc/index.html?path=7

0 comments on commit 42859ed

Please sign in to comment.