termux-packages/packages/libllvm/build.sh

119 lines
4.5 KiB
Bash
Raw Normal View History

2017-12-26 23:27:38 +01:00
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
e07d6dd8d9ef196cfc8e8bb131cbd6a2ed0b1caf1715f9d05b0f0eeaddb6df32
6b8c4a833cf30230c0213d78dbac01af21387b298225de90ab56032ca79c0e0b
7c0e050d5f7da3b057579fb3ea79ed7dc657c765011b402eb5bbe5663a7c38fc)
TERMUX_PKG_SRCURL=(https://releases.llvm.org/${TERMUX_PKG_VERSION}/llvm-${TERMUX_PKG_VERSION}.src.tar.xz
https://releases.llvm.org/${TERMUX_PKG_VERSION}/cfe-${TERMUX_PKG_VERSION}.src.tar.xz
https://llvm.org/releases/${TERMUX_PKG_VERSION}/lld-${TERMUX_PKG_VERSION}.src.tar.xz
https://releases.llvm.org/${TERMUX_PKG_VERSION}/openmp-${TERMUX_PKG_VERSION}.src.tar.xz)
2015-06-13 01:03:31 +02:00
TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_RM_AFTER_INSTALL="
bin/clang-check
2017-03-15 16:28:36 +01:00
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
2017-07-04 13:45:47 +02:00
-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
Add fixes for debug builds (#2296) * build-package.sh: add possibility for debug patches and TERMUX_PKG_HAS_DEBUG Setting TERMUX_PKG_HAS_DEBUG=no disables attempt to build debug build of package. Useful for example if a debug build doesn't make sense, as for python-packages and texlive. * aapt: skip D_FORTIFY_SOURCE=2 for libandroid-cutils when doing debug build * lftp: skip D_FORTIFY_SOURCE=2 for debug build * libflac: don't use -g3 for debug build Configure script removes it otherwise. * nano: skip -D_FORTIFY_SOURCE=2 for debug build * vifm: skip -D_FORTIFY_SOURCE=2 for debug build * mc: skip -D_FORTIFY_SOURCE=2 for debug build * dropbear: add __attribute__((overloadable)) to XMEMSET and XMEMCPY if debug * gdb: add __attribute__((overloadable)) to strchr if debug * gnuit: add __attribute__((overloadable)) to strchr and strcpy if debug * gperf: add __attribute__((overloadable)) to strlen if debug * inetutils: add __attribute__((overloadable)) to strrchr and strchr if debug * readline: add __attribute__((overloadable)) to strchr if debug * tsocks: add __attribute__((overloadable)) to poll if debug * units: add __attribute__((overloadable)) to strchr if debug * liblua: fix bug in loslib.c that emerged in debug build Use strncpy instead of strcpy. Original error message: loslib.c:169:3: error: 'strcpy' called with string bigger than buffer lua_tmpnam(buff, err); ^ loslib.c:122:37: note: expanded from macro 'lua_tmpnam' strcpy(b, LUA_TMPNAMTEMPLATE); \ ^ * alpine: include our getpass.h in imap's mtest.c to declare getpass Debug build complained about the previous implicit declaration. * nginx: use --with-debug instead of --debug * cboard: skip -D_FORTIFY_SOURCE=2 for debug build * gettext: add __attribute__((overloadable)) to getcwd if debug * oathtool: skip -D_FORTIFY_SOURCE=2 for debug build * php: add __attribute__((overloadable)) to strlcpy and strlcat if debug * expect: add __attribute__((overloadable)) to strchr if debug * texlive: set TERMUX_PKG_HAS_DEBUG=no * asciinema: set TERMUX_PKG_HAS_DEBUG=no * libllvm: set TERMUX_PKG_HAS_DEBUG=no Debug build fails with: home/builder/.termux-build/libllvm/src/lib/Support/Unix/Path.inc:740:19: error: no matching function for call to 'RetryAfterSignal' if ((ResultFD = sys::RetryAfterSignal(-1, open, P.begin(), OpenFlags)) < 0) * build-package.sh: set TERMUX_PKG_REPLACES=package if debug build Hopefully allows us to install debug packages without breaking dependecies. Should be looked over and be made more similar to how debian does this in any case * Update build.sh
2018-06-13 02:12:36 +02:00
TERMUX_PKG_HAS_DEBUG=no
2015-06-13 01:03:31 +02:00
termux_step_post_extract_package () {
mv cfe-${TERMUX_PKG_VERSION}.src tools/clang
mv lld-${TERMUX_PKG_VERSION}.src tools/lld
mv openmp-${TERMUX_PKG_VERSION}.src projects/openmp
2015-06-13 01:03:31 +02:00
}
termux_step_host_build () {
termux_setup_cmake
2016-09-04 22:17:03 +02:00
cmake -G "Unix Makefiles" $TERMUX_PKG_SRCDIR \
-DLLVM_BUILD_TESTS=OFF \
-DLLVM_INCLUDE_TESTS=OFF
make -j $TERMUX_MAKE_PROCESSES clang-tblgen llvm-tblgen
2015-06-13 01:03:31 +02:00
}
2017-01-15 13:48:05 +01:00
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
2015-06-13 01:03:31 +02:00
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
2016-01-05 15:15:12 +01:00
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
2017-03-05 03:30:38 +01:00
termux_error_exit "Invalid arch: $TERMUX_ARCH"
fi
2015-06-13 01:03:31 +02:00
# see CMakeLists.txt and tools/clang/CMakeLists.txt
2017-01-15 13:48:05 +01:00
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"
2015-06-13 01:03:31 +02:00
}
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
2015-06-13 01:03:31 +02:00
}
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
}