-
Notifications
You must be signed in to change notification settings - Fork 1
Zlib fix for updated MacOS #755
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
Conversation
WalkthroughPlatform-specific build rules and compiler flags are added to the Bazel configuration for macOS and Linux. The zlib library is introduced as an external dependency, with a custom build file and a macOS-specific compatibility fix implemented via a wrapper function. New Bazel targets and settings support these changes. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Bazel
participant zlib (external)
participant macos_zlib_fix
Developer->>Bazel: Build project
Bazel->>zlib (external): Fetch and build zlib (with zlib.BUILD)
alt If on macOS
Bazel->>macos_zlib_fix: Build macOS wrapper
Bazel->>zlib (external): Apply macOS-specific defines and wrapper
end
Bazel-->>Developer: Build artifacts with platform-specific settings
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.bazelrc (1)
31-31
: Linux host flags?
Consider adding--host_copt=-Wno-deprecated-function
underbuild:linux
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.bazelrc
(1 hunks)WORKSPACE
(1 hunks)third_party/BUILD.bazel
(1 hunks)third_party/macos_zlib_fix.cc
(1 hunks)third_party/zlib.BUILD
(1 hunks)
🔇 Additional comments (10)
.bazelrc (2)
20-23
: Verify flag validity.
Ensure--enable_platform_specific_config
exists in your Bazel version.
25-29
: macOS warnings suppressed.
Flags look correct for macOS builds.third_party/BUILD.bazel (3)
1-6
: Visibility set correctly.
7-10
: macOS config present.
12-16
: Linkage check.
Confirmmacos_zlib_fix
is actually used by downstream targets.WORKSPACE (1)
5-14
: Verify zlib SHA.
Double-check the checksum matches upstream v1.2.11.third_party/zlib.BUILD (4)
1-2
: Public visibility OK.
4-7
: macOS config OK.
15-24
: Defines correct.
25-31
: copts correct.
#ifdef __APPLE__ | ||
/* This provides a redefinition-safe fdopen on macOS as zlib is incompatible without it */ | ||
#include <stdio.h> | ||
|
||
FILE* my_fdopen_wrapper(int fd, const char* mode) { | ||
return fdopen(fd, mode); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing C linkage.
Wrapper must be declared extern "C"
to avoid name mangling.
third_party/zlib.BUILD
Outdated
cc_library( | ||
name = "zlib", | ||
srcs = glob(["*.c"], exclude = ["example.c", "minigzip.c"]), | ||
hdrs = glob(["*.h"]), | ||
includes = ["."], | ||
defines = select({ | ||
":macos": [ | ||
"HAVE_UNISTD_H", | ||
"NO_FSEEKO", | ||
"HAVE_STDARG_H", | ||
"_DARWIN_C_SOURCE", | ||
"fdopen=my_fdopen_wrapper", # Redefine fdopen to avoid conflicts | ||
], | ||
"//conditions:default": [], | ||
}), | ||
copts = select({ | ||
":macos": [ | ||
"-Wno-macro-redefined", | ||
"-Wno-deprecated-non-prototype", | ||
], | ||
"//conditions:default": [], | ||
}), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing wrapper in deps.
Add
deps = select({":macos":["//third_party:macos_zlib_fix"],"//conditions:default":[]})
to link my_fdopen_wrapper
.
Summary
This patches the fdopen issue for bazel build on MacOS.
Checklist
Summary by CodeRabbit