From 7987a8ade4307bc5408a36d8d442eb921cac46ff Mon Sep 17 00:00:00 2001 From: wangqiang Date: Tue, 29 Oct 2024 11:17:03 +0800 Subject: [PATCH] Add support for loongarch64 architecture in ld.hugetlbfs --- ...garch64-architecture-in-ld.hugetlbfs.patch | 27 +++++++++++++++++++ libhugetlbfs.spec | 8 ++++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 Add-support-for-loongarch64-architecture-in-ld.hugetlbfs.patch diff --git a/Add-support-for-loongarch64-architecture-in-ld.hugetlbfs.patch b/Add-support-for-loongarch64-architecture-in-ld.hugetlbfs.patch new file mode 100644 index 0000000..0b21bff --- /dev/null +++ b/Add-support-for-loongarch64-architecture-in-ld.hugetlbfs.patch @@ -0,0 +1,27 @@ +From 135a062d6eda37ac56eb00e3dd11de7e241d619b Mon Sep 17 00:00:00 2001 +From: wangqiang +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)) diff --git a/libhugetlbfs.spec b/libhugetlbfs.spec index 58075be..f195746 100644 --- a/libhugetlbfs.spec +++ b/libhugetlbfs.spec @@ -2,13 +2,14 @@ Name: libhugetlbfs Version: 2.24 -Release: 2 +Release: 3 Summary: A library which provides easy access to huge pages of memory License: LGPLv2+ URL: https://github.com/libhugetlbfs/libhugetlbfs Source0: https://github.com/libhugetlbfs/libhugetlbfs/releases/download/%{version}/%{name}-%{version}.tar.gz -Patch2: 0001-add-support-sw64.patch +Patch1: 0001-add-support-sw64.patch +Patch2: Add-support-for-loongarch64-architecture-in-ld.hugetlbfs.patch BuildRequires: gcc glibc-devel glibc-static BuildRequires: autoconf automake @@ -79,6 +80,9 @@ touch $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d/hugepages.conf %changelog +* Tue Oct 29 2024 wangqiang - 2.24-3 +- Add support for loongarch64 architecture in ld.hugetlbfs + * Mon Aug 26 2024 Weifeng Su - 2.24-2 - Add missing build dependencies in the self-build. -- Gitee