termux-packages/packages/libllvm/build.sh
Vishal Biswas 160d3aeb06 update ndk to 17 and switch some packages to clang build (#2415)
* update ndk to 17

* bump NDK version in setup-android script

* libnl: fix for ndk r17

* libpixman: use clang's __builtin_shufflevector instead of __builtin_shuffle (#1)

Required to make package build with ndk17.

* fix as for arm

* ndk17 still uses ld.bfd on aarch64

* use -fno-integrated-as for clang only

* glib: remove patch unnecessary after ndk17

* torsocks: remove unneeded patch after ndk17

* subversion: fix build as clang++ now errors out for mismatched flags

* libpulseaudio: fix build with ndk17

https://github.com/termux/termux-packages/pull/2415#issuecomment-388296684

* gst-plugins-good: disable video4linux2

ioctl is defined as __overloadable in ndk17 headers which
  conflicts with v4l2object's member ioctl

* libzmq: disable Werror to build with ndk17

* ltrace: hardcode symbol not available in ndk17

* busybox: build with clang for all arches except arm

* dropbear: build with clang instead of gcc

* gnupg: build with clang instead of gcc

* openssl: use clang for all arches except arm

* picolisp: build with clang instead of gcc

* valgrind: use clang on all arches except aarch64

* Revert "gst-plugins-good: disable video4linux2"

This reverts commit 43850b81ccf60033c25cb13dfd326c1b0528773a.
Already applied on base branch.

* libllvm: use default arm triple
2018-05-27 14:55:20 +02:00

133 lines
4.9 KiB
Bash

TERMUX_PKG_HOMEPAGE=https://clang.llvm.org/
TERMUX_PKG_DESCRIPTION="Modular compiler and toolchain technologies library"
_PKG_MAJOR_VERSION=6.0
TERMUX_PKG_VERSION=${_PKG_MAJOR_VERSION}.0
TERMUX_PKG_REVISION=2
TERMUX_PKG_SHA256=1ff53c915b4e761ef400b803f07261ade637b0c269d99569f18040f3dcee4408
TERMUX_PKG_SRCURL=https://releases.llvm.org/${TERMUX_PKG_VERSION}/llvm-${TERMUX_PKG_VERSION}.src.tar.xz
TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_RM_AFTER_INSTALL="
bin/clang-check
bin/clang-import-test
bin/clang-offload-bundler
bin/git-clang-format
bin/macho-dump
lib/libgomp.a
lib/libiomp5.a
"
TERMUX_PKG_DEPENDS="binutils, ncurses, ndk-sysroot, ndk-stl, libffi"
# Replace gcc since gcc is deprecated by google on android and is not maintained upstream.
# Conflict with clang versions earlier than 3.9.1-3 since they bundled llvm.
TERMUX_PKG_CONFLICTS="gcc, clang (<< 3.9.1-3)"
TERMUX_PKG_REPLACES=gcc
# See http://llvm.org/docs/CMake.html:
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DPYTHON_EXECUTABLE=`which python`
-DLLVM_ENABLE_PIC=ON
-DLLVM_ENABLE_LIBEDIT=OFF
-DLLVM_BUILD_TESTS=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DCLANG_DEFAULT_CXX_STDLIB=libc++
-DCLANG_INCLUDE_TESTS=OFF
-DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF
-DC_INCLUDE_DIRS=$TERMUX_PREFIX/include
-DLLVM_LINK_LLVM_DYLIB=ON
-DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen
-DCLANG_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/clang-tblgen
-DLIBOMP_ENABLE_SHARED=FALSE
-DOPENMP_ENABLE_LIBOMPTARGET=OFF
-DLLVM_BINUTILS_INCDIR=$TERMUX_PREFIX/include
-DLLVM_ENABLE_SPHINX=ON
-DSPHINX_OUTPUT_MAN=ON
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
-DPERL_EXECUTABLE=$(which perl)
-DLLVM_ENABLE_FFI=ON
"
TERMUX_PKG_FORCE_CMAKE=yes
TERMUX_PKG_KEEP_STATIC_LIBRARIES=true
termux_step_post_extract_package () {
local CLANG_SRC_TAR=cfe-${TERMUX_PKG_VERSION}.src.tar.xz
termux_download \
https://releases.llvm.org/${TERMUX_PKG_VERSION}/$CLANG_SRC_TAR \
$TERMUX_PKG_CACHEDIR/$CLANG_SRC_TAR \
e07d6dd8d9ef196cfc8e8bb131cbd6a2ed0b1caf1715f9d05b0f0eeaddb6df32
tar -xf $TERMUX_PKG_CACHEDIR/$CLANG_SRC_TAR -C tools
mv tools/cfe-${TERMUX_PKG_VERSION}.src tools/clang
local LLD_SRC_TAR=lld-${TERMUX_PKG_VERSION}.src.tar.xz
termux_download \
https://llvm.org/releases/${TERMUX_PKG_VERSION}/$LLD_SRC_TAR \
$TERMUX_PKG_CACHEDIR/$LLD_SRC_TAR \
6b8c4a833cf30230c0213d78dbac01af21387b298225de90ab56032ca79c0e0b
tar -xf $TERMUX_PKG_CACHEDIR/$LLD_SRC_TAR -C tools
mv tools/lld-${TERMUX_PKG_VERSION}.src tools/lld
local OPENMP_SRC_TAR=openmp-${TERMUX_PKG_VERSION}.src.tar.xz
termux_download \
http://releases.llvm.org/${TERMUX_PKG_VERSION}/$OPENMP_SRC_TAR \
$TERMUX_PKG_CACHEDIR/$OPENMP_SRC_TAR \
7c0e050d5f7da3b057579fb3ea79ed7dc657c765011b402eb5bbe5663a7c38fc
tar -xf $TERMUX_PKG_CACHEDIR/$OPENMP_SRC_TAR -C projects
mv projects/openmp-${TERMUX_PKG_VERSION}.src projects/openmp
}
termux_step_host_build () {
termux_setup_cmake
cmake -G "Unix Makefiles" $TERMUX_PKG_SRCDIR \
-DLLVM_BUILD_TESTS=OFF \
-DLLVM_INCLUDE_TESTS=OFF
make -j $TERMUX_MAKE_PROCESSES clang-tblgen llvm-tblgen
}
termux_step_pre_configure () {
mkdir projects/openmp/runtime/src/android
cp $TERMUX_PKG_BUILDER_DIR/nl_types.h projects/openmp/runtime/src/android
cp $TERMUX_PKG_BUILDER_DIR/nltypes_stubs.cpp projects/openmp/runtime/src/android
cd $TERMUX_PKG_BUILDDIR
export LLVM_DEFAULT_TARGET_TRIPLE=$TERMUX_HOST_PLATFORM
export 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
# see CMakeLists.txt and tools/clang/CMakeLists.txt
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$LLVM_DEFAULT_TARGET_TRIPLE"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_TARGET_ARCH=$LLVM_TARGET_ARCH -DLLVM_TARGETS_TO_BUILD=all"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_HOST_TRIPLE=$LLVM_DEFAULT_TARGET_TRIPLE"
}
termux_step_post_make_install () {
if [ $TERMUX_ARCH = "arm" ]; then
cp ../src/projects/openmp/runtime/exports/common.min.50/include/omp.h $TERMUX_PREFIX/include
else
cp ../src/projects/openmp/runtime/exports/common.min.50.ompt.optional/include/omp.h $TERMUX_PREFIX/include
fi
make docs-llvm-man
cp docs/man/* $TERMUX_PREFIX/share/man/man1
cd $TERMUX_PREFIX/bin
for tool in clang clang++ cc c++ cpp gcc g++ ${TERMUX_HOST_PLATFORM}-{clang,clang++,gcc,g++,cpp}; do
ln -f -s clang-${_PKG_MAJOR_VERSION} $tool
done
}
termux_step_post_massage () {
sed $TERMUX_PKG_BUILDER_DIR/llvm-config.in \
-e "s|@TERMUX_PKG_VERSION@|$TERMUX_PKG_VERSION|g" \
-e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \
-e "s|@TERMUX_PKG_SRCDIR@|$TERMUX_PKG_SRCDIR|g" \
-e "s|@LLVM_TARGET_ARCH@|$LLVM_TARGET_ARCH|g" \
-e "s|@LLVM_DEFAULT_TARGET_TRIPLE@|$LLVM_DEFAULT_TARGET_TRIPLE|g" \
-e "s|@TERMUX_ARCH@|$TERMUX_ARCH|g" > $TERMUX_PREFIX/bin/llvm-config
chmod 755 $TERMUX_PREFIX/bin/llvm-config
}