Skip to content
Snippets Groups Projects
Commit be072d23 authored by zhaixiaojuan's avatar zhaixiaojuan Committed by Sören Tempel
Browse files

community/polyml: add loongarch64 support

parent 7ac7dc17
No related branches found
No related tags found
1 merge request!67177community/polyml: add loongarch64 support
Pipeline #247006 skipped
...@@ -11,7 +11,14 @@ license="LGPL-2.1-only" ...@@ -11,7 +11,14 @@ license="LGPL-2.1-only"
makedepends="gmp-dev libffi-dev" makedepends="gmp-dev libffi-dev"
subpackages="$pkgname-dev $pkgname-doc" subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/polyml/polyml/archive/v$pkgver.tar.gz source="$pkgname-$pkgver.tar.gz::https://github.com/polyml/polyml/archive/v$pkgver.tar.gz
riscv64.patch" riscv64.patch
add-support-to-loongarch64.patch"
prepare() {
default_prepare
update_config_sub
update_config_guess
}
build() { build() {
# Compiling poly as a dynamically linked position independent # Compiling poly as a dynamically linked position independent
...@@ -41,4 +48,5 @@ package() { ...@@ -41,4 +48,5 @@ package() {
sha512sums=" sha512sums="
e471abef01b7f2bfac6d847904c0fcef6ae5a1356b1246a2e8982d24fd590b49feb03752642efe09d34344b4faf89bc3edd4418e9993e72ea22e5482e6d37271 polyml-5.9.1.tar.gz e471abef01b7f2bfac6d847904c0fcef6ae5a1356b1246a2e8982d24fd590b49feb03752642efe09d34344b4faf89bc3edd4418e9993e72ea22e5482e6d37271 polyml-5.9.1.tar.gz
bf41a055b01ca9e5d1856e39f318079e23272eb034031cb97f7b7dbb94b981b6956baaba38d33c959e2175f052d4214dffd6f1fb18a69b8509013a19a93beb50 riscv64.patch bf41a055b01ca9e5d1856e39f318079e23272eb034031cb97f7b7dbb94b981b6956baaba38d33c959e2175f052d4214dffd6f1fb18a69b8509013a19a93beb50 riscv64.patch
eb8b2b390a8c210b180f9fcb6742c4d2a9938c5e720b3925690f0fb78058c15e65ef18af677d48fcdd4896c814978d9030f09280799f7426798b601fd2161ea6 add-support-to-loongarch64.patch
" "
diff --git a/config.h.in b/config.h.in
index 8c98c2f..64a045e 100644
--- a/config.h.in
+++ b/config.h.in
@@ -466,6 +466,9 @@
/* Define if the host is an Itanium */
#undef HOSTARCHITECTURE_IA64
+/* Define if the host is a LoongArch (64-bit) */
+#undef HOSTARCHITECTURE_LOONGARCH64
+
/* Define if the host is a Motorola 68000 */
#undef HOSTARCHITECTURE_M68K
diff --git a/configure b/configure
index 5bc938b..454f223 100755
--- a/configure
+++ b/configure
@@ -23512,6 +23512,12 @@ printf "%s\n" "#define HOSTARCHITECTURE_RISCV32 1" >>confdefs.h
printf "%s\n" "#define HOSTARCHITECTURE_RISCV64 1" >>confdefs.h
+ polyarch=interpret
+ ;;
+ loongarch64)
+
+printf "%s\n" "#define HOSTARCHITECTURE_LOONGARCH64 1" >>confdefs.h
+
polyarch=interpret
;;
*) as_fn_error $? "Poly/ML is not supported for this architecture" "$LINENO" 5 ;;
diff --git a/configure.ac b/configure.ac
index e48afb7..fc1d3ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -452,6 +452,10 @@ case "${host_cpu}" in
AC_DEFINE([HOSTARCHITECTURE_RISCV64], [1], [Define if the host is a RISC-V (64-bit)])
polyarch=interpret
;;
+ loongarch64)
+ AC_DEFINE([HOSTARCHITECTURE_LOONGARCH64], [1], [Define if the host is a LoongArch (64-bit)])
+ polyarch=interpret
+ ;;
*) AC_MSG_ERROR([Poly/ML is not supported for this architecture]) ;;
esac
diff --git a/libpolyml/elfexport.cpp b/libpolyml/elfexport.cpp
index 13a2c43..ec16594 100644
--- a/libpolyml/elfexport.cpp
+++ b/libpolyml/elfexport.cpp
@@ -286,6 +286,21 @@
# endif
# define HOST_E_FLAGS (HOST_E_FLAGS_FLOAT_ABI | HOST_E_FLAGS_RVE)
# define USE_RELA 1
+#elif defined(HOSTARCHITECTURE_LOONGARCH64)
+# define HOST_E_MACHINE EM_LOONGARCH
+# define HOST_DIRECT_DATA_RELOC R_LARCH_64
+# define HOST_DIRECT_FPTR_RELOC R_LARCH_64
+# if defined(__loongarch_soft_float)
+# define HOST_E_FLAGS_FLOAT_ABI EF_LARCH_ABI_SOFT_FLOAT
+# elif defined(__loongarch_single_float)
+# define HOST_E_FLAGS_FLOAT_ABI EF_LARCH_ABI_SINGLE_FLOAT
+# elif defined(__loongarch_double_float)
+# define HOST_E_FLAGS_FLOAT_ABI EF_LARCH_ABI_DOUBLE_FLOAT
+# else
+# error "Unknown LoongArch float ABI"
+# endif
+# define HOST_E_FLAGS (HOST_E_FLAGS_FLOAT_ABI | EF_LARCH_OBJABI_V1)
+# define USE_RELA 1
#else
# error "No support for exporting on this architecture"
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment