Introduce arch/x86/lib/, and make it the home for the somewhat misplaced
x86-specific file that lived in the arch-independent lib/.
Introduce ARCH_LIBS-y as a make variable, to arrange for arch-specific
libraries to (generally) come ahead of generic one(s) when linking. Should
any library be intended to come after the generic one(s), it can be
appended to $(ALL_LIBS-y).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Arrange to link arch-specific lib ahead of generic one.
---
xen/Makefile | 4 +++-
xen/arch/x86/Makefile | 1 +
xen/arch/x86/arch.mk | 2 ++
xen/arch/x86/lib/Makefile | 1 +
.../x86/lib/generic-hweightl.c} | 0
xen/lib/Makefile | 1 -
6 files changed, 7 insertions(+), 2 deletions(-)
create mode 100644 xen/arch/x86/lib/Makefile
rename xen/{lib/x86-generic-hweightl.c => arch/x86/lib/generic-hweightl.c} (100%)
diff --git a/xen/Makefile b/xen/Makefile
index e6cf2874251c..13e336ba5484 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -461,6 +461,7 @@ ALL_OBJS-y += xsm/built_in.o
ALL_OBJS-y += arch/$(SRCARCH)/built_in.o
ALL_OBJS-$(CONFIG_CRYPTO) += crypto/built_in.o
+ARCH_LIBS-y :=
ALL_LIBS-y := lib/lib.a
all-symbols-y :=
@@ -620,7 +621,8 @@ $(TARGET): outputmakefile asm-generic FORCE
$(Q)$(MAKE) $(build)=arch/$(SRCARCH) include
$(Q)$(MAKE) $(build)=. arch/$(SRCARCH)/include/asm/asm-offsets.h
$(Q)$(MAKE) $(build)=. MKRELOC=$(MKRELOC) 'ALL_OBJS=$(ALL_OBJS-y)' \
- 'ALL_LIBS=$(ALL_LIBS-y)' 'all_symbols=$(all-symbols-y)' $@
+ 'ALL_LIBS=$(ARCH_LIBS-y) $(ALL_LIBS-y)' \
+ 'all_symbols=$(all-symbols-y)' $@
SUBDIRS = xsm arch common crypto drivers lib test
define all_sources
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 300cc67407e9..61e2293a467e 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -5,6 +5,7 @@ obj-y += efi/
obj-y += genapic/
obj-$(CONFIG_GUEST) += guest/
obj-$(CONFIG_HVM) += hvm/
+obj-y += lib/
obj-y += mm/
obj-$(CONFIG_XENOPROF) += oprofile/
obj-$(CONFIG_PV) += pv/
diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index 16368a498bb7..0203138a819a 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -3,6 +3,8 @@
export XEN_IMG_OFFSET := 0x200000
+ARCH_LIBS-y += arch/x86/lib/lib.a
+
CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET)
# Prevent floating-point variables from creeping into Xen.
diff --git a/xen/arch/x86/lib/Makefile b/xen/arch/x86/lib/Makefile
new file mode 100644
index 000000000000..ddf7e19bdc1d
--- /dev/null
+++ b/xen/arch/x86/lib/Makefile
@@ -0,0 +1 @@
+lib-y += generic-hweightl.o
diff --git a/xen/lib/x86-generic-hweightl.c b/xen/arch/x86/lib/generic-hweightl.c
similarity index 100%
rename from xen/lib/x86-generic-hweightl.c
rename to xen/arch/x86/lib/generic-hweightl.c
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index 954d9216a39c..efca830d924c 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -39,7 +39,6 @@ lib-y += strtol.o
lib-y += strtoll.o
lib-y += strtoul.o
lib-y += strtoull.o
-lib-$(CONFIG_X86) += x86-generic-hweightl.o
lib-$(CONFIG_X86) += xxhash32.o
lib-$(CONFIG_X86) += xxhash64.o
On 08/12/2025 12:04 pm, Jan Beulich wrote: > Introduce arch/x86/lib/, and make it the home for the somewhat misplaced > x86-specific file that lived in the arch-independent lib/. > > Introduce ARCH_LIBS-y as a make variable, to arrange for arch-specific > libraries to (generally) come ahead of generic one(s) when linking. Should > any library be intended to come after the generic one(s), it can be > appended to $(ALL_LIBS-y). > > Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
© 2016 - 2025 Red Hat, Inc.