Use pkg-config instead of papi_version_check

This commit is contained in:
Aleix Boné 2025-12-09 14:16:19 +01:00
parent 1e36c3b204
commit 8e30063cdd
No known key found for this signature in database
3 changed files with 141 additions and 7 deletions

View File

@ -80,7 +80,8 @@ in
(optional enableGlibcxxDebug "CXXFLAGS=-D_GLIBCXX_DEBUG") ++
# Most nanos6 api symbols are resolved at runtime, so prefer
# ifunc by default
(optional isCross "--with-symbol-resolution=ifunc");
(optional isCross "--with-symbol-resolution=ifunc") ++
(optional enablePapi "--with-papi=${papi}");
postConfigure = lib.optionalString (!enableDebug) ''
# Disable debug
@ -102,11 +103,7 @@ in
automake
libtool
pkg-config
# TODO: papi_version is needed for configure:
# ./configure: line 27378: papi_version: command not found
# This probably breaks cross-compilation
] ++ lib.optionals enablePapi [ papi ];
];
buildInputs = [
boost

View File

@ -50,7 +50,7 @@ in
configureFlags = [
"--with-ovni=${ovni}"
"CACHELINE_WIDTH=${toString cacheline}"
];
] ++ lib.optionals enablePapi [ "--with-papi=${papi}" ];
nativeBuildInputs = [
autoreconfHook
pkg-config
@ -60,6 +60,7 @@ in
hwloc
ovni
] ++ lib.optionals enablePapi [ papi ];
patches = [ ./fix-papi.patch ];
meta = {
homepage = "https://gitlab.bsc.es/nos-v/nos-v";

136
pkgs/nosv/fix-papi.patch Normal file
View File

@ -0,0 +1,136 @@
Commit ID: c09633f172ce4075e0a05a33f6dcbe8e03e1202a
Change ID: onmwypnnrysktutwsvotqovzponvwrxs
Bookmarks: fix/papi fix/papi@git fix/papi@origin
Author : Aleix Boné <aleix.boneribo@bsc.es> (2025-12-10 11:14:14)
Committer: Aleix Boné <aleix.boneribo@bsc.es> (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