community/ldc: enable on loongarch64

This commit is contained in:
Celeste 2024-09-06 01:49:41 +00:00
parent cc538969c9
commit f6f603df7c
2 changed files with 75 additions and 3 deletions

View File

@ -7,7 +7,7 @@ _llvmver=18
pkgdesc="The LLVM-based D Compiler"
url="https://github.com/ldc-developers/ldc"
# LDC does not support host compiling on most of the architecture Alpine supports
arch="x86_64 aarch64"
arch="x86_64 aarch64 loongarch64"
license="BSD-3-Clause AND BSL-1.0 AND ( Artistic-1.0 OR GPL-2.0-or-later ) AND NCSA AND MIT"
depends="
$pkgname-static=$pkgver-r$pkgrel
@ -36,7 +36,9 @@ subpackages="
$pkgname-static
$pkgname-bash-completion
"
source="https://github.com/ldc-developers/ldc/releases/download/v$pkgver/ldc-$pkgver-src.tar.gz"
source="https://github.com/ldc-developers/ldc/releases/download/v$pkgver/ldc-$pkgver-src.tar.gz
loongarch64.patch
"
builddir="$srcdir/ldc-$pkgver-src/"
build() {
@ -49,6 +51,11 @@ build() {
export CFLAGS="${CFLAGS/-fstack-clash-protection}"
export CXXFLAGS="${CXXFLAGS/-fstack-clash-protection}"
;;
loongarch64)
export CFLAGS="${CFLAGS/-fstack-clash-protection}"
export CXXFLAGS="${CXXFLAGS/-fstack-clash-protection}"
_atomic=";atomic"
;;
esac
# First, build LDC using GDC
@ -69,7 +76,7 @@ build() {
-DBUILD_SHARED_LIBS=True \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DD_COMPILER="$builddir/stage1/bin/ldmd2" \
-DC_SYSTEM_LIBS="unwind;m;pthread;rt;dl" \
-DC_SYSTEM_LIBS="unwind;m;pthread;rt;dl$_atomic" \
-DADDITIONAL_DEFAULT_LDC_SWITCHES=' "-linker=bfd", "-link-defaultlib-shared", "-L--export-dynamic", "-L--eh-frame-hdr"' \
-DLLVM_ROOT_DIR="/usr/lib/llvm$_llvmver" \
$CMAKE_CROSSOPTS
@ -144,4 +151,5 @@ runtime() {
sha512sums="
d5c91043fa7d5faee9fc231fade52b6ac961907a7f6f8920d8337c9ba0b7052a5f98eb5f23ae56ca93510952c502ca78c9eec1d03f408aaa310fa4e4d57d9519 ldc-1.39.0-src.tar.gz
671302afafa14ad59e55189d99f94bc579bad5be2e60fab7b87d500e83bf1ca97951a2e375706f3ebbb480bd3a942f805b930e892cb7063cc22f2917ad97890f loongarch64.patch
"

View File

@ -0,0 +1,64 @@
Patch-Source: https://github.com/dlang/dmd/commit/cd4cf9cde2593d12ad0daa3f3d8eb7100075f05d
--
From cd4cf9cde2593d12ad0daa3f3d8eb7100075f05d Mon Sep 17 00:00:00 2001
From: Xin Wang <wangxin03@loongson.cn>
Date: Mon, 2 Sep 2024 17:44:08 +0800
Subject: [PATCH] druntime: add support for LoongArch64 on musl and libunwind
Co-authored-by: Celeste <cielesti@protonmail.com>
---
druntime/src/core/internal/backtrace/libunwind.d | 5 +++++
druntime/src/core/stdc/fenv.d | 8 ++++++++
druntime/src/core/sys/posix/signal.d | 5 +++++
3 files changed, 18 insertions(+)
diff --git a/runtime/druntime/src/core/internal/backtrace/libunwind.d b/runtime/druntime/src/core/internal/backtrace/libunwind.d
index 3378763eee63..b72858ab79cf 100644
--- a/runtime/druntime/src/core/internal/backtrace/libunwind.d
+++ b/runtime/druntime/src/core/internal/backtrace/libunwind.d
@@ -154,5 +154,10 @@ else version (RISCV64) // 32 is not supported
enum _LIBUNWIND_CONTEXT_SIZE = 64;
enum _LIBUNWIND_CURSOR_SIZE = 76;
}
+else version (LoongArch64)
+{
+ enum _LIBUNWIND_CONTEXT_SIZE = 65;
+ enum _LIBUNWIND_CURSOR_SIZE = 77;
+}
else
static assert(0, "Platform not supported");
diff --git a/runtime/druntime/src/core/stdc/fenv.d b/runtime/druntime/src/core/stdc/fenv.d
index b9b10aae3d93..ce77d5c1e6b2 100644
--- a/runtime/druntime/src/core/stdc/fenv.d
+++ b/runtime/druntime/src/core/stdc/fenv.d
@@ -432,6 +432,14 @@ else version (CRuntime_Musl)
}
alias ushort fexcept_t;
}
+ else version (LoongArch64)
+ {
+ struct fenv_t
+ {
+ uint __cw;
+ }
+ alias uint fexcept_t;
+ }
else
{
static assert(false, "Architecture not supported.");
diff --git a/runtime/druntime/src/core/sys/posix/signal.d b/runtime/druntime/src/core/sys/posix/signal.d
index ed4ec1270d90..e3d80fb02180 100644
--- a/runtime/druntime/src/core/sys/posix/signal.d
+++ b/runtime/druntime/src/core/sys/posix/signal.d
@@ -2758,6 +2758,11 @@ else version (CRuntime_Musl)
enum MINSIGSTKSZ = 2048;
enum SIGSTKSZ = 8192;
}
+ else version (LoongArch64)
+ {
+ enum MINSIGSTKSZ = 4096;
+ enum SIGSTKSZ = 16384;
+ }
else
static assert(0, "unimplemented");