aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeod24 <pro.mathias.lang@gmail.com>2021-08-01 16:23:10 +0900
committerAndy Postnikov <apostnikov@gmail.com>2021-10-28 01:52:22 +0000
commit83aa516bb0e7816cc99f9b34fe2a6873896e8a32 (patch)
treeb5293a519871b6ff5f41dbaf723613d4814714cf
parent3ef7d2ebeff9dd2ae9fc9aa5c8faecc74d0b663e (diff)
downloadaports-83aa516bb0e7816cc99f9b34fe2a6873896e8a32.tar.gz
aports-83aa516bb0e7816cc99f9b34fe2a6873896e8a32.tar.bz2
aports-83aa516bb0e7816cc99f9b34fe2a6873896e8a32.tar.xz
community/ldc: upgrade to 1.28.0
-rw-r--r--community/ldc/0001-Add-OpenBSD-to-section_ldc.d-202.patch24
-rw-r--r--community/ldc/0002-LDC-Fix-TLS-range-with-static-druntime-on-Linux-x86-.patch105
-rw-r--r--community/ldc/APKBUILD46
3 files changed, 163 insertions, 12 deletions
diff --git a/community/ldc/0001-Add-OpenBSD-to-section_ldc.d-202.patch b/community/ldc/0001-Add-OpenBSD-to-section_ldc.d-202.patch
new file mode 100644
index 0000000000..1f748807ea
--- /dev/null
+++ b/community/ldc/0001-Add-OpenBSD-to-section_ldc.d-202.patch
@@ -0,0 +1,24 @@
+From e87efd1dd3360cb0e1079e8b8e6a438745e95028 Mon Sep 17 00:00:00 2001
+From: Brian Callahan <ibara@users.noreply.github.com>
+Date: Sat, 23 Oct 2021 11:51:37 -0400
+Subject: [PATCH 1/2] Add OpenBSD to section_ldc.d (#202)
+
+This is needed to build on OpenBSD.
+---
+ src/rt/sections_ldc.d | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/rt/sections_ldc.d b/src/rt/sections_ldc.d
+index 45a0e929..5ee022bc 100644
+--- a/runtime/druntime/src/rt/sections_ldc.d
++++ b/runtime/druntime/src/rt/sections_ldc.d
+@@ -30,6 +30,7 @@ else version (Darwin) {}
+ else version (FreeBSD) {}
+ else version (DragonFlyBSD) {}
+ else version (NetBSD) {}
++else version (OpenBSD) {}
+ else version (Windows) {}
+ else version (LDC):
+
+--
+2.30.1 (Apple Git-130)
diff --git a/community/ldc/0002-LDC-Fix-TLS-range-with-static-druntime-on-Linux-x86-.patch b/community/ldc/0002-LDC-Fix-TLS-range-with-static-druntime-on-Linux-x86-.patch
new file mode 100644
index 0000000000..a13a797edd
--- /dev/null
+++ b/community/ldc/0002-LDC-Fix-TLS-range-with-static-druntime-on-Linux-x86-.patch
@@ -0,0 +1,105 @@
+From ec3c0aafbf4b6f3345e276e21a26ffee077470cf Mon Sep 17 00:00:00 2001
+From: Martin Kinkelin <noone@nowhere.com>
+Date: Sun, 24 Oct 2021 04:05:14 +0200
+Subject: [PATCH 2/2] LDC: Fix TLS range with static druntime on Linux x86/x64
+
+After some manual tests with bfd and lld linkers, this should fix
+https://github.com/ldc-developers/ldc/issues/3849.
+---
+ src/rt/sections_elf_shared.d | 51 ++++++++++++++++++++++++------------
+ 1 file changed, 34 insertions(+), 17 deletions(-)
+
+diff --git a/src/rt/sections_elf_shared.d b/src/rt/sections_elf_shared.d
+index 4bdb0091..4477b0de 100644
+--- a/runtime/druntime/src/rt/sections_elf_shared.d
++++ b/runtime/druntime/src/rt/sections_elf_shared.d
+@@ -165,6 +165,8 @@ private:
+ {
+ size_t _tlsMod;
+ size_t _tlsSize;
++ version (LDC)
++ size_t _tlsAlignment;
+ }
+ else static if (SharedDarwin)
+ {
+@@ -187,7 +189,10 @@ private:
+ {
+ static if (SharedELF)
+ {
+- return getTLSRange(_tlsMod, _tlsSize);
++ version (LDC)
++ return getTLSRange(_tlsMod, _tlsSize, _tlsAlignment);
++ else
++ return getTLSRange(_tlsMod, _tlsSize);
+ }
+ else static if (SharedDarwin)
+ {
+@@ -1029,12 +1034,7 @@ else
+ pdso._tlsMod = object.info.dlpi_tls_modid;
+ pdso._tlsSize = phdr.p_memsz;
+ version (LDC)
+- {
+- // align to multiple of size_t to avoid misaligned scanning
+- // (size is subtracted from TCB address to get base of TLS)
+- immutable mask = size_t.sizeof - 1;
+- pdso._tlsSize = (pdso._tlsSize + mask) & ~mask;
+- }
++ pdso._tlsAlignment = phdr.p_align;
+ break;
+
+ default:
+@@ -1207,25 +1207,42 @@ version (LDC)
+ version = Static_Linux_X86_Any;
+ }
+
+-void[] getTLSRange(size_t mod, size_t sz) nothrow @nogc
++// LDC: added `alignment` param
++void[] getTLSRange(size_t mod, size_t sz, size_t alignment) nothrow @nogc
+ {
+ version (Static_Linux_X86_Any)
+ {
++ void* tcb;
+ version (X86)
+- static void* endOfBlock() nothrow @nogc { asm nothrow @nogc { naked; mov EAX, GS:[0]; ret; } }
++ asm nothrow @nogc { "mov %%gs:0, %0" : "=r" (tcb); }
+ else version (X86_64)
+- static void* endOfBlock() nothrow @nogc { asm nothrow @nogc { naked; mov RAX, FS:[0]; ret; } }
++ asm nothrow @nogc { "mov %%fs:0, %0" : "=r" (tcb); }
++
++ void* start = tcb - sz;
++
++ // For non-ld.gold linkers, it seems to be necessary to align the
++ // pointer down according to the TLS alignment.
++ start = cast(void*) ((cast(size_t) start) & ~(alignment - 1));
+
+- // FIXME: It is unclear whether aligning the area down to the next
+- // double-word is necessary and if so, on what systems, but at least
+- // some implementations seem to do it.
+- version (none)
++ version (unittest) // verify against __tls_get_addr for static druntime unittest runners
+ {
+- immutable mask = (2 * size_t.sizeof) - 1;
+- sz = (sz + mask) & ~mask;
++ void* reference;
++ if (mod != 0)
++ {
++ auto ti = tls_index(mod, 0);
++ reference = __tls_get_addr(&ti);
++ }
++
++ if (reference != start)
++ {
++ import core.stdc.stdlib : abort;
++ fprintf(stderr, "ERROR: getTLSRange mismatch - %p\n", start);
++ fprintf(stderr, " vs. %p\n", reference);
++ abort();
++ }
+ }
+
+- return (endOfBlock() - sz)[0 .. sz];
++ return start[0 .. sz];
+ }
+ else
+ {
+--
+2.30.1 (Apple Git-130)
diff --git a/community/ldc/APKBUILD b/community/ldc/APKBUILD
index 3b65f91d3f..6d5bda84dd 100644
--- a/community/ldc/APKBUILD
+++ b/community/ldc/APKBUILD
@@ -1,7 +1,7 @@
# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Mathias LANG <pro.mathias.lang@gmail.com>
pkgname=ldc
-pkgver=1.26.0
+pkgver=1.28.0
pkgrel=0
pkgdesc="The LLVM-based D Compiler"
url="https://github.com/ldc-developers/ldc"
@@ -9,17 +9,20 @@ url="https://github.com/ldc-developers/ldc"
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="llvm-libunwind-dev tzdata $pkgname-static=$pkgver-r$pkgrel"
-makedepends="chrpath cmake curl-dev diffutils gdmd llvm11-dev llvm11-static
+makedepends="chrpath cmake curl-dev diffutils gdmd llvm12-dev llvm12-static
libedit-dev zlib-dev"
checkdepends="bash gdb grep llvm11-test-utils"
# A user might want to install the '-runtime' subpackage when they have
# a dynamically-linked D program.
subpackages="
+ $pkgname-dbg
$pkgname-runtime
$pkgname-static
- $pkgname-dbg
$pkgname-bash-completion:bashcomp:noarch"
-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
+ 0001-Add-OpenBSD-to-section_ldc.d-202.patch
+ 0002-LDC-Fix-TLS-range-with-static-druntime-on-Linux-x86-.patch
+"
builddir="$srcdir/ldc-$pkgver-src/"
build() {
@@ -40,8 +43,7 @@ build() {
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DD_COMPILER='gdmd' \
- -DLLVM_ROOT_DIR="/usr/lib/llvm11" \
- -DADDITIONAL_DEFAULT_LDC_SWITCHES=' "-linker=bfd", "-link-defaultlib-shared"' \
+ -DADDITIONAL_DEFAULT_LDC_SWITCHES=' "-linker=bfd", "-link-defaultlib-shared", "-L--export-dynamic"' \
$CMAKE_CROSSOPTS -S "$builddir" -B "$builddir/stage1"
make -C "$builddir/stage1"
@@ -60,12 +62,13 @@ build() {
-DCMAKE_C_FLAGS="$CFLAGS" \
-DD_COMPILER="$builddir/stage1/bin/ldmd2" \
-DC_SYSTEM_LIBS="unwind;m;pthread;rt;dl" \
- -DADDITIONAL_DEFAULT_LDC_SWITCHES=' "-linker=bfd", "-link-defaultlib-shared"' \
- -DLLVM_ROOT_DIR="/usr/lib/llvm11" \
+ -DADDITIONAL_DEFAULT_LDC_SWITCHES=' "-linker=bfd", "-link-defaultlib-shared", "-L--export-dynamic"' \
$CMAKE_CROSSOPTS "$builddir"
make
# Build the test runners
+ # Use of `-L--export-dynamic` is needed so that exceptions work correctly
+ # (namely: function names should be available without debug infos).
make all-test-runners
# CMake added the rpaths to the shared libs (of stage1!) - strip them
@@ -100,11 +103,24 @@ check() {
# - dmd-testsuite takes too long to run and has more to do with language checks
# which are less relevant to us than platform integration tests
# - lit-test disabled because 'TEST 'LDC :: debuginfo/print_gdb.d' FAILED'
- # Something to do with TLS variables not being printable in GDB
+ # See https://gitlab.alpinelinux.org/alpine/aports/-/issues/11154
# - '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$_tests_ignore"
+ #
+ # The following two tests fail since v1.27.0, but seems to fail for unrelated reason.
+ # - 'druntime-test-cycles'
+ # - 'druntime-test-gc'
+ # Namely, the following assert is triggered:
+ # core.exception.AssertError@../../src/rt/lifetime.d(1250): Assertion failure
+ # ----------------
+ # ??:? _d_assert [0x7fc894efb1a0]
+ # ??:? void rt.lifetime.__unittest_L1236_C12() [0x5642121a5040]
+ #
+ # Link: https://github.com/ldc-developers/druntime/blob/8e135b4e978975b24536e2a938801a29b39dc9f6/src/rt/lifetime.d#L1250
+ # However this unittest is AFAICS unrelated to the two tests,
+ # and either succeed or isn't run on its own.
+ ctest --output-on-failure -E "dmd-testsuite|lit-tests|druntime-test-exceptions|druntime-test-shared|druntime-test-stdcpp|druntime-test-cycles|druntime-test-gc$_tests_ignore"
}
package() {
@@ -124,7 +140,9 @@ runtime() {
do
mv "$pkgdir"/usr/lib/$libn-ldc-shared.so* "$subpkgdir/usr/lib/"
done
- mv "$pkgdir"/usr/lib/libldc-jit.so* "$subpkgdir/usr/lib"
+ # As of LDC v1.28.0, JIT is not supported for LLVM >= 12
+ # https://github.com/ldc-developers/ldc/blob/v1.28.0/CMakeLists.txt#L452
+ #mv "$pkgdir"/usr/lib/libldc-jit.so* "$subpkgdir/usr/lib"
mv "$pkgdir"/usr/lib/*.so* "$subpkgdir/usr/lib/"
}
@@ -145,4 +163,8 @@ bashcomp() {
amove usr/share/bash-completion/completions
}
-sha512sums="7bb2aa464f5ba834c07f67743f4af01db6588d56611d6c9e250a6908ebe93a0dcd9d3a79f8f252fc92eeb4826bfa62de6c51c4db03ff80e60a8d993e4451f573 ldc-1.26.0-src.tar.gz"
+sha512sums="
+3e566282175d65eb075c9c076bcf0475658c747238ed91efd350a7834d6d54760310ac5249fb74db3812c07058efbca8d726427ef39055d77b3f9a6940bf4188 ldc-1.28.0-src.tar.gz
+19a04c789b5f447dbc7dcf3536ef4f613ab4e637a4a707e3d5ba2445b4590881c030d7302a8ef3393ce5ca5bc9fb5695ba8b63b63fcd40b8d9c2fd147c079292 0001-Add-OpenBSD-to-section_ldc.d-202.patch
+a59dc0c05f9e6c74efe8f6c9ea35dff89fd2a34fc79c793925df997904da3b6032803a74715641c11944f7ef49ab96ddea70eabc25005f2e00ad1d9af2bd7bd8 0002-LDC-Fix-TLS-range-with-static-druntime-on-Linux-x86-.patch
+"