bazel-contrib / bazel-contrib/rules_foreign_cc
Zlib build failure on Mac
- Dominant language
- Starlark
- Stars
- 737
- Forks
- 270
- PR merge metrics
- No merged PRs in 30d
Description
With this dependencies on Mac
```
bazel_dep(name = "rules_foreign_cc", version = "0.15.0")
bazel_dep(name = "rules_cc", version = "0.1.2")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "googletest", version = "1.17.0")
bazel_dep(name = "abseil-cpp", version = "20250512.1", repo_name = "absl")
bazel_dep(name = "gflags", version = "2.2.2")
bazel_dep(name = "glog", version = "0.7.1")
bazel_dep(name = "protobuf", version = "31.1")
```
during building of `cmake` it fails on Mac
```
ZLIB_INTERNAL zcalloc(opaque, items, size)
| ^
/private/var/tmp/_bazel_s15o/efc294df099e260992df2e34ea48483c/sandbox/darwin-sandbox/1/execroot/_main/external/+_repo_rules+opencv/3rdparty/zlib/zutil.c:317:20: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
317 | void ZLIB_INTERNAL zcfree(opaque, ptr)
| ^
4 warnings and 3 errors generated.
make[2]: *** [3rdparty/zlib/CMakeFiles/zlib.dir/build.make:275: 3rdparty/zlib/CMakeFiles/zlib.dir/zutil.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1704: 3rdparty/zlib/CMakeFiles/zlib.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
_____ END BUILD LOGS _____
rules_foreign_cc: Build wrapper script location: bazel-out/darwin_arm64-fastbuild/bin/opencv_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build script location: bazel-out/darwin_arm64-fastbuild/bin/opencv_foreign_cc/build_script.sh
rules_foreign_cc: Build log location: bazel-out/darwin_arm64-fastbuild/bin/opencv_foreign_cc/CMake.log
rules_foreign_cc: Keeping these below directories for debug, but note that the directories inside a sandbox
rules_foreign_cc: are still cleaned unless you specify the '--sandbox_debug' Bazel command line flag.
rules_foreign_cc: Build Dir: /private/var/tmp/_bazel_s15o/efc294df099e260992df2e34ea48483c/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/opencv.build_tmpdir
rules_foreign_cc: Deps Dir: /private/var/tmp/_bazel_s15o/efc294df099e260992df2e34ea48483c/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/opencv.ext_build_deps
INFO: Elapsed time: 60.618s, Critical Path: 58.53s
INFO: 2 processes: 1904 action cache hit, 2 internal.
ERROR: Build did NOT complete successfully
```
I brew install Zlib on Mac, but I think it downloads the old version, I guess.
Contributor guide
Research direction
Reproduce the Mac build with the listed Bazel dependencies and inspect the generated CMake.log and build_script.sh. Start with external OpenCV's 3rdparty/zlib/zutil.c and the reported C23 diagnostics; done means the OpenCV build completes successfully on Mac.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cmake, macos, opencv
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100