2019-09-03 19:06:03 +02:00
|
|
|
LLVM_INSTALL_DIR=$TERMUX_PKG_BUILDDIR/llvm-install
|
|
|
|
|
2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://github.com/ldc-developers/ldc
|
|
|
|
TERMUX_PKG_DESCRIPTION="D programming language compiler, built with LLVM"
|
2019-01-21 13:53:58 +01:00
|
|
|
TERMUX_PKG_LICENSE="BSD 3-Clause"
|
2018-06-13 02:15:26 +02:00
|
|
|
TERMUX_PKG_VERSION=()
|
2020-02-15 02:03:03 +01:00
|
|
|
TERMUX_PKG_VERSION+=(1.20.0)
|
2019-12-21 13:25:50 +01:00
|
|
|
TERMUX_PKG_VERSION+=(9.0.1) # LLVM version
|
2020-02-15 02:03:03 +01:00
|
|
|
TERMUX_PKG_VERSION+=(2.090.1) # TOOLS version
|
|
|
|
TERMUX_PKG_VERSION+=(1.19.0) # DUB version
|
2020-02-17 14:33:59 +01:00
|
|
|
TERMUX_PKG_REVISION=1
|
2018-06-13 02:15:26 +02:00
|
|
|
|
|
|
|
TERMUX_PKG_SRCURL=(https://github.com/ldc-developers/ldc/releases/download/v${TERMUX_PKG_VERSION}/ldc-${TERMUX_PKG_VERSION}-src.tar.gz
|
2019-12-21 13:25:50 +01:00
|
|
|
https://github.com/ldc-developers/llvm-project/releases/download/ldc-v${TERMUX_PKG_VERSION[1]}/llvm-${TERMUX_PKG_VERSION[1]}.src.tar.xz
|
2018-06-13 02:15:26 +02:00
|
|
|
https://github.com/dlang/tools/archive/v${TERMUX_PKG_VERSION[2]}.tar.gz
|
2019-12-21 13:25:50 +01:00
|
|
|
https://github.com/dlang/dub/archive/v${TERMUX_PKG_VERSION[3]}.tar.gz
|
2018-08-20 19:21:27 +02:00
|
|
|
https://github.com/ldc-developers/ldc/releases/download/v${TERMUX_PKG_VERSION}/ldc2-${TERMUX_PKG_VERSION}-linux-x86_64.tar.xz)
|
2020-02-15 02:03:03 +01:00
|
|
|
TERMUX_PKG_SHA256=(49c9fdfe3a51c978385aae94f2e102f306102f6282215638f2ae3fb9ea8d3ab9
|
2019-12-21 13:25:50 +01:00
|
|
|
fb1aa89d334487a23036978e266c9e47e00941b40c749561a688efe83961e051
|
2020-02-15 02:03:03 +01:00
|
|
|
5b2db582632ec882188b70dc84da0156e16b21d346c9e46f6d21c663024efa35
|
|
|
|
84dc77f517ca1f115e05e25e8a8cdbcacbf31df281217ebac31dc974560a4ffc
|
|
|
|
ab2100228b9396ff1098006f7692d5638f4ebeb07890767499207c8aaf62ff09)
|
2019-06-20 20:30:12 +02:00
|
|
|
TERMUX_PKG_DEPENDS="clang, libc++, zlib"
|
2019-08-12 17:28:41 +02:00
|
|
|
TERMUX_PKG_NO_STATICSPLIT=true
|
2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_HOSTBUILD=true
|
2019-08-12 17:28:41 +02:00
|
|
|
TERMUX_PKG_FORCE_CMAKE=true
|
2017-07-01 02:43:00 +02:00
|
|
|
#These CMake args are only used to configure a patched LLVM
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
|
|
|
|
-DLLVM_ENABLE_PIC=ON
|
2019-09-29 22:41:21 +02:00
|
|
|
-DLLVM_ENABLE_PLUGINS=OFF
|
2017-07-01 02:43:00 +02:00
|
|
|
-DLLVM_BUILD_TOOLS=OFF
|
|
|
|
-DLLVM_BUILD_UTILS=OFF
|
2019-09-03 19:06:03 +02:00
|
|
|
-DCOMPILER_RT_INCLUDE_TESTS=OFF
|
2019-09-29 22:41:21 +02:00
|
|
|
-DLLVM_INCLUDE_TESTS=OFF
|
2019-09-03 19:06:03 +02:00
|
|
|
-DLLVM_ENABLE_TERMINFO=OFF
|
|
|
|
-DLLVM_ENABLE_LIBEDIT=OFF
|
2017-09-13 15:44:02 +02:00
|
|
|
-DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen
|
2019-09-29 22:41:21 +02:00
|
|
|
-DLLVM_CONFIG_PATH=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-config
|
2019-02-12 09:41:30 +01:00
|
|
|
-DPYTHON_EXECUTABLE=$(which python3)
|
2019-09-29 22:41:21 +02:00
|
|
|
-DLLVM_TARGETS_TO_BUILD='AArch64;ARM;WebAssembly;X86'
|
2019-09-03 19:06:03 +02:00
|
|
|
-DCMAKE_INSTALL_PREFIX=$LLVM_INSTALL_DIR
|
2017-09-13 15:44:02 +02:00
|
|
|
"
|
2017-07-01 02:43:00 +02:00
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_post_extract_package() {
|
2019-08-08 14:25:54 +02:00
|
|
|
# Certain packages are not safe to build on device because their
|
|
|
|
# build.sh script deletes specific files in $TERMUX_PREFIX.
|
2019-08-12 17:28:41 +02:00
|
|
|
if $TERMUX_ON_DEVICE_BUILD; then
|
2019-08-08 14:25:54 +02:00
|
|
|
termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
|
|
|
|
fi
|
|
|
|
|
2018-06-13 02:15:26 +02:00
|
|
|
mv llvm-${TERMUX_PKG_VERSION[1]}.src llvm
|
2019-09-03 19:06:03 +02:00
|
|
|
mv tools-${TERMUX_PKG_VERSION[2]} dlang-tools
|
2018-06-13 02:15:26 +02:00
|
|
|
mv dub-${TERMUX_PKG_VERSION[3]} dub
|
2017-07-01 02:43:00 +02:00
|
|
|
|
2019-09-13 02:09:36 +02:00
|
|
|
LLVM_TRIPLE=${TERMUX_HOST_PLATFORM/-/--}
|
2018-08-20 19:21:27 +02:00
|
|
|
if [ $TERMUX_ARCH = arm ]; then LLVM_TRIPLE=${LLVM_TRIPLE/arm-/armv7a-}; fi
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_host_build() {
|
2017-07-01 02:43:00 +02:00
|
|
|
termux_setup_cmake
|
2017-10-31 19:10:15 +01:00
|
|
|
termux_setup_ninja
|
2019-09-03 19:06:03 +02:00
|
|
|
|
|
|
|
# Build native llvm-tblgen, a prerequisite for cross-compiling LLVM
|
2017-10-31 19:10:15 +01:00
|
|
|
cmake -GNinja $TERMUX_PKG_SRCDIR/llvm \
|
2019-09-03 19:06:03 +02:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
2017-07-01 02:43:00 +02:00
|
|
|
-DLLVM_BUILD_TOOLS=OFF \
|
2018-04-30 11:47:35 +02:00
|
|
|
-DLLVM_BUILD_UTILS=OFF \
|
2019-09-29 22:41:21 +02:00
|
|
|
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
|
|
|
|
-DLLVM_INCLUDE_TESTS=OFF
|
2018-03-05 15:00:00 +01:00
|
|
|
ninja -j $TERMUX_MAKE_PROCESSES llvm-tblgen
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 19:06:03 +02:00
|
|
|
# Just before CMake invokation for LLVM:
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_pre_configure() {
|
2019-03-29 13:06:16 +01:00
|
|
|
LDFLAGS+=" -lc++_shared"
|
|
|
|
|
2020-02-15 02:03:03 +01:00
|
|
|
# Don't build compiler-rt sanitizers:
|
|
|
|
# * 64-bit targets: libclang_rt.hwasan-*-android.so fails to link
|
|
|
|
# * 32-bit ARM: compile errors for interception library
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
|
|
|
|
2018-08-20 19:21:27 +02:00
|
|
|
local LLVM_TARGET_ARCH
|
|
|
|
if [ $TERMUX_ARCH = "arm" ]; then
|
|
|
|
LLVM_TARGET_ARCH=ARM
|
|
|
|
elif [ $TERMUX_ARCH = "aarch64" ]; then
|
|
|
|
LLVM_TARGET_ARCH=AArch64
|
|
|
|
elif [ $TERMUX_ARCH = "i686" ]; then
|
|
|
|
LLVM_TARGET_ARCH=X86
|
|
|
|
elif [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
LLVM_TARGET_ARCH=X86
|
|
|
|
else
|
|
|
|
termux_error_exit "Invalid arch: $TERMUX_ARCH"
|
|
|
|
fi
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TRIPLE}"
|
2019-09-03 19:06:03 +02:00
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_TARGET_ARCH=${LLVM_TARGET_ARCH}"
|
2017-07-01 02:43:00 +02:00
|
|
|
|
|
|
|
# CPPFLAGS adds the system llvm to the include path, which causes
|
|
|
|
# conflicts with the local patched llvm when compiling ldc
|
|
|
|
CPPFLAGS=""
|
|
|
|
|
|
|
|
OLD_TERMUX_PKG_SRCDIR=$TERMUX_PKG_SRCDIR
|
|
|
|
TERMUX_PKG_SRCDIR=$TERMUX_PKG_SRCDIR/llvm
|
|
|
|
|
|
|
|
OLD_TERMUX_PKG_BUILDDIR=$TERMUX_PKG_BUILDDIR
|
|
|
|
TERMUX_PKG_BUILDDIR=$TERMUX_PKG_BUILDDIR/llvm
|
|
|
|
mkdir "$TERMUX_PKG_BUILDDIR"
|
|
|
|
}
|
|
|
|
|
2019-09-03 19:06:03 +02:00
|
|
|
# CMake for LLVM has been run:
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_post_configure() {
|
2019-09-03 19:06:03 +02:00
|
|
|
# Cross-compile & install LLVM
|
|
|
|
cd "$TERMUX_PKG_BUILDDIR"
|
|
|
|
if test -f build.ninja; then
|
|
|
|
ninja -j $TERMUX_MAKE_PROCESSES install
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Invoke CMake for LDC:
|
|
|
|
|
2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_SRCDIR=$OLD_TERMUX_PKG_SRCDIR
|
|
|
|
TERMUX_PKG_BUILDDIR=$OLD_TERMUX_PKG_BUILDDIR
|
|
|
|
cd "$TERMUX_PKG_BUILDDIR"
|
|
|
|
|
2019-09-29 22:41:21 +02:00
|
|
|
# Replace non-native llvm-config executable with bash script,
|
|
|
|
# as it is going to be invoked during LDC CMake config.
|
|
|
|
sed $TERMUX_PKG_SRCDIR/.azure-pipelines/android-llvm-config.in \
|
|
|
|
-e "s|@LLVM_VERSION@|${TERMUX_PKG_VERSION[1]}|g" \
|
|
|
|
-e "s|@LLVM_INSTALL_DIR@|$LLVM_INSTALL_DIR|g" \
|
|
|
|
-e "s|@TERMUX_PKG_SRCDIR@|$TERMUX_PKG_SRCDIR/llvm|g" \
|
|
|
|
-e "s|@LLVM_DEFAULT_TARGET_TRIPLE@|$LLVM_TRIPLE|g" \
|
|
|
|
-e "s|@LLVM_TARGETS@|AArch64 ARM X86 WebAssembly|g" > $LLVM_INSTALL_DIR/bin/llvm-config
|
|
|
|
chmod 755 $LLVM_INSTALL_DIR/bin/llvm-config
|
|
|
|
|
2019-09-13 02:09:36 +02:00
|
|
|
LDC_FLAGS="-mtriple=$LLVM_TRIPLE"
|
2018-08-20 19:21:27 +02:00
|
|
|
if [ $TERMUX_ARCH = arm ]; then LDC_FLAGS="$LDC_FLAGS;-mcpu=cortex-a8"; fi
|
|
|
|
|
2019-09-13 02:09:36 +02:00
|
|
|
LDC_PATH=$TERMUX_PKG_SRCDIR/ldc2-$TERMUX_PKG_VERSION-linux-x86_64
|
|
|
|
DMD=$LDC_PATH/bin/ldmd2
|
2018-08-20 19:21:27 +02:00
|
|
|
|
2019-09-03 19:06:03 +02:00
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DLLVM_ROOT_DIR=$LLVM_INSTALL_DIR \
|
2019-09-13 02:09:36 +02:00
|
|
|
-DD_COMPILER=$DMD \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX \
|
2019-09-29 22:41:21 +02:00
|
|
|
-DLDC_WITH_LLD=OFF \
|
2019-09-13 02:09:36 +02:00
|
|
|
-DD_LINKER_ARGS='-fuse-ld=bfd;-Lldc-build-runtime.tmp/lib;-lphobos2-ldc;-ldruntime-ldc;-Wl,--gc-sections'"
|
2018-08-20 19:21:27 +02:00
|
|
|
|
2017-07-01 02:43:00 +02:00
|
|
|
termux_step_configure_cmake
|
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_make() {
|
2019-09-03 19:06:03 +02:00
|
|
|
# Cross-compile the runtime libraries
|
2018-08-20 19:21:27 +02:00
|
|
|
$LDC_PATH/bin/ldc-build-runtime --ninja -j $TERMUX_MAKE_PROCESSES \
|
|
|
|
--dFlags="$LDC_FLAGS" --cFlags="$CFLAGS -I$TERMUX_PREFIX/include" \
|
|
|
|
--targetSystem="Android;Linux;UNIX" --ldcSrcDir="$TERMUX_PKG_SRCDIR"
|
|
|
|
|
2019-09-13 02:09:36 +02:00
|
|
|
# Set up host ldmd2 for cross-compilation
|
2018-08-20 19:21:27 +02:00
|
|
|
export DFLAGS="${LDC_FLAGS//;/ }"
|
|
|
|
|
2019-09-03 19:06:03 +02:00
|
|
|
# Cross-compile LDC executables (linked against runtime libs above)
|
2018-08-20 19:21:27 +02:00
|
|
|
if test -f build.ninja; then
|
2019-10-17 00:22:33 +02:00
|
|
|
ninja -j $TERMUX_MAKE_PROCESSES ldc2 ldmd2 ldc-build-runtime ldc-profdata ldc-prune-cache
|
2017-07-01 02:43:00 +02:00
|
|
|
fi
|
2017-09-06 21:16:04 +02:00
|
|
|
|
2019-09-03 19:06:03 +02:00
|
|
|
# Cross-compile dlang tools and dub:
|
|
|
|
|
2019-09-13 02:09:36 +02:00
|
|
|
# Set up host ldmd2 for cross-compilation & -linking
|
|
|
|
export DFLAGS="$DFLAGS -linker=bfd -L-L$TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib -Xcc=-pie -L-z -Lnocopyreloc"
|
|
|
|
if [ $TERMUX_ARCH = arm ]; then export DFLAGS="$DFLAGS -L--fix-cortex-a8"; fi
|
2018-08-20 19:21:27 +02:00
|
|
|
|
2019-09-03 19:06:03 +02:00
|
|
|
cd $TERMUX_PKG_SRCDIR/dlang-tools
|
2019-09-13 02:09:36 +02:00
|
|
|
$DMD -w -de rdmd.d -of=$TERMUX_PKG_BUILDDIR/bin/rdmd
|
|
|
|
$DMD -w -de ddemangle.d -of=$TERMUX_PKG_BUILDDIR/bin/ddemangle
|
|
|
|
$DMD -w -de DustMite/dustmite.d DustMite/splitter.d -of=$TERMUX_PKG_BUILDDIR/bin/dustmite
|
2017-09-06 21:16:04 +02:00
|
|
|
|
|
|
|
cd $TERMUX_PKG_SRCDIR/dub
|
2019-09-13 02:09:36 +02:00
|
|
|
$DMD -O -w -version=DubUseCurl -version=DubApplication -Isource @build-files.txt -of=$TERMUX_PKG_BUILDDIR/bin/dub
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_make_install() {
|
2019-10-17 00:22:33 +02:00
|
|
|
cp bin/{ddemangle,dub,dustmite,ldc-build-runtime,ldc-profdata,ldc-prune-cache,ldc2,ldmd2,rdmd} $TERMUX_PREFIX/bin
|
2019-09-03 19:06:03 +02:00
|
|
|
cp $TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib/*.a $TERMUX_PREFIX/lib
|
|
|
|
sed "s|$TERMUX_PREFIX/|%%ldcbinarypath%%/../|g" bin/ldc2_install.conf > $TERMUX_PREFIX/etc/ldc2.conf
|
|
|
|
cat $TERMUX_PREFIX/etc/ldc2.conf
|
2017-07-01 02:43:00 +02:00
|
|
|
|
|
|
|
rm -Rf $TERMUX_PREFIX/include/d
|
|
|
|
mkdir $TERMUX_PREFIX/include/d
|
|
|
|
cp -r $TERMUX_PKG_SRCDIR/runtime/druntime/src/{core,etc,ldc,object.d} $TERMUX_PREFIX/include/d
|
2018-08-20 19:21:27 +02:00
|
|
|
cp $LDC_PATH/import/ldc/gccbuiltins_{aarch64,arm,x86}.di $TERMUX_PREFIX/include/d/ldc
|
2017-07-01 02:43:00 +02:00
|
|
|
cp -r $TERMUX_PKG_SRCDIR/runtime/phobos/etc/c $TERMUX_PREFIX/include/d/etc
|
|
|
|
rm -Rf $TERMUX_PREFIX/include/d/etc/c/zlib
|
|
|
|
cp -r $TERMUX_PKG_SRCDIR/runtime/phobos/std $TERMUX_PREFIX/include/d
|
|
|
|
|
|
|
|
rm -Rf $TERMUX_PREFIX/share/ldc
|
|
|
|
mkdir $TERMUX_PREFIX/share/ldc
|
2018-12-17 08:01:31 +01:00
|
|
|
cp -r $TERMUX_PKG_SRCDIR/{LICENSE,README,packaging/bash_completion.d} $TERMUX_PREFIX/share/ldc
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|