]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: thread: protect thread_cpus_enabled_at_boot with USE_THREAD
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Sat, 12 Apr 2025 09:16:08 +0000 (11:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Apr 2025 14:03:21 +0000 (16:03 +0200)
commit08efe8cd24eb3061508078d4641c2d582ecc84c8
treee28a3528f5e6febfcb0477e5ac29d3c7101b5d23
parent7a43094f8d8fe3c435ecc003f07453dd9de8134a
BUG/MINOR: thread: protect thread_cpus_enabled_at_boot with USE_THREAD

Following error is triggered at linker invokation, when we try to compile with
USE_THREAD=0 and -O0.

  make -j 8 TARGET=linux-glibc USE_LUA=1 USE_PCRE2=1 USE_LINUX_CAP=1 \
   USE_MEMORY_PROFILING=1 OPT_CFLAGS=-O0  USE_THREAD=0

  /usr/bin/ld: src/thread.o: warning: relocation against `thread_cpus_enabled_at_boot' in read-only section `.text'
  /usr/bin/ld: src/thread.o: in function `thread_detect_count':
  /home/vk/projects/haproxy/src/thread.c:1619: undefined reference to `thread_cpus_enabled_at_boot'
  /usr/bin/ld: /home/vk/projects/haproxy/src/thread.c:1619: undefined reference to `thread_cpus_enabled_at_boot'
  /usr/bin/ld: /home/vk/projects/haproxy/src/thread.c:1620: undefined reference to `thread_cpus_enabled_at_boot'
  /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:1044: haproxy] Error 1

thread_cpus_enabled_at_boot is only available when we compiled with
USE_THREAD=1, which is the default for the most targets now.

In some cases, we need to recompile in mono-thread mode, thus
thread_cpus_enabled_at_boot should be protected with USE_THREAD in
thread_detect_count().

thread_detect_count() is always called during the process initialization
never mind of multi thread support. It sets some defaults in global.nbthread
and global.nbtgroups.

This patch is related to GitHub issue #2916.
No need to be backported as it was added in 3.2-dev9 version.
src/thread.c