diff --git a/Config.uk b/Config.uk index e0fb0d4e2aaa30860f6219c4bfb443ae084769e9..25258715a6c15e5c0ac06780b3a9fa289c608fc3 100644 --- a/Config.uk +++ b/Config.uk @@ -1,7 +1,7 @@ menuconfig LIBFARMHASH bool "farmhash - Google's family of hash functions" select LIBCXX - select LIBNEWLIBC + select LIBMUSL select LIBPOSIX_SYSINFO select LIBCXXABI select LIBUNWIND diff --git a/Makefile.uk b/Makefile.uk index 8f54ae884a5004134e2b3903dcd3735b6ffd2404..8b02c6ccb028e6262652f1a178b17824b30152ad 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -37,9 +37,14 @@ $(eval $(call addlib_s,libfarmhash,$(CONFIG_LIBFARMHASH))) ################################################################################ # Sources ################################################################################ -LIBFARMHASH_VERSION=816a4ae622e964763ca0862d9dbd19324a1eaf45 +LIBFARMHASH_VERSION=0d859a811870d10f53a594927d0d0b97573ad06d +LIBFARMHASH_PATCHDIR=$(LIBFARMHASH_BASE)/patches LIBFARMHASH_URL=https://github.com/google/farmhash/archive/$(LIBFARMHASH_VERSION).tar.gz + +ifeq ($(CONFIG_LIBFARMHASH), y) $(eval $(call fetch,libfarmhash,$(LIBFARMHASH_URL))) +$(eval $(call patch,libfarmhash,$(LIBFARMHASH_PATCHDIR),farmhash-$(LIBFARMHASH_VERSION))) +endif ################################################################################ # Helpers @@ -58,15 +63,25 @@ CXXINCLUDES-$(CONFIG_LIBFARMHASH) += $(LIBFARMHASH_INCLUDES) ################################################################################ # Library sources ################################################################################ -UK_ALIBS-y += $(LIBFARMHASH_SRC)/src/farmhash.o +UK_ALIBS-$(CONFIG_LIBFARMHASH) += $(LIBFARMHASH_SRC)/src/farmhash.o ################################################################################ # Lib-specific Targets ################################################################################ # Use the native build system to generate farmhash.o, then link it in above -$(LIBFARMHASH_BUILD)/.prepared: $(LIBFARMHASH_BUILD)/.origin +ifeq ($(CONFIG_LIBFARMHASH), y) +ifeq ($(CONFIG_ARCH_X86_64),y) + HOST_ARCH := x86_64-linux-gnu +else ifeq ($(CONFIG_ARCH_ARM_64),y) + HOST_ARCH := aarch64-linux-gnu +else + $(error Unsupported architecture) +endif + +$(LIBFARMHASH_BUILD)/.prepared: $(LIBFARMHASH_BUILD)/.origin $(LIBFARMHASH_BUILD)/.patched $(call verbose_cmd,CONFIG,libsoldeploy: $(notdir $@), \ - cd $(LIBFARMHASH_SRC) && ./configure && make all && \ + cd $(LIBFARMHASH_SRC) && ./configure --host=$(HOST_ARCH) && make all && \ touch $@) UK_PREPARE-$(CONFIG_LIBFARMHASH) += $(LIBFARMHASH_BUILD)/.prepared +endif diff --git a/patches/0001-Remove-std-namespace.patch b/patches/0001-Remove-std-namespace.patch new file mode 100644 index 0000000000000000000000000000000000000000..817f8a3a1bd148f0aa97550bcf8071335fb44923 --- /dev/null +++ b/patches/0001-Remove-std-namespace.patch @@ -0,0 +1,89 @@ +diff --git a/src/farmhash.cc b/src/farmhash.cc +index f2b99ff..e5b1ba8 100644 +--- a/src/farmhash.cc ++++ b/src/farmhash.cc +@@ -411,7 +411,6 @@ template <> uint128_t DebugTweak(uint128_t x) { + + } // namespace NAMESPACE_FOR_HASH_FUNCTIONS + +-using namespace std; + using namespace NAMESPACE_FOR_HASH_FUNCTIONS; + namespace farmhashna { + #undef Fetch +@@ -480,7 +479,7 @@ STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) { + + // Return a 16-byte hash for 48 bytes. Quick and dirty. + // Callers do best to use "random-looking" values for a and b. +-STATIC_INLINE pair WeakHashLen32WithSeeds( ++STATIC_INLINE std::pair WeakHashLen32WithSeeds( + uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) { + a += w; + b = Rotate(b + a + z, 21); +@@ -488,11 +487,11 @@ STATIC_INLINE pair WeakHashLen32WithSeeds( + a += x; + a += y; + b += Rotate(a, 44); +- return make_pair(a + z, b + c); ++ return std::make_pair(a + z, b + c); + } + + // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. +-STATIC_INLINE pair WeakHashLen32WithSeeds( ++STATIC_INLINE std::pair WeakHashLen32WithSeeds( + const char* s, uint64_t a, uint64_t b) { + return WeakHashLen32WithSeeds(Fetch(s), + Fetch(s + 8), +@@ -536,8 +535,8 @@ uint64_t Hash64(const char *s, size_t len) { + uint64_t x = seed; + uint64_t y = seed * k1 + 113; + uint64_t z = ShiftMix(y * k2 + 113) * k2; +- pair v = make_pair(0, 0); +- pair w = make_pair(0, 0); ++ std::pair v = std::make_pair(0, 0); ++ std::pair w = std::make_pair(0, 0); + x = x * k2 + Fetch(s); + + // Set end so that after the loop we have 1 to 64 bytes left to process. +@@ -609,8 +608,8 @@ uint64_t Hash64WithSeeds(const char *s, size_t len, + uint64_t x = seed0; + uint64_t y = seed1 * k2 + 113; + uint64_t z = farmhashna::ShiftMix(y * k2) * k2; +- pair v = make_pair(seed0, seed1); +- pair w = make_pair(0, 0); ++ std::pair v = std::make_pair(seed0, seed1); ++ std::pair w = std::make_pair(0, 0); + uint64_t u = x - z; + x *= k2; + uint64_t mul = k2 + (u & 0x82); +@@ -1743,7 +1742,7 @@ STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) { + + // Return a 16-byte hash for 48 bytes. Quick and dirty. + // Callers do best to use "random-looking" values for a and b. +-STATIC_INLINE pair WeakHashLen32WithSeeds( ++STATIC_INLINE std::pair WeakHashLen32WithSeeds( + uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) { + a += w; + b = Rotate(b + a + z, 21); +@@ -1751,11 +1750,11 @@ STATIC_INLINE pair WeakHashLen32WithSeeds( + a += x; + a += y; + b += Rotate(a, 44); +- return make_pair(a + z, b + c); ++ return std::make_pair(a + z, b + c); + } + + // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. +-STATIC_INLINE pair WeakHashLen32WithSeeds( ++STATIC_INLINE std::pair WeakHashLen32WithSeeds( + const char* s, uint64_t a, uint64_t b) { + return WeakHashLen32WithSeeds(Fetch(s), + Fetch(s + 8), +@@ -1806,7 +1805,7 @@ uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) { + + // We expect len >= 128 to be the common case. Keep 56 bytes of state: + // v, w, x, y, and z. +- pair v, w; ++ std::pair v, w; + uint64_t x = Uint128Low64(seed); + uint64_t y = Uint128High64(seed); + uint64_t z = len * k1;