!1531 Add LoongArch support

From: @Hongchen_Zhang 
Reviewed-by: @gaojuxin09, @anred, @SuperSix173 
Signed-off-by: @xiexiuqi
This commit is contained in:
openeuler-ci-bot 2024-04-23 13:48:37 +00:00 committed by Gitee
commit 8644e6acb0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -33,7 +33,7 @@ sh /usr/lib/rpm/brp-ebs-sign --module test_openEuler_sign.ko || \
rm -f test_openEuler_sign.ko test_openEuler_sign.ko.sig
%endif
%global Arch $(echo %{_host_cpu} | sed -e s/i.86/x86/ -e s/x86_64/x86/ -e s/aarch64.*/arm64/ -e s/riscv.*/riscv/ -e s/powerpc64le/powerpc/)
%global Arch $(echo %{_host_cpu} | sed -e s/i.86/x86/ -e s/x86_64/x86/ -e s/aarch64.*/arm64/ -e s/riscv.*/riscv/ -e s/powerpc64le/powerpc/ -e s/loongarch64/loongarch/)
%global KernelVer %{version}-%{release}.%{_target_cpu}
%global debuginfodir /usr/lib/debug
@ -42,7 +42,7 @@ rm -f test_openEuler_sign.ko test_openEuler_sign.ko.sig
%global upstream_sublevel 0
%global devel_release 21
%global maintenance_release .0.0
%global pkg_release .22
%global pkg_release .24
%define with_debuginfo 1
# Do not recompute the build-id of vmlinux in find-debuginfo.sh
@ -148,7 +148,7 @@ Provides: kernel-uname-r = %{KernelVer} kernel=%{KernelVer}
Requires: dracut >= 001-7 grubby >= 8.28-2 initscripts >= 8.11.1-1 linux-firmware >= 20100806-2 module-init-tools >= 3.16-2
ExclusiveArch: noarch aarch64 i686 x86_64 riscv64 ppc64le
ExclusiveArch: noarch aarch64 i686 x86_64 riscv64 ppc64le loongarch64
ExclusiveOS: Linux
%if %{with_perf}
@ -393,7 +393,21 @@ sed -i arch/arm64/configs/openeuler_defconfig -e 's/^CONFIG_ARM64_VA_BITS_.*/CON
%global make %{__make} %{?clang_make_opts} HOSTCFLAGS="%{?build_cflags}" HOSTLDFLAGS="%{?build_ldflags}"
%ifarch loongarch64
%if 0%{with_signmodules}
echo "CONFIG_MODULE_SIG=y" >>arch/loongarch/configs/loongson3_defconfig
%endif
%if 0%{with_debuginfo}
echo "CONFIG_DEBUG_INFO=y" >>arch/loongarch/configs/loongson3_defconfig
%endif
make ARCH=%{Arch} loongson3_defconfig
%else
%{make} ARCH=%{Arch} openeuler_defconfig
%endif
%if %{with clang_lto}
scripts/config -e LTO_CLANG_FULL
@ -534,7 +548,12 @@ cd linux-%{KernelVer}
mkdir -p $RPM_BUILD_ROOT/boot
dd if=/dev/zero of=$RPM_BUILD_ROOT/boot/initramfs-%{KernelVer}.img bs=1M count=20
%ifarch loongarch64
strip -s vmlinux -o vmlinux.elf
install -m 755 vmlinux.elf $RPM_BUILD_ROOT/boot/vmlinuz-%{KernelVer}
%else
install -m 755 $(make -s image_name) $RPM_BUILD_ROOT/boot/vmlinuz-%{KernelVer}
%endif
%if 0%{?openEuler_sign_rsa}
%{openEuler_check_EBS_perm}
@ -865,6 +884,12 @@ fi
if [ -d /lib/modules/%{KernelVer} ] && [ "`ls -A /lib/modules/%{KernelVer}`" = "" ]; then
rm -rf /lib/modules/%{KernelVer}
fi
if [ `uname -i` == "loongarch64" ];then
[ -f /etc/grub2.cfg ] && GRUB_CFG=`readlink -f /etc/grub2.cfg`
[ "x${GRUB_CFG}" == "x" ] && [ -f /etc/grub2-efi.cfg ] && GRUB_CFG=`readlink -f /etc/grub2-efi.cfg`
[ "x${GRUB_CFG}" == "x" ] && [ -f /boot/efi/EFI/openEuler/grub.cfg ] && GRUB_CFG=/boot/efi/EFI/openEuler/grub.cfg
[ "x${GRUB_CFG}" != "x" ] && grub2-mkconfig -o ${GRUB_CFG}
fi
%posttrans
%{_sbindir}/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update %{KernelVer} || exit $?
@ -873,6 +898,13 @@ if [ `uname -i` == "aarch64" ] &&
[ -f /boot/EFI/grub2/grub.cfg ]; then
/usr/bin/sh %{_sbindir}/mkgrub-menu-%{version}-%{devel_release}%{?maintenance_release}%{?pkg_release}.sh %{version}-%{release}.aarch64 /boot/EFI/grub2/grub.cfg update
fi
if [ `uname -i` == "loongarch64" ];then
[ -f /etc/grub2.cfg ] && GRUB_CFG=`readlink -f /etc/grub2.cfg`
[ "x${GRUB_CFG}" == "x" ] && [ -f /etc/grub2-efi.cfg ] && GRUB_CFG=`readlink -f /etc/grub2-efi.cfg`
[ "x${GRUB_CFG}" == "x" ] && [ -f /boot/efi/EFI/openEuler/grub.cfg ] && GRUB_CFG=/boot/efi/EFI/openEuler/grub.cfg
[ "x${GRUB_CFG}" != "x" ] && grub2-mkconfig -o ${GRUB_CFG}
grubby --set-default=/boot/vmlinuz-%{KernelVer}
fi
if [ -x %{_sbindir}/weak-modules ]
then
%{_sbindir}/weak-modules --add-kernel %{KernelVer} || exit $?
@ -932,6 +964,8 @@ fi
%files headers
%defattr (-, root, root)
/usr/include/*
%exclude %{_includedir}/cpufreq.h
%exclude %{_includedir}/cpuidle.h
%if %{with_perf}
%files -n perf
@ -1019,6 +1053,12 @@ fi
%endif
%changelog
* Tue Apr 23 2024 Hongchen Zhang <zhanghongchen@loongson.cn> - 6.6.0-21.0.0.24
- add LoongArch support
* Tue Apr 23 2024 Hongchen Zhang <zhanghongchen@loongson.cn> - 6.6.0-21.0.0.23
- exclude cpufreq.h and cpuidle.h from kernel-headers package
* Sat Apr 20 2024 ZhangPeng <zhangpeng362@huawei.com> - 6.6.0-21.0.0.22
- !6201 v2 mm: some optimization about hugetlb and thp
- mm: filemap: try to enable THP for exec mapping