aboutsummaryrefslogtreecommitdiffstats
path: root/community/ldc
diff options
context:
space:
mode:
authorRasmus Thomsen <oss@cogitri.dev>2020-04-13 11:51:51 +0200
committerRasmus Thomsen <oss@cogitri.dev>2020-04-14 13:55:12 +0000
commitc9c4693578eeb5a549abcb938364f0d2b2381ad5 (patch)
treea10d0d05fcb33f0b486dca99651b530147d2102c /community/ldc
parent73e56b23657c29245adc3fe33b37d98604661285 (diff)
downloadaports-c9c4693578eeb5a549abcb938364f0d2b2381ad5.tar.bz2
aports-c9c4693578eeb5a549abcb938364f0d2b2381ad5.tar.xz
community/ldc: enable on aarch64
See https://github.com/ldc-developers/ldc/issues/3270
Diffstat (limited to 'community/ldc')
-rw-r--r--community/ldc/3332.patch137
-rw-r--r--community/ldc/APKBUILD23
-rw-r--r--community/ldc/disable-static-assert.patch26
3 files changed, 182 insertions, 4 deletions
diff --git a/community/ldc/3332.patch b/community/ldc/3332.patch
new file mode 100644
index 0000000000..99852ef150
--- /dev/null
+++ b/community/ldc/3332.patch
@@ -0,0 +1,137 @@
+From 3e1946536974b778e71cda1790fa6fdf7c3708fe Mon Sep 17 00:00:00 2001
+From: Martin Kinkelin <noone@nowhere.com>
+Date: Fri, 21 Feb 2020 00:13:13 +0100
+Subject: [PATCH 1/2] Fix tail calls in thunks by applying the callee function
+ attributes to the call instruction
+
+This apparently isn't required for x86, but makes all the difference for
+AArch64 and fixes #3329.
+---
+ ir/irclass.cpp | 14 ++++++-----
+ tests/codegen/sret_thunk_gh3329.d | 42 +++++++++++++++++++++++++++++++
+ 2 files changed, 50 insertions(+), 6 deletions(-)
+ create mode 100644 tests/codegen/sret_thunk_gh3329.d
+
+diff --git a/ir/irclass.cpp b/ir/irclass.cpp
+index ac3ca1aa87..4a683ac861 100644
+--- a/ir/irclass.cpp
++++ b/ir/irclass.cpp
+@@ -203,7 +203,8 @@ LLConstant *IrAggr::getVtblInit() {
+ Logger::println("Running late functionSemantic to infer return type.");
+ if (!fd->functionSemantic()) {
+ if (fd->semantic3Errors) {
+- Logger::println("functionSemantic failed; using null for vtbl entry.");
++ Logger::println(
++ "functionSemantic failed; using null for vtbl entry.");
+ constants.push_back(getNullValue(voidPtrType));
+ continue;
+ }
+@@ -301,8 +302,8 @@ llvm::GlobalVariable *IrAggr::getInterfaceVtblSymbol(BaseClass *b,
+
+ const auto irMangle = getIRMangledVarName(mangledName.peekChars(), LINKd);
+
+- LLGlobalVariable *gvar =
+- declareGlobal(cd->loc, gIR->module, vtblType, irMangle, /*isConstant=*/true);
++ LLGlobalVariable *gvar = declareGlobal(cd->loc, gIR->module, vtblType,
++ irMangle, /*isConstant=*/true);
+
+ // insert into the vtbl map
+ interfaceVtblMap.insert({{b->sym, interfaces_index}, gvar});
+@@ -462,9 +463,10 @@ void IrAggr::defineInterfaceVtbl(BaseClass *b, bool new_instance,
+
+ // call the real vtbl function.
+ llvm::CallInst *call = gIR->ir->CreateCall(callee, args);
+- call->setCallingConv(irFunc->getCallingConv());
+- call->setTailCallKind(thunk->isVarArg() ? llvm::CallInst::TCK_MustTail
+- : llvm::CallInst::TCK_Tail);
++ call->setCallingConv(callee->getCallingConv());
++ call->setAttributes(callee->getAttributes());
++ call->setTailCallKind(callee->isVarArg() ? llvm::CallInst::TCK_MustTail
++ : llvm::CallInst::TCK_Tail);
+
+ // return from the thunk
+ if (thunk->getReturnType() == LLType::getVoidTy(gIR->context())) {
+diff --git a/tests/codegen/sret_thunk_gh3329.d b/tests/codegen/sret_thunk_gh3329.d
+new file mode 100644
+index 0000000000..7f2d7c62fe
+--- /dev/null
++++ b/tests/codegen/sret_thunk_gh3329.d
+@@ -0,0 +1,42 @@
++// RUN: %ldc -run %s
++
++extern(C) int printf(const(char)* format, ...);
++
++struct NoPOD
++{
++ size_t x;
++ ~this() {}
++}
++
++interface I
++{
++ NoPOD doIt(size_t arg);
++}
++
++__gshared C c;
++
++class C : I
++{
++ this()
++ {
++ c = this;
++ printf("c: %p\n", c);
++ }
++
++ NoPOD doIt(size_t arg)
++ {
++ printf("doIt this: %p; arg: %p\n", this, arg);
++ assert(this == c);
++ assert(arg == 0x2A);
++ return NoPOD(arg << 4);
++ }
++}
++
++void main()
++{
++ I i = new C;
++ printf("i: %p\n", i);
++ NoPOD r = i.doIt(0x2A);
++ printf("&r: %p\n", &r);
++ assert(r.x == 0x2A0);
++}
+
+From 803941307b1da278b63df1d5c2050b5ef6e153ac Mon Sep 17 00:00:00 2001
+From: Martin Kinkelin <noone@nowhere.com>
+Date: Fri, 21 Feb 2020 00:59:53 +0100
+Subject: [PATCH 2/2] Shippable CI: Remove workarounds for previously broken
+ debug libs
+
+---
+ shippable.yml | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/shippable.yml b/shippable.yml
+index 00aea59a7e..35cb54c9cd 100644
+--- a/shippable.yml
++++ b/shippable.yml
+@@ -83,14 +83,14 @@ build:
+ # Run LDC D unittests
+ - ctest --output-on-failure -R "ldc2-unittest"
+ # Run LIT testsuite, ignore the errors
+- - PATH=$PWD/../llvm/bin:$PATH ctest -V -R "lit-tests" || true
++ - cd tests
++ - PATH="$PWD/../../llvm/bin:$PATH" python runlit.py -v -j 32 . || true
++ - cd ..
+ # Run DMD testsuite, ignore the errors
+- # FIXME: the debug libs seem not really usable, most runnable tests crash
+- - sed -i 's|REQUIRED_ARGS=-g -link-defaultlib-debug|REQUIRED_ARGS=-g|g' tests/d2/CTestTestfile.cmake
+- - DMD_TESTSUITE_MAKE_ARGS='-j16 GDB_FLAGS=OFF' ctest -V -R "dmd-testsuite" || true
+- # Run defaultlib unittests (non-debug only for now, excl. hanging core.thread.fiber)
++ - DMD_TESTSUITE_MAKE_ARGS='-j32 GDB_FLAGS=OFF' ctest -V -R "dmd-testsuite" || true
++ # Run defaultlib unittests (excl. hanging core.thread.fiber)
+ # & druntime stand-alone tests, ignore the errors
+- - ctest -j16 --output-on-failure -E "dmd-testsuite|lit-tests|ldc2-unittest|-debug(-shared)?$|^core.thread.fiber($|-)" || true
++ - ctest -j32 --output-on-failure -E "dmd-testsuite|lit-tests|ldc2-unittest|^core.thread.fiber($|-)" || true
+ # Install LDC & make portable
+ - ninja install > /dev/null
+ - cd ..
diff --git a/community/ldc/APKBUILD b/community/ldc/APKBUILD
index 88dde923e9..72fafb339f 100644
--- a/community/ldc/APKBUILD
+++ b/community/ldc/APKBUILD
@@ -6,7 +6,7 @@ pkgrel=5
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"
+arch="x86_64 aarch64"
license="BSD-3-Clause AND BSL-1.0 AND ( Artistic-1.0 OR GPL-2.0-or-later ) AND NCSA AND MIT"
depends="libexecinfo tzdata"
makedepends="chrpath cmake curl-dev diffutils gdmd llvm10-dev llvm10-static
@@ -21,6 +21,8 @@ subpackages="
$pkgname-bash-completion:bashcomp:noarch"
source="https://github.com/ldc-developers/ldc/releases/download/v$pkgver/ldc-$pkgver-src.tar.gz
01-conf.patch
+ disable-static-assert.patch
+ 3332.patch
"
builddir="$srcdir/ldc-$pkgver-src/"
@@ -57,7 +59,7 @@ build() {
# Build the test runners
make all-test-runners
- # CMake added the rpaths to the shared libs - strip them
+ # CMake added the rpaths to the shared libs (of stage1!) - strip them
chrpath -d "$builddir"/lib/*.so*
chrpath -d \
"$builddir"/bin/ldc2 \
@@ -67,7 +69,18 @@ build() {
}
check() {
+ # Find the libraries we just built as final (not stage1!)
export LD_LIBRARY_PATH="$builddir"/lib
+
+ case "$CARCH" in
+ # Math & numeric related tests fail due to https://github.com/ldc-developers/ldc/issues/3270#issuecomment-613132406
+ # druntime-test-thread fails due to https://github.com/ldc-developers/ldc/issues/3403
+ aarch64)
+ _tests_ignore="|core\.thread\.fiber|std.*math.*|std\.numeric.*|std\.format|std\.algorithm\.sorting.*|druntime-test-thread"
+ ;;
+ esac
+
+
# Note: The testsuite does not parallelize well, as the 'clean' target get run in parallel.
# Hence '-j${JOBS}' was left out on purpose
#
@@ -78,7 +91,7 @@ check() {
# - 'druntime-test-shared' fails, probably because it is using 'Object.factory'
# - 'druntime-test-stdcpp' fails for an unknown reason and is temporarily disabled
# - 'druntime-test-exceptions' fails for an unknown reason and is temporarily disabled
- ctest --output-on-failure -E "dmd-testsuite|lit-tests|druntime-test-exceptions|druntime-test-shared|druntime-test-stdcpp"
+ ctest --output-on-failure -E "dmd-testsuite|lit-tests|druntime-test-exceptions|druntime-test-shared|druntime-test-stdcpp$_tests_ignore"
}
package() {
@@ -121,4 +134,6 @@ bashcomp() {
}
sha512sums="bb699999a69de1773a10998c653b5a1b0bce30e39cfcee0e19b036378b28519b3118ac369b341cfd305a8a9bd904564ffffe83f720a62ab4f2c1942c2e26bb53 ldc-1.20.1-src.tar.gz
-1a8ec8d75a5d01a1bc41e4b641e0663344fcbc44f3f10287f8cc716095faeadfa3dfc4ce7d84d72522151454e54d95e9f623ec5862e98e837d8fe44057307ce9 01-conf.patch"
+1a8ec8d75a5d01a1bc41e4b641e0663344fcbc44f3f10287f8cc716095faeadfa3dfc4ce7d84d72522151454e54d95e9f623ec5862e98e837d8fe44057307ce9 01-conf.patch
+9c0be23f61c12d0aecd09abec525c6b3827cc654ca08a890f2424602140ccb57c7034252b3424f3763f6649660470e954b2b2224bd31fe4c1489d98520add346 disable-static-assert.patch
+086bb8e7f6528fcc9aa715b6a9f99556b6f8c859377604d823c27fd615e815fe03e5c2ba805453ac4fce6253307616621a81c37577ce62564e7b954c5ccd9ac9 3332.patch"
diff --git a/community/ldc/disable-static-assert.patch b/community/ldc/disable-static-assert.patch
new file mode 100644
index 0000000000..96a5431649
--- /dev/null
+++ b/community/ldc/disable-static-assert.patch
@@ -0,0 +1,26 @@
+https://github.com/ldc-developers/ldc/issues/3270
+
+See https://git.musl-libc.org/cgit/musl/tree/src/math/sqrtl.c
+diff --git a/runtime/phobos/std/math.d b/runtime/phobos/std/math.d
+index 1c526d8..67f2521 100644
+--- a/runtime/phobos/std/math.d
++++ b/runtime/phobos/std/math.d
+@@ -4925,7 +4925,17 @@
+ enum real SQRTMIN = 0.5 * sqrt(real.min_normal); // This is a power of 2.
+ enum real SQRTMAX = 1.0L / SQRTMIN; // 2^^((max_exp)/2) = nextUp(sqrt(real.max))
+
+- static assert(2*(SQRTMAX/2)*(SQRTMAX/2) <= real.max);
++ // https://github.com/ldc-developers/ldc/issues/3270#issuecomment-613132406
++ version(AArch64)
++ {
++ }
++ else version(SystemZ)
++ {
++ }
++ else
++ {
++ static assert(2*(SQRTMAX/2)*(SQRTMAX/2) <= real.max);
++ }
+
+ static if (floatTraits!(real).realFormat == RealFormat.ieeeQuadruple)
+ {