Commit ID: c09633f172ce4075e0a05a33f6dcbe8e03e1202a Change ID: onmwypnnrysktutwsvotqovzponvwrxs Bookmarks: fix/papi fix/papi@git fix/papi@origin Author : Aleix Boné (2025-12-10 11:14:14) Committer: Aleix Boné (2025-12-12 12:56:48) Improve PAPI m4 module for cross compilation diff --git a/m4/papi.m4 b/m4/papi.m4 index de90584870..8398f856f5 100644 --- a/m4/papi.m4 +++ b/m4/papi.m4 @@ -1,6 +1,6 @@ # This file is part of Nanos6 and is licensed under the terms contained in the COPYING file. # -# Copyright (C) 2021-2022 Barcelona Supercomputing Center (BSC) +# Copyright (C) 2021-2025 Barcelona Supercomputing Center (BSC) AC_DEFUN([AC_CHECK_PAPI], [ @@ -8,34 +8,38 @@ [papi], [AS_HELP_STRING([--with-papi=prefix], [specify the installation prefix of PAPI])], [ ac_cv_use_papi_prefix=$withval ], - [ ac_cv_use_papi_prefix="" ] + [ ac_cv_use_papi_prefix="check" ] ) if test x"${ac_cv_use_papi_prefix}" = x"no"; then AC_MSG_CHECKING([the PAPI installation prefix]) AC_MSG_RESULT([${ac_cv_use_papi_prefix}]) ac_use_papi=no - elif test x"${ac_cv_use_papi_prefix}" != x"" ; then - AC_MSG_CHECKING([the PAPI installation prefix]) - AC_MSG_RESULT([${ac_cv_use_papi_prefix}]) - papi_LIBS="-L${ac_cv_use_papi_prefix}/lib -lpapi -Wl,-rpath,${ac_cv_use_papi_prefix}/lib" - papi_CFLAGS="-I$ac_cv_use_papi_prefix/include" - ac_use_papi=yes - else + elif test x"${ac_cv_use_papi_prefix}" = x""; then + AC_MSG_RESULT([invalid prefix]) + AC_MSG_ERROR([papi prefix specified but empty]) + elif test x"${ac_cv_use_papi_prefix}" = x"yes" -o x"${ac_cv_use_papi_prefix}" = x"check"; then PKG_CHECK_MODULES( [papi], - [papi], + [papi >= 5.6.0], [ AC_MSG_CHECKING([the PAPI installation prefix]) AC_MSG_RESULT([retrieved from pkg-config]) papi_CFLAGS="${papi_CFLAGS}" ac_use_papi=yes + ac_papi_version_correct=yes ], [ AC_MSG_CHECKING([the PAPI installation prefix]) AC_MSG_RESULT([not available]) ac_use_papi=no ] ) + else + AC_MSG_CHECKING([the PAPI installation prefix]) + AC_MSG_RESULT([${ac_cv_use_papi_prefix}]) + papi_LIBS="-L${ac_cv_use_papi_prefix}/lib -lpapi -Wl,-rpath,${ac_cv_use_papi_prefix}/lib" + papi_CFLAGS="-I$ac_cv_use_papi_prefix/include" + ac_use_papi=yes fi if test x"${ac_use_papi}" = x"yes" ; then @@ -53,10 +57,10 @@ ac_use_papi=yes ], [ - if test x"${ac_cv_use_papi_prefix}" != x"" ; then - AC_MSG_ERROR([PAPI cannot be found.]) + if test x"${ac_cv_use_papi_prefix}" = x"yes" ; then + AC_MSG_ERROR([PAPI >= 5.6.0 cannot be found.]) else - AC_MSG_WARN([PAPI cannot be found.]) + AC_MSG_WARN([PAPI >= 5.6.0 not available.]) fi ac_use_papi=no ] @@ -64,30 +68,38 @@ CFLAGS="${ac_save_CFLAGS}" LIBS="${ac_save_LIBS}" + elif test x"${ac_cv_use_papi_prefix}" = x"yes" ; then + AC_MSG_ERROR([PAPI >= 5.6.0 cannot be found.]) fi - if test x"${ac_use_papi}" = x"yes" ; then - if test x"${ac_cv_use_papi_prefix}" != x"" ; then + if test x"${ac_use_papi}" = x"yes" -a x"${ac_papi_version_correct}" != x"yes" ; then + if test x"${ac_cv_use_papi_prefix}" != x"yes" -a x"${ac_cv_use_papi_prefix}" != x"check" ; then papiBinary=${ac_cv_use_papi_prefix}/bin/papi_version else papiBinary=papi_version fi - papiVersion=`$papiBinary | sed 's/[[^0-9.]]*\([[0-9.]]*\).*/\1/'` - AX_COMPARE_VERSION( - [[${papiVersion}]], - [[ge]], - [[5.6.0]], - [[ac_papi_version_correct=yes]], - [[ac_papi_version_correct=no]] - ) - if test x"${ac_papi_version_correct}" != x"yes" ; then - AC_MSG_ERROR([PAPI version must be >= 5.6.0.]) - ac_use_papi=no + if test x"$cross_compiling" = x"yes" ; then + AC_MSG_WARN([Cross-compiling detected, skipping PAPI version check]) else - AC_MSG_CHECKING([if the PAPI version >= 5.6.0.]) - AC_MSG_RESULT([${ac_papi_version_correct}]) + papiVersion=`$papiBinary | sed 's/[[^0-9.]]*\([[0-9.]]*\).*/\1/'` + + AX_COMPARE_VERSION( + [[${papiVersion}]], + [[ge]], + [[5.6.0]], + [[ac_papi_version_correct=yes]], + [[ac_papi_version_correct=no]] + ) + + if test x"${ac_papi_version_correct}" != x"yes" ; then + AC_MSG_ERROR([PAPI version must be >= 5.6.0.]) + ac_use_papi=no + else + AC_MSG_CHECKING([if the PAPI version >= 5.6.0.]) + AC_MSG_RESULT([${ac_papi_version_correct}]) + fi fi fi