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.
This commit is contained in:
parent
7a43094f8d
commit
08efe8cd24
@ -1591,7 +1591,8 @@ int thread_resolve_group_mask(struct thread_set *ts, int defgrp, char **err)
|
||||
*/
|
||||
void thread_detect_count(void)
|
||||
{
|
||||
int thr_min, thr_max;
|
||||
int thr_max;
|
||||
int thr_min __maybe_unused;
|
||||
int grp_min __maybe_unused;
|
||||
int grp_max __maybe_unused;
|
||||
int cpus_avail __maybe_unused;
|
||||
@ -1615,9 +1616,11 @@ void thread_detect_count(void)
|
||||
if (global.nbtgroups)
|
||||
grp_min = grp_max = global.nbtgroups;
|
||||
|
||||
#if defined(USE_THREAD)
|
||||
/* Adjust to boot settings if not forced */
|
||||
if (thr_min <= thread_cpus_enabled_at_boot && thread_cpus_enabled_at_boot < thr_max)
|
||||
thr_max = thread_cpus_enabled_at_boot;
|
||||
#endif
|
||||
|
||||
if (global.thread_limit && thr_max > global.thread_limit)
|
||||
thr_max = global.thread_limit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user