BUILD: pools: only detect link-time jemalloc on ELF platforms

The build broke on Windows and MacOS after commit ed232148a ("MEDIUM:
pool: refactor malloc_trim/glibc and jemalloc api addition detections."),
because the extern+attribute(weak) combination doesn't result in a really
weak symbol and it causes an undefined symbol at link time.

Let's reserve this detection to ELF platforms. The runtime detection using
dladdr() remains used if defined.

No backport needed, this is purely 2.6.
This commit is contained in:
Willy Tarreau 2021-11-26 15:55:55 +01:00
parent efd954793e
commit 781f07a620
1 changed files with 2 additions and 0 deletions

View File

@ -77,9 +77,11 @@ static void trim_all_pools(void)
*/ */
static void detect_allocator(void) static void detect_allocator(void)
{ {
#if defined(__ELF__)
extern int mallctl(const char *, void *, size_t *, void *, size_t) __attribute__((weak)); extern int mallctl(const char *, void *, size_t *, void *, size_t) __attribute__((weak));
my_mallctl = mallctl; my_mallctl = mallctl;
#endif
if (!my_mallctl) { if (!my_mallctl) {
my_mallctl = get_sym_curr_addr("mallctl"); my_mallctl = get_sym_curr_addr("mallctl");