Skip to content

Commit

Permalink
Fix FreeBSD errors when using tasks.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grafikrobot committed Aug 29, 2023
1 parent 32d9061 commit 5688347
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .ci/azp-linux-asan-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand Down
1 change: 1 addition & 0 deletions Jamroot.jam
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ project b2
: build-dir .build
: requirements
<cxxstd>11
<threading>multi
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
<variant>debug:<define>B2_DEBUG=1
Expand Down
4 changes: 2 additions & 2 deletions src/engine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)..
Expand Down
2 changes: 1 addition & 1 deletion src/engine/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5688347

Please sign in to comment.