Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2017 01:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
ldc-git AUR package (fixed PKGBUILD)
# Generated by mksrcinfo v8
# Tue Dec 12 00:48:37 UTC 2017
pkgbase = ldc-git
pkgdesc = A D Compiler based on the LLVM Compiler Infrastructure including D runtime and libphobos2
pkgver = v1.7.0.beta1.2.g3a6d93b8
pkgrel = 1
epoch = 1
url =
arch = i686
arch = x86_64
groups = dlang
groups = dlang-ldc
license = BSD
makedepends = git
makedepends = cmake
makedepends = llvm
makedepends = dmd
source = git+
source = git+
source = git+
source = git+
source = ldc2.conf
sha256sums = SKIP
sha256sums = SKIP
sha256sums = SKIP
sha256sums = SKIP
sha256sums = 7f7eea41e730175ea52993f82bef5bdea6d6fc628344cda9488c04bf4b430024
pkgname = ldc-git
depends = liblphobos-git
depends = llvm-libs
provides = d-compiler=
backup = etc/ldc2-git.conf
pkgname = liblphobos-git
depends = curl
provides = d-runtime
provides = d-stdlib
// See comments in driver/config.d in ldc source tree for grammar description of
// this config file.
// The default group is required
// default switches injected before all explicit command-line switches
switches = [
// default switches appended after all explicit command-line switches
post-switches = [
# Maintainer: Vladimir Panteleev <arch-pkg at>
# Contributor: zfo <>
# Contributor: Mihails Strasuns <>
# Contributor: Sven-Hendrik Haase <>
pkgname=("${_pkgname}-git" 'liblphobos-git')
groups=('dlang' 'dlang-ldc')
pkgdesc="A D Compiler based on the LLVM Compiler Infrastructure including D runtime and libphobos2"
arch=('i686' 'x86_64')
makedepends=('git' 'cmake' 'llvm' 'dmd')
pkgver() {
cd "${srcdir}/${_pkgname}"
git describe --tags HEAD | sed 's/-/./g'
prepare() {
cd "${srcdir}/${_pkgname}"
git submodule init
git config submodule.druntime.url "${srcdir}/druntime"
git config submodule.phobos.url "${srcdir}/phobos"
git config submodule.tests/d2/dmd-testsuite.url "${srcdir}/dmd-testsuite"
git submodule update
# patch the config file to be /etc/ldc2-git.conf
sed 's/ldc2[.]conf/ldc2-git.conf/' -i driver/configfile.cpp
# patch ldc to properly link to ldc-git (needed for ldmd)
sed 's/LDC_EXE ldc2/LDC_EXE ldc2-git/' -i CMakeLists.txt
sed 's/LDMD_EXE ldmd2/LDMD_EXE ldmd2-git/' -i CMakeLists.txt
# patch bash-completion
sed 's/\(ldc2\?\)\b/\1-git/g' -i bash_completion.d/ldc2
# it's faster just to rename the config files
build() {
cd "${srcdir}/${_pkgname}"
mkdir -p build && cd build
# workaround for wrong ld flag format generated by cmake:
# export LDFLAGS="-L-O1 -L--sort-common -L--as-needed -L-z -Lrelro"
local args=(
# Use host DMD
# This 1) ensures we use the main dmd package, and not something in the user's $PATH;
# and 2) compilation with ldc links Phobos/Druntime as shared libraries;
# dmd does static linking to the rescue!
# This is the git version - use static linking by default
package_ldc-git() {
local dmd_fe_ver
dmd_fe_ver=$(sed -n 's/^.*dmd_version = "v\(.*\)";$/\1/p' \
depends=('liblphobos-git' 'llvm-libs')
cd "${srcdir}/${_pkgname}/build"
make install DESTDIR="${pkgdir}"
# rename binaries
for f in profdata prune-cache; do
mv "${pkgdir}/usr/bin/ldc-$f" \
# rename bash-completion
mv "${pkgdir}/usr/share/bash-completion/completions/ldc2" \
# remove liblphobos files
rm -rf "${pkgdir}/usr/include"
rm -rf "${pkgdir}/usr/lib"
# remove misc
rm -rf "${pkgdir}/usr/bin/ldc-build-runtime"
# symlinks
ln -s ldc2-git "${pkgdir}/usr/share/bash-completion/completions/ldc-git"
ln -s ldc2-git "${pkgdir}/usr/bin/ldc-git"
ln -s ldmd2-git "${pkgdir}/usr/bin/ldmd-git"
# licenses
install -D -m644 "${srcdir}/ldc/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# default configuration files
install -D -m644 "${srcdir}/ldc2.conf" "${pkgdir}/etc/ldc2-git.conf"
package_liblphobos-git() {
provides=('d-runtime' 'd-stdlib')
cd "${srcdir}/ldc/build"
make install DESTDIR="${pkgdir}"
# remove ldc files
rm -rf "${pkgdir}/usr/bin/"
rm -rf "${pkgdir}/etc/"
rm -rf "${pkgdir}/usr/share/bash-completion/"
# rename libraries
for f in libphobos2-ldc libdruntime-ldc libphobos2-ldc-debug libdruntime-ldc-debug \
libldc-jit libldc-jit-rt libldc-profile-rt; do
for ext in a so; do
test -e "${pkgdir}/usr/lib/$f.$ext" && \
mv "${pkgdir}/usr/lib/$f.$ext" "${pkgdir}/usr/lib/$f-git.$ext"
# licenses
install -D -m644 "${srcdir}/ldc/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment