From: Adenilson Cavalcanti Date: Mon, 29 Jul 2024 23:37:41 +0000 (-0700) Subject: [zstd][android] Fix build with NDK r27 X-Git-Tag: v1.5.7^2~100^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4107%2Fhead;p=thirdparty%2Fzstd.git [zstd][android] Fix build with NDK r27 The NDK cross compiler declares the target as __linux (which is not technically incorrect), which triggers the enablement of _GNU_SOURCE in the newly added code that requires the presence of qsort_r() used in the COVER dictionary code. Even though the NDK uses llvm/libc, it doesn't declare qsort_r() in the stdlib.h header. The build fix is to only activate the _GNU_SOURCE macro if the OS is *not* Android, as then we will fallback to the C90 compliant code. This patch should solve the reported issue number #4103. --- diff --git a/lib/common/zstd_deps.h b/lib/common/zstd_deps.h index f41a973c3..8a9c7cc53 100644 --- a/lib/common/zstd_deps.h +++ b/lib/common/zstd_deps.h @@ -31,7 +31,7 @@ */ #if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \ defined(__CYGWIN__) || defined(__MSYS__) -#if !defined(_GNU_SOURCE) +#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */ #define _GNU_SOURCE #endif #endif diff --git a/lib/dictBuilder/cover.c b/lib/dictBuilder/cover.c index 386a4d572..2ef33c73e 100644 --- a/lib/dictBuilder/cover.c +++ b/lib/dictBuilder/cover.c @@ -24,7 +24,7 @@ /* qsort_r is an extension. */ #if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \ defined(__CYGWIN__) || defined(__MSYS__) -#if !defined(_GNU_SOURCE) +#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */ #define _GNU_SOURCE #endif #endif