llvm: Update from 5.0.1 to 6.0

Also build our own libomp.
This commit is contained in:
its-pointless 2018-03-21 09:10:53 +11:00 committed by Fredrik Fornwall
parent aeba9d07b2
commit db75340215
16 changed files with 221 additions and 60 deletions

View File

@ -0,0 +1,3 @@
TERMUX_SUBPKG_INCLUDE="bin/ld.gold bin/gold"
TERMUX_SUBPKG_DEPENDS="binutils"
TERMUX_SUBPKG_DESCRIPTION="gold linker"

View File

@ -3,21 +3,22 @@ TERMUX_PKG_DESCRIPTION="Collection of binary tools, the main ones being ld, the
TERMUX_PKG_VERSION=2.30
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/binutils/binutils-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--enable-gold --enable-plugins --disable-werror --with-system-zlib --enable-new-dtags"
TERMUX_PKG_SHA256=8c3850195d1c093d290a716e20ebcaa72eda32abf5e3d8611154b39cff79e9ea
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--disable-werror --with-system-zlib --enable-new-dtags"
TERMUX_PKG_EXTRA_MAKE_ARGS="tooldir=$TERMUX_PREFIX"
TERMUX_PKG_RM_AFTER_INSTALL="share/man/man1/windmc.1 share/man/man1/windres.1 bin/ld.bfd"
TERMUX_PKG_REVISION=1
TERMUX_PKG_KEEP_STATIC_LIBRARIES=true
# Avoid linking against libfl.so from flex if available:
export LEXLIB=
termux_step_post_make_install () {
cp $TERMUX_PKG_BUILDER_DIR/ldd $TERMUX_PREFIX/bin/ldd
cd $TERMUX_PREFIX/bin
# Setup symlinks as these are used when building, so used by
# system setup in e.g. python, perl and libtool:
for b in ar ld nm objdump ranlib readelf strip; do
ln -s -f $b $TERMUX_HOST_PLATFORM-$b
done
ln -sf ld.gold gold
}

View File

@ -0,0 +1,13 @@
--- ../cache/binutils-2.30/gold/options.cc 2018-01-13 13:31:16.000000000 +0000
+++ ./gold/options.cc 2018-03-11 23:17:59.326121534 +0000
@@ -1227,8 +1227,8 @@
|| this->user_set_sysroot()
|| *TARGET_SYSTEM_ROOT != '\0')
{
- this->add_to_library_path_with_sysroot("/lib");
- this->add_to_library_path_with_sysroot("/usr/lib");
+ this->add_to_library_path_with_sysroot("/data/data/com.termux/files/usr/lib");
+ this->add_to_library_path_with_sysroot("/system/lib");
}
else
this->add_to_library_path_with_sysroot(TOOLLIBDIR);

View File

@ -0,0 +1,13 @@
--- ../cache/binutils-2.30/gold/options.cc 2018-01-13 13:31:16.000000000 +0000
+++ ./gold/options.cc 2018-03-11 23:20:26.295331766 +0000
@@ -1227,8 +1227,8 @@
|| this->user_set_sysroot()
|| *TARGET_SYSTEM_ROOT != '\0')
{
- this->add_to_library_path_with_sysroot("/lib");
- this->add_to_library_path_with_sysroot("/usr/lib");
+ this->add_to_library_path_with_sysroot("/data/data/com.termux/files/usr/lib");
+ this->add_to_library_path_with_sysroot("/system/lib64");
}
else
this->add_to_library_path_with_sysroot(TOOLLIBDIR);

View File

