1From a0b547f41939304adfc0c430314c342dd69306ae Mon Sep 17 00:00:00 2001
2From: sterni <sternenseemann@systemli.org>
3Date: Thu, 17 Jul 2025 21:21:29 +0200
4Subject: [PATCH] rts: record libnuma include and lib dirs in package conf
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9The --with-libnuma-libraries and --with-libnuma-includes flags were
10originally introduced for hadrian in def486c90ef6f37d81d0d9c6df7544
11and curiously never supported by the make build system — even though
12the addition was made in the 9.0 series and even backported to the
138.10 series.
14
15While the make build system knows when to link against libnuma, it won't
16enforce its specific directories by adding them to rts.conf in the
17package db. This commit implements this retroactively for the make build
18system, modeled after how make does the same sort of thing for Libdw.
19The Libdw logic also affects the bindist configure file in
20distrib/configure.ac which isn't replicate since we don't need it.
21---
22 mk/config.mk.in | 4 ++++
23 rts/ghc.mk | 8 ++++++++
24 rts/package.conf.in | 5 +++--
25 rts/rts.cabal.in | 1 +
26 4 files changed, 16 insertions(+), 2 deletions(-)
27
28diff --git a/mk/config.mk.in b/mk/config.mk.in
29index 2ff2bea9b6..d95f927dbd 100644
30--- a/mk/config.mk.in
31+++ b/mk/config.mk.in
32@@ -324,6 +324,10 @@ LibdwIncludeDir=@LibdwIncludeDir@
33 # rts/Libdw.c:set_initial_registers()
34 GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 s390x),@UseLibdw@,NO))
35
36+UseLibNuma=@UseLibNuma@
37+LibNumaLibDir=@LibNumaLibDir@
38+LibNumaIncludeDir=@LibNumaIncludeDir@
39+
40 ################################################################################
41 #
42 # Paths (see paths.mk)
43diff --git a/rts/ghc.mk b/rts/ghc.mk
44index 36a82f9f2c..854bb8e013 100644
45--- a/rts/ghc.mk
46+++ b/rts/ghc.mk
47@@ -573,6 +573,14 @@ rts_PACKAGE_CPP_OPTS += -DLIBDW_INCLUDE_DIR=
48 rts_PACKAGE_CPP_OPTS += -DLIBDW_LIB_DIR=
49 endif
50
51+ifeq "$(UseLibNuma)" "YES"
52+rts_PACKAGE_CPP_OPTS += -DLIBNUMA_INCLUDE_DIR=$(LibNumaIncludeDir)
53+rts_PACKAGE_CPP_OPTS += -DLIBNUMA_LIB_DIR=$(LibNumaLibDir)
54+else
55+rts_PACKAGE_CPP_OPTS += -DLIBNUMA_INCLUDE_DIR=
56+rts_PACKAGE_CPP_OPTS += -DLIBNUMA_LIB_DIR=
57+endif
58+
59 # -----------------------------------------------------------------------------
60 # dependencies
61
62diff --git a/rts/package.conf.in b/rts/package.conf.in
63index cb5a436f5c..9e5ae48adb 100644
64--- a/rts/package.conf.in
65+++ b/rts/package.conf.in
66@@ -18,9 +18,9 @@ hidden-modules:
67 import-dirs:
68
69 #if defined(INSTALLING)
70-library-dirs: LIB_DIR FFI_LIB_DIR LIBDW_LIB_DIR
71+library-dirs: LIB_DIR FFI_LIB_DIR LIBDW_LIB_DIR LIBNUMA_LIB_DIR
72 #else /* !INSTALLING */
73-library-dirs: TOP"/rts/dist-install/build" FFI_LIB_DIR LIBDW_LIB_DIR
74+library-dirs: TOP"/rts/dist-install/build" FFI_LIB_DIR LIBDW_LIB_DIR LIBNUMA_LIB_DIR
75 #endif
76
77 hs-libraries: "HSrts" FFI_LIB
78@@ -74,6 +74,7 @@ include-dirs: TOP"/rts/include"
79 TOP"/rts/dist-install/build/include"
80 FFI_INCLUDE_DIR
81 LIBDW_INCLUDE_DIR
82+ LIBNUMA_INCLUDE_DIR
83 #endif
84
85 includes: Rts.h
86diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
87index a8882268ac..debf2ba0a0 100644
88--- a/rts/rts.cabal.in
89+++ b/rts/rts.cabal.in
90@@ -154,6 +154,7 @@ library
91 include-dirs: include
92 @FFIIncludeDir@
93 @LibdwIncludeDir@
94+ @LibNumaIncludeDir@
95 includes: Rts.h
96 install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
97 ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
98--
992.50.0
100