Add support for loongarch64 architecture in ld.hugetlbfs

This commit is contained in:
wangqiang 2024-10-29 11:05:19 +08:00
parent c2856ca815
commit 64656eb354
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,27 @@
From 135a062d6eda37ac56eb00e3dd11de7e241d619b Mon Sep 17 00:00:00 2001
From: wangqiang <wangqiang1@kylinos.cn>
Date: Fri, 27 Sep 2024 15:21:19 +0800
Subject: [PATCH] Add support for loongarch64 architecture in ld.hugetlbfs
- Added alignment configuration for loongarch64 architecture in the `ld.hugetlbfs` script.
- Set `HPAGE_SIZE` to 32MB and `SLICE_SIZE` to match `HPAGE_SIZE` for loongarch64.
- This ensures correct alignment and hugepage usage for binaries targeting loongarch64 systems.
Fix: https://github.com/libhugetlbfs/libhugetlbfs/issues/91
Referenc: https://github.com/llvm/llvm-project/blob/main/lld/ELF/Driver.cpp#L217
---
ld.hugetlbfs | 1 +
1 file changed, 1 insertion(+)
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index 5e4e4974..1028d8e2 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -117,6 +117,7 @@ elf64ppc|elf64lppc)
fi ;;
elf_i386|elf_x86_64) HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
elf_s390|elf64_s390) HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
+elf64loongarch) HPAGE_SIZE=$((32*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
armelf*_linux_eabi|aarch64elf*|aarch64linux*|sw_64elf*|sw_64linux*)
hpage_kb=$(cat /proc/meminfo | grep Hugepagesize: | awk '{print $2}')
HPAGE_SIZE=$((hpage_kb * 1024))

View File

@ -2,7 +2,7 @@
Name: libhugetlbfs
Version: 2.23
Release: 5
Release: 6
Summary: A library which provides easy access to huge pages of memory
License: LGPLv2+
URL: https://github.com/libhugetlbfs/libhugetlbfs
@ -12,6 +12,7 @@ Patch0: 0000-build_flags.patch
Patch1: Disable-hugepage-backed-malloc-if-__morecore-is-not-.patch
Patch2: libhugetlbfs-2.23-sw.patch
Patch3: add-loongarch-support.patch
Patch4: Add-support-for-loongarch64-architecture-in-ld.hugetlbfs.patch
Patch9001:libhugetlbfs-make-cflags.patch
Patch9002:libhugetlbfs-fix-max-segment-cannot-adopt-the-x86.patch
@ -86,6 +87,9 @@ touch $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d/hugepages.conf
%changelog
* Tue Oct 29 2024 wangqiang <wangqiang1@kylinos.cn> - 2.23-6
- Add support for loongarch64 architecture in ld.hugetlbfs
* Fri Sep 27 2024 wangqiang <wangqiang1@kylinos.cn> - 2.23-5
- Re-enable patch libhugetlbfs-fix-max-segment-cannot-adopt-the-x86.patch