@ -1,31 +1,18 @@
TERMUX_PKG_HOMEPAGE=https://clang.llvm.org/
TERMUX_PKG_DESCRIPTION="Modular compiler and toolchain technologies library"
_PKG_MAJOR_VERSION=5.0
TERMUX_PKG_VERSION=${_PKG_MAJOR_VERSION}.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0
_PKG_MAJOR_VERSION=6.0
TERMUX_PKG_VERSION=${_PKG_MAJOR_VERSION}.0
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/bugpoint
bin/clang-check
bin/clang-import-test
bin/clang-offload-bundler
bin/git-clang-format
bin/llvm-tblgen
bin/macho-dump
bin/sancov
bin/sanstats
bin/scan-build
bin/scan-view
lib/BugpointPasses.so
lib/libclang*.a
lib/libLLVM*.a
lib/libLTO.so
lib/LLVMHello.so
share/man/man1/scan-build.1
share/scan-build
share/scan-view
lib/libgomp.a
lib/libiomp5.a
"
TERMUX_PKG_DEPENDS="binutils, ncurses, ndk-sysroot, ndk-stl"
# Replace gcc since gcc is deprecated by google on android and is not maintained upstream.
@ -45,7 +32,15 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-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"
-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)
"
TERMUX_PKG_FORCE_CMAKE=yes
TERMUX_PKG_KEEP_STATIC_LIBRARIES=true
@ -54,7 +49,7 @@ termux_step_post_extract_package () {
termux_download \
https://releases.llvm.org/${TERMUX_PKG_VERSION}/$CLANG_SRC_TAR \
$TERMUX_PKG_CACHEDIR/$CLANG_SRC_TAR \
135f6c9b0cd2da1aff2250e065946258eb699777888df39ca5a5b4fe5e23d0ff
e07d6dd8d9ef196cfc8e8bb131cbd6a2ed0b1caf1715f9d05b0f0eeaddb6df32
tar -xf $TERMUX_PKG_CACHEDIR/$CLANG_SRC_TAR -C tools
mv tools/cfe-${TERMUX_PKG_VERSION}.src tools/clang
@ -63,10 +58,17 @@ termux_step_post_extract_package () {
termux_download \
https://llvm.org/releases/${TERMUX_PKG_VERSION}/$LLD_SRC_TAR \
$TERMUX_PKG_CACHEDIR/$LLD_SRC_TAR \
d5b36c0005824f07ab093616bdff247f3da817cae2c51371e1d1473af717d895
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 () {
@ -78,6 +80,10 @@ termux_step_host_build () {
}
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
@ -98,23 +104,19 @@ termux_step_pre_configure () {
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_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
local OPENMP_ARCH
if [ $TERMUX_ARCH = "i686" ]; then
OPENMP_ARCH="i386"
else
OPENMP_ARCH=$TERMUX_ARCH
fi
local OPENMP_PATH=lib64/clang/5.0/lib/linux/$OPENMP_ARCH/libomp.a
cp $TERMUX_STANDALONE_TOOLCHAIN/$OPENMP_PATH $TERMUX_PREFIX/lib
}
termux_step_post_massage () {

View File

@ -10,6 +10,7 @@ lib/clang
lib/libomp.a
libexec/
share/clang
share/man/man1/scan-build.1
"
TERMUX_SUBPKG_DESCRIPTION="C language frontend for LLVM"
TERMUX_SUBPKG_DEPENDS="libllvm"

View File

@ -0,0 +1,3 @@
TERMUX_SUBPKG_INCLUDE="lib/libLLVM*.a lib/libclang*.a lib/LTO.so include/clang"
TERMUX_SUBPKG_DESCRIPTION="C language frontend library for LLVM"
TERMUX_SUBPKG_DEPENDS="libllvm"

View File

@ -9,6 +9,8 @@ lib/liblldYAML.a
bin/lld
bin/lld-link
bin/ld.lld
bin/wasm-ld
bin/ld64.lld
lib/liblldCOFF.a
lib/liblldELF.a
"

View File

@ -1,11 +1,24 @@
TERMUX_SUBPKG_INCLUDE="
bin/llc
bin/lli
bin/sancov
bin/sanstats
bin/llvm*
bin/obj2yaml
bin/opt
bin/verify-uselistorder
bin/yaml2obj
share/opt-viewer
bin/bugpoint
bin/clang-check
bin/scan-build
bin/scan-view
share/man/man1/llc.1
share/man/man1/lli.1
share/man/man1/llvm*
share/man/man1/opt.1
share/man/man1/bugpoint.1
share/man/man1/tblgen.1
"
TERMUX_SUBPKG_DESCRIPTION="C language frontend for LLVM"
TERMUX_SUBPKG_DEPENDS="libllvm"

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef ANDROID_NLTYPES_H
#define ANDROID_NLTYPES_H
#include_next <nl_types.h>
#ifdef __cplusplus
extern "C" {
#endif
nl_catd catopen(const char*, int);
char* catgets(nl_catd, int, int, const char*);
int catclose(nl_catd);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* ANDROID_NLTYPES_H */

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2016 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <nl_types.h>
#include <errno.h>
__attribute__((weak,visibility("hidden")))
nl_catd catopen(const char*, int) {
return reinterpret_cast<nl_catd>(-1);
}
__attribute__((weak,visibility("hidden")))
char* catgets(nl_catd, int, int, const char* message) {
return const_cast<char*>(message);
}
__attribute__((weak,visibility("hidden")))
int catclose(nl_catd) {
// Since we didn't hand out a valid nl_catd, you can't be returning one to us.
errno = EBADF;
return -1;
}

View File

@ -0,0 +1,22 @@
--- ../../cache/llvm-project-20170507-release_600/openmp/runtime/src/CMakeLists.txt 2018-03-02 09:50:00.000000000 +0000
+++ ./projects/openmp/runtime/src/CMakeLists.txt 2018-03-08 03:39:14.548490023 +0000
@@ -50,6 +50,9 @@
if(${LIBOMP_USE_HWLOC})
include_directories(${LIBOMP_HWLOC_INSTALL_DIR}/include)
endif()
+if(ANDROID)
+ include_directories(${LIBOMP_SRC_DIR}/android)
+endif()
# Getting correct source files to build library
set(LIBOMP_CFILES)
@@ -95,6 +98,9 @@
libomp_append(LIBOMP_CXXFILES kmp_gsupport.cpp)
libomp_append(LIBOMP_ASMFILES z_Linux_asm.S) # Unix assembly file
endif()
+ if(ANDROID)
+ libomp_append(LIBOMP_CXXFILES android/nltypes_stubs.cpp)
+ endif()
libomp_append(LIBOMP_CFILES thirdparty/ittnotify/ittnotify_static.c LIBOMP_USE_ITT_NOTIFY)
libomp_append(LIBOMP_CXXFILES kmp_debugger.cpp LIBOMP_USE_DEBUGGER)
libomp_append(LIBOMP_CXXFILES kmp_stats.cpp LIBOMP_STATS)

View File

@ -21,17 +21,3 @@ diff -u -r ../llvm-5.0.0.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp ./tools/c
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
@@ -415,9 +412,12 @@
const llvm::Triple::ArchType Arch = ToolChain.getArch();
const bool isAndroid = ToolChain.getTriple().isAndroid();
const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
+ // Termux modification: Enable pie by default for Android
+ // and support the nopie flag.
const bool IsPIE =
!Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
- (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
+ (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault() || isAndroid) &&
+ !Args.hasArg(options::OPT_nopie);
const bool HasCRTBeginEndFiles =
ToolChain.getTriple().hasEnvironment() ||
(ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);

View File

@ -0,0 +1,11 @@
--- ../cache/cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp 2017-12-11 18:14:51.000000000 +0000
+++ ./tools/clang/lib/Driver/ToolChains/Linux.cpp 2018-03-13 03:32:36.142985756 +0000
@@ -816,7 +816,7 @@
}
bool Linux::isPIEDefault() const {
- return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
+ return getTriple().isAndroid() ||
getTriple().isMusl() || getSanitizerArgs().requiresPIE();
}

View File

@ -1,12 +1,11 @@
diff -u -r ../llvm-5.0.0.src/tools/llvm-shlib/CMakeLists.txt ./tools/llvm-shlib/CMakeLists.txt
--- ../llvm-5.0.0.src/tools/llvm-shlib/CMakeLists.txt 2017-07-11 03:17:44.000000000 +0200
+++ ./tools/llvm-shlib/CMakeLists.txt 2017-09-07 23:29:50.949353365 +0200
--- ../../cache/llvm-project-20170507-release_600/llvm/tools/llvm-shlib/CMakeLists.txt 2018-03-02 09:50:00.000000000 +0000
+++ ./tools/llvm-shlib/CMakeLists.txt 2018-03-08 01:56:32.764107349 +0000
@@ -37,7 +37,7 @@
add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
list(REMOVE_DUPLICATES LIB_NAMES)
-if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")) # FIXME: It should be "GNU ld for elf"
+if(("${CMAKE_SYSTEM_NAME}" MATCHES "^(Linux|Android)$") OR (MINGW) OR (HAIKU) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")) # FIXME: It should be "GNU ld for elf"
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map)
-if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
+if(("${CMAKE_SYSTEM_NAME}" MATCHES "^(Linux|Android)$") OR (MINGW) OR (HAIKU)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"

View File

@ -1,7 +1,7 @@
TERMUX_PKG_HOMEPAGE=https://developer.android.com/tools/sdk/ndk/index.html
TERMUX_PKG_DESCRIPTION="System header and library files from the Android NDK needed for compiling C programs"
TERMUX_PKG_VERSION=$TERMUX_NDK_VERSION
TERMUX_PKG_REVISION=7
TERMUX_PKG_REVISION=8
TERMUX_PKG_NO_DEVELSPLIT=yes
# Depend on libandroid-support-dev so that iconv.h and libintl.h are available:
TERMUX_PKG_DEPENDS="libandroid-support-dev"
@ -16,8 +16,6 @@ termux_step_extract_into_massagedir () {
cp -Rf $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include/* \
$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/include
cp $TERMUX_STANDALONE_TOOLCHAIN/lib64/clang/5.0/include/omp.h \
$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/include
local _LIBDIR=lib
if [ "$TERMUX_ARCH" = "x86_64" ]; then