[Git][ghc/ghc][wip/rts-configure-libdw-libnuma] Move lib{numa,dw} defines to RTS configure

John Ericson (@Ericson2314) gitlab at gitlab.haskell.org
Mon Jan 2 07:29:31 UTC 2023



John Ericson pushed to branch wip/rts-configure-libdw-libnuma at Glasgow Haskell Compiler / GHC


Commits:
7b2cf807 by John Ericson at 2023-01-02T02:28:55-05: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.

- - - - -


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
=====================================
@@ -1124,7 +1124,14 @@ AC_SUBST([UseLibffiForAdjustors])
 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
=====================================
@@ -12,8 +12,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 +21,29 @@ 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
=====================================
@@ -11,8 +11,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 +20,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 +36,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 "x:$ac_cv_header_numa_h:$ac_cv_header_numaif_h" = "x: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 "x:$enable_numa:$UseLibNuma" = "x: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/7b2cf80717a6b16e3f6135c6c6905bd5d3bbde72

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b2cf80717a6b16e3f6135c6c6905bd5d3bbde72
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/20230102/668f80a1/attachment-0001.html>


More information about the ghc-commits mailing list