From 5688347c0bdab784929c8b3a399e63008073d019 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 29 Aug 2023 09:02:25 -0500 Subject: [PATCH] Fix FreeBSD errors when using tasks. FreeBSD gcc, instead of failing at link time when using multithreading and forgetting add the -pthread option it throws an exception at runtime. This change default to using the -pthread option for bootstrap on all platforms. It also turns on threading=multi on the jam build. --- .ci/azp-linux-asan-test.yml | 2 +- Jamroot.jam | 1 + src/engine/build.sh | 4 ++-- src/engine/tasks.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.ci/azp-linux-asan-test.yml b/.ci/azp-linux-asan-test.yml index 352a209e3e..0702ad085c 100644 --- a/.ci/azp-linux-asan-test.yml +++ b/.ci/azp-linux-asan-test.yml @@ -15,7 +15,7 @@ steps: displayName: Build - bash: | set -e - export B2=`ls -1 ${PWD}/.build/*/debug/address-sanitizer-on/cxxstd-11-iso/b2` + export B2=`ls -1 ${PWD}/.build/*/debug/address-sanitizer-on/cxxstd-11-iso/threading-multi/b2` cd test ./test_all.py ${TOOLSET} cd .. diff --git a/Jamroot.jam b/Jamroot.jam index 1a160fe096..f96fcd4a21 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -27,6 +27,7 @@ project b2 : build-dir .build : requirements 11 + multi msvc:_CRT_SECURE_NO_WARNINGS=1 msvc:_CRT_NONSTDC_NO_DEPRECATE=1 debug:B2_DEBUG=1 diff --git a/src/engine/build.sh b/src/engine/build.sh index bbb632f3df..02fcb08951 100755 --- a/src/engine/build.sh +++ b/src/engine/build.sh @@ -156,11 +156,11 @@ check_toolset () # Prefer Clang (clang) on macOS.. if test_toolset clang && test_uname Darwin && test_compiler clang++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=clang$TOOLSET_SUFFIX ; return ${TRUE} ; fi + # GCC (gcc) with -pthread arg (for AIX and others).. + if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 -pthread ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi # GCC (gcc).. if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 -D_GNU_SOURCE ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi - # GCC (gcc) with -pthread arg (for AIX and others).. - if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 -pthread ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi # Clang (clang).. if test_toolset clang && test_compiler clang++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=clang$TOOLSET_SUFFIX ; return ${TRUE} ; fi # Clang (clang) with -pthread arg (for FreeBSD and others).. diff --git a/src/engine/tasks.cpp b/src/engine/tasks.cpp index 10e114592f..f9b4db61f5 100644 --- a/src/engine/tasks.cpp +++ b/src/engine/tasks.cpp @@ -319,7 +319,7 @@ unsigned get_parallelism(int parallelism) #if B2_USE_STD_THREADS return parallelism >= 0 ? parallelism - : std::min(unsigned(globs.jobs), system_info().cpu_thread_count()) - 1; + : std::min(unsigned(globs.jobs), system_info().cpu_thread_count()); #else return 0; #endif