[Git][ghc/ghc][wip/rts-configure-libdw-libnuma] Move lib{numa,dw} defines to RTS configure
John Ericson (@Ericson2314)
gitlab at gitlab.haskell.org
Fri Sep 22 05:52:15 UTC 2023
John Ericson pushed to branch wip/rts-configure-libdw-libnuma at Glasgow Haskell Compiler / GHC
Commits:
435de9de by John Ericson at 2023-09-22T01:52:05-04:00
Move lib{numa,dw} defines to RTS configure
Clean up the m4 to handle the auto case always and be more consistent.
Also simplify the CPP --- we should always have both headers if we are
using libnuma.
"side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to
better separate searching from actions taken based on search results.
This might seem overkill now, but will make shuffling logic between
configure scripts easier later.
The macro comments are converted from `dnl` to `#` following the
recomendation in
https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html
- - - - -
5 changed files:
- configure.ac
- m4/fp_find_libdw.m4
- m4/fp_find_libnuma.m4
- rts/configure.ac
- rts/posix/OSMem.c
Changes:
=====================================
configure.ac
=====================================
@@ -1131,7 +1131,14 @@ FP_FIND_LIBZSTD
dnl ** Other RTS features
dnl --------------------------------------------------------------
FP_FIND_LIBDW
+AC_SUBST(UseLibdw)
+AC_SUBST(LibdwLibDir)
+AC_SUBST(LibdwIncludeDir)
+
FP_FIND_LIBNUMA
+AC_SUBST(UseLibNuma)
+AC_SUBST(LibNumaLibDir)
+AC_SUBST(LibNumaIncludeDir)
dnl ** Documentation
dnl --------------------------------------------------------------
=====================================
m4/fp_find_libdw.m4
=====================================
@@ -1,6 +1,11 @@
-dnl ** Have libdw?
-dnl --------------------------------------------------------------
-dnl Sets UseLibdw.
+# FP_FIND_LIBDW
+# --------------------------------------------------------------
+# Should we used libdw? (yes, no, or auto.)
+#
+# Sets variables:
+# - UseLibdw: [YES|NO]
+# - LibdwLibDir: optional path
+# - LibdwIncludeDir: optional path
AC_DEFUN([FP_FIND_LIBDW],
[
AC_ARG_WITH([libdw-libraries],
@@ -12,8 +17,6 @@ AC_DEFUN([FP_FIND_LIBDW],
LIBDW_LDFLAGS="-L$withval"
])
- AC_SUBST(LibdwLibDir)
-
AC_ARG_WITH([libdw-includes],
[AS_HELP_STRING([--with-libdw-includes=ARG],
[Find includes for libdw in ARG [default=system default]])
@@ -23,32 +26,28 @@ AC_DEFUN([FP_FIND_LIBDW],
LIBDW_CFLAGS="-I$withval"
])
- AC_SUBST(LibdwIncludeDir)
+ AC_ARG_ENABLE(dwarf-unwind,
+ [AS_HELP_STRING([--enable-dwarf-unwind],
+ [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])],
+ [],
+ [enable_dwarf_unwind=no])
UseLibdw=NO
- USE_LIBDW=0
- AC_ARG_ENABLE(dwarf-unwind,
- [AS_HELP_STRING([--enable-dwarf-unwind],
- [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])])
- if test "$enable_dwarf_unwind" = "yes" ; then
+ if test "$enable_dwarf_unwind" != "no" ; then
CFLAGS2="$CFLAGS"
CFLAGS="$LIBDW_CFLAGS $CFLAGS"
LDFLAGS2="$LDFLAGS"
LDFLAGS="$LIBDW_LDFLAGS $LDFLAGS"
- AC_CHECK_LIB(dw, dwfl_attach_state,
- [AC_CHECK_HEADERS([elfutils/libdw.h], [break], [])
- UseLibdw=YES],
- [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])
+ AC_CHECK_HEADER([elfutils/libdwfl.h],
+ [AC_CHECK_LIB(dw, dwfl_attach_state,
+ [UseLibdw=YES])])
+
+ if test "x:$enable_dwarf_unwind:$UseLibdw" = "x:yes:NO" ; then
+ AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])
+ fi
CFLAGS="$CFLAGS2"
LDFLAGS="$LDFLAGS2"
fi
-
- AC_SUBST(UseLibdw)
- if test $UseLibdw = "YES" ; then
- USE_LIBDW=1
- fi
- AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw])
])
-
=====================================
m4/fp_find_libnuma.m4
=====================================
@@ -1,7 +1,13 @@
+# FP_FIND_LIBNUMA
+# --------------------------------------------------------------
+# Should we used libnuma? (yes, no, or auto.)
+#
+# Sets variables:
+# - UseLibNuma: [YES|NO]
+# - LibNumaLibDir: optional path
+# - LibNumaIncludeDir: optional path
AC_DEFUN([FP_FIND_LIBNUMA],
[
- dnl ** Have libnuma?
- dnl --------------------------------------------------------------
AC_ARG_WITH([libnuma-libraries],
[AS_HELP_STRING([--with-libnuma-libraries=ARG],
[Find libraries for libnuma in ARG [default=system default]])
@@ -11,8 +17,6 @@ AC_DEFUN([FP_FIND_LIBNUMA],
LIBNUMA_LDFLAGS="-L$withval"
])
- AC_SUBST(LibNumaLibDir)
-
AC_ARG_WITH([libnuma-includes],
[AS_HELP_STRING([--with-libnuma-includes=ARG],
[Find includes for libnuma in ARG [default=system default]])
@@ -22,14 +26,14 @@ AC_DEFUN([FP_FIND_LIBNUMA],
LIBNUMA_CFLAGS="-I$withval"
])
- AC_SUBST(LibNumaIncludeDir)
-
- HaveLibNuma=0
AC_ARG_ENABLE(numa,
- [AS_HELP_STRING([--enable-numa],
- [Enable NUMA memory policy and thread affinity support in the
- runtime system via numactl's libnuma [default=auto]])])
+ [AS_HELP_STRING([--enable-numa],
+ [Enable NUMA memory policy and thread affinity support in the
+ runtime system via numactl's libnuma [default=auto]])],
+ [],
+ [enable_numa=auto])
+ UseLibNuma=NO
if test "$enable_numa" != "no" ; then
CFLAGS2="$CFLAGS"
CFLAGS="$LIBNUMA_CFLAGS $CFLAGS"
@@ -38,23 +42,14 @@ AC_DEFUN([FP_FIND_LIBNUMA],
AC_CHECK_HEADERS([numa.h numaif.h])
- if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then
- AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1)
+ if test "$ac_cv_header_numa_h:$ac_cv_header_numaif_h" = "yes:yes" ; then
+ AC_CHECK_LIB([numa], [numa_available], [UseLibNuma=YES])
fi
- if test "$enable_numa:$HaveLibNuma" = "yes:0" ; then
- AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)])
+ if test "$enable_numa:$UseLibNuma" = "yes:NO" ; then
+ AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)])
fi
CFLAGS="$CFLAGS2"
LDFLAGS="$LDFLAGS2"
fi
-
- AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma])
- if test $HaveLibNuma = "1" ; then
- AC_SUBST([UseLibNuma],[YES])
- AC_SUBST([CabalHaveLibNuma],[True])
- else
- AC_SUBST([UseLibNuma],[NO])
- AC_SUBST([CabalHaveLibNuma],[False])
- fi
])
=====================================
rts/configure.ac
=====================================
@@ -33,6 +33,15 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host])
FPTOOLS_SET_PLATFORM_VARS([host], [Host])
FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
+dnl ** Other RTS features
+dnl --------------------------------------------------------------
+AC_DEFINE_UNQUOTED([USE_LIBDW], [$CABAL_FLAG_libdw], [Set to 1 to use libdw])
+
+AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$CABAL_FLAG_libnuma], [Define to 1 if you have libnuma])
+
+dnl ** Write config files
+dnl --------------------------------------------------------------
+
AC_OUTPUT
dnl ######################################################################
=====================================
rts/posix/OSMem.c
=====================================
@@ -30,10 +30,8 @@
#if defined(HAVE_FCNTL_H)
#include <fcntl.h>
#endif
-#if defined(HAVE_NUMA_H)
+#if HAVE_LIBNUMA
#include <numa.h>
-#endif
-#if defined(HAVE_NUMAIF_H)
#include <numaif.h>
#endif
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/435de9de368104fcf1b8e9a0f33750dd7c7c2d82
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/435de9de368104fcf1b8e9a0f33750dd7c7c2d82
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230922/cb0af141/attachment-0001.html>
More information about the ghc-commits
mailing list