contrib/cityhash: namespace config.h as city_config.h for vendored builds#515
Conversation
dbca1d0 to
f03227f
Compare
|
Hi @iliaal, Thank you for your contribution! Could you please explain the steps that led you to the problem you're trying to solve? |
|
You're right that config.h is checked in next to city.cc and resolves fine in this repo's own CMake build. The breakage hits consumers that vendor the CityHash sources, like my PHP ClickHouse extension (iliaal/php_clickhouse), which vendors clickhouse-cpp and builds it through PHP's own build system ( config.h is a generated autoconf artifact ("Generated from config.h.in by configure"). Build systems that vendor the sources but prune generated headers (mine does, which is common) don't carry it, and MSVC then fails: city.cc reads only two macros from it. It takes the little-endian path either way, since the shipped config.h leaves The only build the bare guard would affect is GCC/Clang, which gets |
|
@iliaal, I see the issue now. Unfortunately, it is a bit more complicated because, in addition to CMake, we also have Bazel. What do you think about renaming CityHash's |
…ilds city.cc did an unguarded `#include "config.h"`. The generic name collides with (or is shadowed by) a consumer's own autoconf config.h when these sources are vendored, and breaks outright (MSVC C1083: cannot open include file 'config.h') when the consumer prunes the generated header. Rename the checked-in header to city_config.h and CITY_-prefix every macro it defines, updating the two usages in city.cc (CITY_WORDS_BIGENDIAN, CITY_HAVE_BUILTIN_EXPECT) and the Bazel srcs entry. The header is static (the `#if WIN32 || WIN64` HAVE_BUILTIN_EXPECT block is a hand edit, not autoconf output), so there is no configure step to keep in sync. Inert `#undef` placeholders for standard types (size_t, uint*_t, ...) stay unprefixed: they would define standard symbols on deficient platforms, not CityHash macros. The pre/post object file for city.cc is byte-identical, so no runtime or wire-hash change.
07d83d0 to
db6bdc5
Compare
|
Reworked to the rename. Details:
|
city.cc does an unguarded
#include "config.h". The generic name collides with (or is shadowed by) a consumer's own autoconfconfig.hwhen the tree is vendored, and breaks outright on builds without an autoconf step that prune the generated header:Rename the checked-in header to
city_config.handCITY_-prefix every macro it defines, updating the two usages in city.cc (CITY_WORDS_BIGENDIAN,CITY_HAVE_BUILTIN_EXPECT) and the Bazelsrcsentry. The header is static (the#if WIN32 || WIN64HAVE_BUILTIN_EXPECTblock is a hand edit, not autoconf output), so there is noconfigurestep to keep in sync.Inert
#undefplaceholders for standard types (size_t,uint*_t, ...) stay unprefixed: they would define standard symbols on deficient platforms, not CityHash macros. The pre/post object file for city.cc is byte-identical, so no runtime or wire-hash change.