From 2e9b29943d73fb9331d674d72425187aeec401c8 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 12 Nov 2026 20:16:40 -0800 Subject: [PATCH] libhugetlbfs: Fix linking tests for riscv64 with lld ld.hugetlbfs has no case for the riscv64 elf64lriscv emulation, so the page sizes it passes for the HTLB_ALIGN=slice tests are empty and LLD fails with: ld.lld: error: invalid max-page-size: Use 2MB, riscv64's default huge page size, and set the text segment address explicitly as for aarch64. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj --- ...017-ld.hugetlbfs-Add-riscv64-support.patch | 40 +++++++++++++++++++ .../libhugetlbfs/libhugetlbfs_2.24.bb | 1 + 2 files changed, 41 insertions(+) create mode 100644 meta-oe/recipes-benchmark/libhugetlbfs/files/0017-ld.hugetlbfs-Add-riscv64-support.patch diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0017-ld.hugetlbfs-Add-riscv64-support.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0017-ld.hugetlbfs-Add-riscv64-support.patch new file mode 100644 index 0000000000..cd96ef740a --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0017-ld.hugetlbfs-Add-riscv64-support.patch @@ -0,0 +1,40 @@ +From: Khem Raj +Date: Thu, 12 Nov 2026 00:00:00 -0800 +Subject: [PATCH] ld.hugetlbfs: Add riscv64 support + +riscv64 was added to the Makefiles in 2.23, but ld.hugetlbfs has no +case for its elf64lriscv emulation, so HPAGE_SIZE and SLICE_SIZE stay +empty. Linking the HTLB_ALIGN=slice tests then passes +"-zcommon-page-size= -zmax-page-size=", which LLD rejects: + + ld.lld: error: invalid max-page-size: + +riscv64 uses 2MB (PMD) huge pages by default. Like aarch64, set the +text segment address explicitly: with a 2MB max page size the default +image base would otherwise be aligned down to 0. + +Upstream-Status: Submitted [https://github.com/libhugetlbfs/libhugetlbfs/pull/119] +Signed-off-by: Khem Raj +--- + ld.hugetlbfs | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/ld.hugetlbfs ++++ b/ld.hugetlbfs +@@ -121,6 +121,7 @@ armelf*_linux_eabi|aarch64elf*|aarch64li + hpage_kb=$(cat /proc/meminfo | grep Hugepagesize: | awk '{print $2}') + HPAGE_SIZE=$((hpage_kb * 1024)) + SLICE_SIZE=$HPAGE_SIZE ;; ++elf64lriscv*) HPAGE_SIZE=$((2*$MB)) SLICE_SIZE=$HPAGE_SIZE ;; + esac + + # LLD does not implement -Ttext-segment, --image-base is its equivalent +@@ -136,7 +137,7 @@ if [ "$HTLB_ALIGN" == "slice" ]; then + # targeting the ARM platform one needs to explicitly set the text segment offset + # otherwise it will be NULL. + case "$EMU" in +- armelf*_linux_eabi|aarch64elf*|aarch64linux*) ++ armelf*_linux_eabi|aarch64elf*|aarch64linux*|elf64lriscv*) + printf -v TEXTADDR "0x%x" "$SLICE_SIZE" + HTLBOPTS="$HTLBOPTS ${TEXTSEG}$TEXTADDR" ;; + elf_i386) HTLBOPTS="$HTLBOPTS ${TEXTSEG}0x08000000" ;; diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb b/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb index f1a68afb9d..10f0764236 100644 --- a/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb +++ b/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb @@ -27,6 +27,7 @@ SRC_URI = " \ file://0014-tests-Add-ldflags-to-linker-commandline-for-libheaps.patch \ file://0015-support-reproducible-builds.patch \ file://0016-ld.hugetlbfs-Use-image-base-with-LLD.patch \ + file://0017-ld.hugetlbfs-Add-riscv64-support.patch \ " UPSTREAM_CHECK_GITTAGREGEX = "(?P\d+(\.\d+)+)"