rules_foreign_cc icon indicating copy to clipboard operation
rules_foreign_cc copied to clipboard

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

Open gr1mpatr0n opened this issue 9 months ago • 1 comments

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...

gr1mpatr0n avatar Apr 26 '25 21:04 gr1mpatr0n

Prior art: A cursory search for RANLIB=: on GitHub shows that it is a thing and has been in autoconf etc. since forever (https://github.com/search?q=RANLIB%3D%3A&type=code).

I'm therefore not sure why my tests are failing...

gr1mpatr0n avatar Apr 26 '25 22:04 gr1mpatr0n