bazel-contrib / bazel-contrib/rules_foreign_cc

CMAKE_RANLIB should be `:` in certain scenarios, instead of `""`

Open
#1,394 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

https://github.com/bazel-contrib/rules_foreign_cc/blob/0bcec88406255e56dbb595b6c477de6e9c78c3a3/foreign_cc/private/cmake_script.bzl#L148

In specific scenarios, `CMAKE_RANLIB` will be injected into command lines which are attempting to use the empty string as a command, breaking (e.g. `"" libjansson.a`). I'm not entirely sure when this is a problem, but I've seen it primarily when cross-compiling for Windows using `clang-cl`. This appears to be corroborated by the OpenCV project, which uses `CMAKE_RANLIB=:` for those builds.

I'd like to understand why this happens though...

Contributor guide

Open the contributing guide

Research direction

Start with foreign_cc/private/cmake_script.bzl around line 148 and trace how CMAKE_RANLIB is set during cross-compilation, especially with clang-cl on Windows. Reproduce the scenario that emits an empty command, then verify that the generated command uses `:` instead of `""` and no longer breaks archive operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.