Skip to content

Commit d44156a

Browse files
committed
update boost.m4 macro to only check for boost libraries in the path
provided. Needed to avoid pulling in old multi-threaded variants on TACC's frontera system that are incompatible with intel compiler. Based on PR from tsuna/boost.m4#82
1 parent e973f0c commit d44156a

File tree

1 file changed

+61
-82
lines changed

1 file changed

+61
-82
lines changed

m4/boost.m4

Lines changed: 61 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2323

2424
m4_define([_BOOST_SERIAL], [m4_translit([
25-
# serial 34
25+
# serial 30
2626
], [#
2727
], [])])
2828

@@ -47,6 +47,16 @@ m4_define([_BOOST_SERIAL], [m4_translit([
4747

4848
m4_pattern_forbid([^_?(BOOST|Boost)_])
4949

50+
# _BOOST_SHELL_FUNCTIONS
51+
# --------------------------------------------------------
52+
#
53+
# Useful shell functions. Call
54+
# AC_REQUIRE([_BOOST_SHELL_FUNCTIONS])
55+
# before using
56+
AC_DEFUN([_BOOST_SHELL_FUNCTIONS],
57+
[_boost_join_path() { _boost_join_path_save_IFS=$IFS; IFS=@ ; echo "$[]*" ; IFS=$_boost_join_path_save_IFS ; } ]
58+
)
59+
5060

5161
# _BOOST_SED_CPP(SED-PROGRAM, PROGRAM,
5262
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
@@ -329,6 +339,7 @@ AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
329339
AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
330340
AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
331341
AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
342+
AS_VAR_PUSHDEF([Boost_lib_abs_path], [boost_cv_lib_$1_abs_path])dnl
332343
AS_IF([test x"$8" = "xno"], [not_found_header='true'])
333344
BOOST_FIND_HEADER([$4], [$not_found_header])
334345
boost_save_CPPFLAGS=$CPPFLAGS
@@ -390,7 +401,8 @@ AC_DEFUN([BOOST_FIND_LIB],
390401
# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their
391402
# configure to fail
392403
AC_DEFUN([_BOOST_FIND_LIBS],
393-
[Boost_lib=no
404+
[AC_REQUIRE([_BOOST_SHELL_FUNCTIONS])
405+
Boost_lib=no
394406
case "$3" in #(
395407
(mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
396408
(mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #(
@@ -442,6 +454,7 @@ dnl start the for loops).
442454
])
443455
ac_objext=$boost_save_ac_objext
444456
boost_failed_libs=
457+
eval eval _boost_shrext=$shrext_cmds
445458
# Don't bother to ident the following nested for loops, only the 2
446459
# innermost ones matter.
447460
for boost_lib_ in $2; do
@@ -462,14 +475,26 @@ for boost_rtopt_ in $boost_rtopt '' -d; do
462475
case $boost_failed_libs in #(
463476
(*@$boost_lib@*) continue;;
464477
esac
465-
# If with_boost is empty, we'll search in /lib first, which is not quite
466-
# right so instead we'll try to a location based on where the headers are.
467-
boost_tmp_lib=$with_boost
468-
test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
469-
for boost_ldpath in "$boost_tmp_lib/lib" '' \
470-
/opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
471-
"$with_boost" C:/Boost/lib /lib*
478+
# If with_boost is specified; search *only* within that hierarchy,
479+
# otherwise search the "standard" places, starting with a location
480+
# based upon where the headers are.
481+
AS_IF( [ test x"$with_boost" = x ],
482+
[
483+
AS_IF( [ test x"$boost_cv_inc_path" = xno || test x"$boost_cv_inc_path" = xyes ],
484+
[boost_tmp_lib=],
485+
[boost_tmp_lib=${boost_cv_inc_path%/include} ]
486+
)
487+
boost_ldpaths=`_boost_join_path $boost_tmp_lib '' \
488+
/opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
489+
C:/Boost/lib /lib*` ],
490+
[ boost_ldpaths=`_boost_join_path "$with_boost" "$with_boost/lib"` ]
491+
)
492+
493+
save_IFS=$IFS
494+
IFS=@
495+
for boost_ldpath in `echo "$boost_ldpaths"`
472496
do
497+
IFS=$save_IFS
473498
# Don't waste time with directories that don't exist.
474499
if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then
475500
continue
@@ -478,14 +503,19 @@ for boost_rtopt_ in $boost_rtopt '' -d; do
478503
# Are we looking for a static library?
479504
case $boost_ldpath:$boost_rtopt_ in #(
480505
(*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
481-
Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
482-
test -e "$Boost_lib_LIBS" || continue;; #(
483-
(*) # No: use -lboost_foo to find the shared library.
506+
Boost_lib_abs_path="$boost_ldpath/lib$boost_lib.$libext"
507+
Boost_lib_LIBS="$Boost_lib_abs_path" ;;
508+
(*) # No:
509+
Boost_lib_abs_path="$boost_ldpath/lib$boost_lib$_boost_shrext"
484510
Boost_lib_LIBS="-l$boost_lib";;
485511
esac
512+
# Don't waste time with libraries that don't exist
513+
if test x"$boost_ldpath" != x && test ! -e "$Boost_lib_abs_path"; then
514+
continue
515+
fi
486516
boost_save_LIBS=$LIBS
487517
LIBS="$Boost_lib_LIBS $LIBS"
488-
test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
518+
test x"$boost_ldpath" != x && LDFLAGS=" -L$boost_ldpath $LDFLAGS"
489519
dnl First argument of AC_LINK_IFELSE left empty because the test file is
490520
dnl generated only once above (before we start the for loops).
491521
_BOOST_AC_LINK_IFELSE([],
@@ -505,8 +535,8 @@ dnl generated only once above (before we start the for loops).
505535
boost_rpath_link_ldflag_found=yes;;
506536
*)
507537
for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do
508-
LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
509-
LIBS="$Boost_lib_LIBS $boost_save_LIBS"
538+
LDFLAGS="-L$boost_ldpath $boost_save_LDFLAGS $boost_cv_rpath_link_ldflag$boost_ldpath"
539+
LIBS="$boost_save_LIBS $Boost_lib_LIBS"
510540
_BOOST_AC_LINK_IFELSE([],
511541
[boost_rpath_link_ldflag_found=yes
512542
break],
@@ -664,10 +694,6 @@ LDFLAGS=$boost_filesystem_save_LDFLAGS
664694
# * The signatures of make_fcontext() and jump_fcontext were changed in 1.56.0
665695
# * A dependency on boost_thread appears in 1.57.0
666696
# * The implementation details were moved to boost::context::detail in 1.61.0
667-
# * 1.61 also introduces execution_context_v2, which is the "lowest common
668-
# denominator" for boost::context presence since then.
669-
# * boost::context::fiber was introduced in 1.69 and execution_context_v2 was
670-
# removed in 1.72
671697
BOOST_DEFUN([Context],
672698
[boost_context_save_LIBS=$LIBS
673699
boost_context_save_LDFLAGS=$LDFLAGS
@@ -678,55 +704,27 @@ if test $boost_major_version -ge 157; then
678704
LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS"
679705
fi
680706
681-
if test $boost_major_version -ge 169; then
682-
707+
if test $boost_major_version -ge 161; then
683708
BOOST_FIND_LIB([context], [$1],
684-
[boost/context/fiber.hpp], [[
709+
[boost/context/continuation.hpp], [[
685710
namespace ctx=boost::context;
686711
int a;
687-
ctx::fiber source{[&a](ctx::fiber&& sink){
688-
a=0;
689-
int b=1;
690-
for(;;){
691-
sink=std::move(sink).resume();
692-
int next=a+b;
693-
a=b;
694-
b=next;
695-
}
696-
return std::move(sink);
697-
}};
698-
for (int j=0;j<10;++j) {
699-
source=std::move(source).resume();
700-
}
701-
return a == 34;
702-
]], [], [], [$2])
703-
704-
elif test $boost_major_version -ge 161; then
705-
706-
BOOST_FIND_LIB([context], [$1],
707-
[boost/context/execution_context_v2.hpp], [[
708-
namespace ctx=boost::context;
709-
int res=0;
710-
int n=35;
711-
ctx::execution_context<int> source(
712-
[n, &res](ctx::execution_context<int> sink, int) mutable {
713-
int a=0;
712+
ctx::continuation source=ctx::callcc(
713+
[&a](ctx::continuation && sink){
714+
a=0;
714715
int b=1;
715-
while(n-->0){
716-
auto result=sink(a);
717-
sink=std::move(std::get<0>(result));
718-
auto next=a+b;
716+
for(;;){
717+
sink=sink.resume();
718+
int next=a+b;
719719
a=b;
720720
b=next;
721721
}
722-
return sink;
722+
return std::move(sink);
723723
});
724-
for(int i=0;i<10;++i){
725-
auto result=source(i);
726-
source=std::move(std::get<0>(result));
727-
res = std::get<1>(result);
724+
for (int j=0;j<10;++j) {
725+
source=source.resume();
728726
}
729-
return res == 34;
727+
return a == 34;
730728
]], [], [], [$2])
731729
732730
else
@@ -1549,11 +1547,10 @@ AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
15491547
-pthreads -mthreads -lpthread --thread-safe -mt";;
15501548
esac
15511549
# Generate the test file.
1552-
AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>
1553-
void *f(void*){ return 0; }],
1554-
[pthread_t th; pthread_create(&th,0,f,0); pthread_join(th,0);
1555-
pthread_attr_t attr; pthread_attr_init(&attr); pthread_cleanup_push(0, 0);
1556-
pthread_cleanup_pop(0);])])
1550+
AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
1551+
[pthread_t th; pthread_join(th, 0);
1552+
pthread_attr_init(0); pthread_cleanup_push(0, 0);
1553+
pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
15571554
for boost_pthread_flag in '' $boost_pthread_flags; do
15581555
boost_pthread_ok=false
15591556
dnl Re-use the test file already generated.
@@ -1615,10 +1612,6 @@ if test x$boost_cv_inc_path != xno; then
16151612
# I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
16161613
# the same defines as GCC's).
16171614
for i in \
1618-
"defined __clang__ && __clang_major__ == 12 && __clang_minor__ == 0 @ clang120" \
1619-
"defined __clang__ && __clang_major__ == 11 && __clang_minor__ == 0 @ clang110" \
1620-
"defined __clang__ && __clang_major__ == 10 && __clang_minor__ == 0 @ clang100" \
1621-
"defined __clang__ && __clang_major__ == 9 && __clang_minor__ == 0 @ clang90" \
16221615
"defined __clang__ && __clang_major__ == 8 && __clang_minor__ == 0 @ clang80" \
16231616
"defined __clang__ && __clang_major__ == 7 && __clang_minor__ == 0 @ clang70" \
16241617
"defined __clang__ && __clang_major__ == 6 && __clang_minor__ == 0 @ clang60" \
@@ -1627,20 +1620,10 @@ if test x$boost_cv_inc_path != xno; then
16271620
"defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 9 @ clang39" \
16281621
"defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 8 @ clang38" \
16291622
"defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 7 @ clang37" \
1630-
_BOOST_mingw_test(10, 2) \
1631-
_BOOST_gcc_test(10, 2) \
1632-
_BOOST_mingw_test(10, 1) \
1633-
_BOOST_gcc_test(10, 1) \
1634-
_BOOST_mingw_test(9, 3) \
1635-
_BOOST_gcc_test(9, 3) \
1636-
_BOOST_mingw_test(9, 2) \
1637-
_BOOST_gcc_test(9, 2) \
16381623
_BOOST_mingw_test(9, 1) \
16391624
_BOOST_gcc_test(9, 1) \
16401625
_BOOST_mingw_test(9, 0) \
16411626
_BOOST_gcc_test(9, 0) \
1642-
_BOOST_mingw_test(8, 4) \
1643-
_BOOST_gcc_test(8, 4) \
16441627
_BOOST_mingw_test(8, 3) \
16451628
_BOOST_gcc_test(8, 3) \
16461629
_BOOST_mingw_test(8, 2) \
@@ -1649,8 +1632,6 @@ if test x$boost_cv_inc_path != xno; then
16491632
_BOOST_gcc_test(8, 1) \
16501633
_BOOST_mingw_test(8, 0) \
16511634
_BOOST_gcc_test(8, 0) \
1652-
_BOOST_mingw_test(7, 4) \
1653-
_BOOST_gcc_test(7, 4) \
16541635
_BOOST_mingw_test(7, 3) \
16551636
_BOOST_gcc_test(7, 3) \
16561637
_BOOST_mingw_test(7, 2) \
@@ -1659,8 +1640,6 @@ if test x$boost_cv_inc_path != xno; then
16591640
_BOOST_gcc_test(7, 1) \
16601641
_BOOST_mingw_test(7, 0) \
16611642
_BOOST_gcc_test(7, 0) \
1662-
_BOOST_mingw_test(6, 5) \
1663-
_BOOST_gcc_test(6, 5) \
16641643
_BOOST_mingw_test(6, 4) \
16651644
_BOOST_gcc_test(6, 4) \
16661645
_BOOST_mingw_test(6, 3) \

0 commit comments

Comments
 (0)