diff options
author | Daniel Trebbien <dtrebbien@gmail.com> | 2012-11-22 18:06:02 -0500 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2013-01-04 18:18:18 +0100 |
commit | 0b7e53359e921cf116d44bd3942269d46cf0fc27 (patch) | |
tree | 3b960b22f3e298baebe3d9e6d1640ee13a9fc0cf /m4/ax_openmp.m4 | |
parent | 2fb15701f233e21bbb95f7a55d3827b806ab5528 (diff) | |
download | autoconf-archive-0b7e53359e921cf116d44bd3942269d46cf0fc27.tar.gz |
AX_OPENMP: fix Mac OS X support
The macro was failing to detect the OpenMP flags for g++ on Mac OS 10.7 because
the AC_TRY_LINK test program was failing to link:
Undefined symbols for architecture x86_64:
"_gomp_thread_attr", referenced from:
_initialize_env in libgomp.a(env.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
As explained at [1], without resorting to a non-portable hack, the test program
needs to actually use an OMP pragma.
[1] http://stackoverflow.com/questions/8983038/linker-errors-after-enabling-openmp-on-mac
Diffstat (limited to 'm4/ax_openmp.m4')
-rw-r--r-- | m4/ax_openmp.m4 | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/m4/ax_openmp.m4 b/m4/ax_openmp.m4 index 7ea794b..8fe18c8 100644 --- a/m4/ax_openmp.m4 +++ b/m4/ax_openmp.m4 @@ -65,7 +65,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 8 +#serial 9 AC_DEFUN([AX_OPENMP], [ AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX @@ -83,8 +83,18 @@ for ax_openmp_flag in $ax_openmp_flags; do none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;; *) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;; esac - AC_TRY_LINK_FUNC(omp_set_num_threads, - [ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break]) + AC_TRY_LINK([#ifdef __cplusplus +extern "C" +#endif +void omp_set_num_threads(int);], [const int N = 100000; + int i, arr[N]; + + omp_set_num_threads(2); + + #pragma omp parallel for + for (i = 0; i < N; i++) { + arr[i] = i; + }], [ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break]) done []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS ]) |