summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLW-archlinux2019-04-12 22:27:11 +0200
committerLW-archlinux2019-04-12 22:27:11 +0200
commit5412daa4f0670937fa5ca1b756f31415a3a74093 (patch)
tree87e195aee1e2fbb9843b3eba9461d77d496da00e
parent244dfb17e150f83821f8b1f8f86fc5124ecc3b71 (diff)
downloadaur-5412daa4f0670937fa5ca1b756f31415a3a74093.tar.gz
many changes
-rw-r--r--.SRCINFO101
-rw-r--r--PKGBUILD328
-rw-r--r--enable-SSP-and-PIE-by-default.patch289
-rw-r--r--llvm-config.h2
4 files changed, 495 insertions, 225 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 06d5c67f2a1c..961e94a960b0 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,74 +1,61 @@
pkgbase = llvm-git
- pkgdesc = Collection of modular and reusable compiler and toolchain technologies (git)
- pkgver = 9.0.0_r313660.af1cbdd3bac
- pkgrel = 1
+ pkgver = 9.0.0_r314109.3dc7c7ca311
+ pkgrel = 2
url = https://llvm.org/
- arch = i686
arch = x86_64
license = custom:University of Illinois/NCSA Open Source License
- makedepends = cmake
- makedepends = doxygen
- makedepends = gcc
- makedepends = gcc-libs
makedepends = git
- makedepends = graphviz
- makedepends = jsoncpp
- makedepends = libelf
- makedepends = libevent
+ makedepends = cmake
+ makedepends = ninja
makedepends = libffi
- makedepends = mathjax
+ makedepends = libedit
makedepends = ncurses
- makedepends = ninja
- makedepends = python-recommonmark
- makedepends = python-requests
+ makedepends = libxml2
+ makedepends = python-sphinx
+ makedepends = ocaml=4.07.1
+ makedepends = ocaml-ctypes
+ makedepends = ocaml-findlib
makedepends = python-sphinx
+ makedepends = python-recommonmark
makedepends = swig
- makedepends = valgrind
- depends = libedit
- depends = libxml2
- depends = python
- optdepends = openmp: OpenMP support in clang with -fopenmp
- provides = clang
- provides = clang=9.0.0_r313660.af1cbdd3bac
- provides = clang-analyzer=9.0.0_r313660.af1cbdd3bac
- provides = clang-analyzer-svn
- provides = clang-compiler-rt
- provides = clang-compiler-rt-svn
- provides = clang-svn
- provides = clang-tools-extra=9.0.0_r313660.af1cbdd3bac
- provides = clang-tools-extra-svn
+ makedepends = python
+ options = staticlibs
+ source = llvm-project::git+https://github.com/llvm/llvm-project.git
+ source = llvm-config.h
+ source = enable-SSP-and-PIE-by-default.patch
+ sha256sums = SKIP
+ sha256sums = 597dc5968c695bbdbb0eac9e8eb5117fcd2773bc91edf5ec103ecffffab8bc48
+ sha256sums = 58f86da25eb230ed6d423b5b61870cbf3bef88f38103ca676a2c7f34b2372171
+
+pkgname = llvm-git
+ pkgdesc = LLVM development version. includes clang and many other tools
+ depends = llvm-libs-git
+ depends = perl
+ optdepends = python: for scripts
+ optdepends = python-setuptools: for using lit (LLVM Integrated Tester)
+ optdepends = ocaml: for ocaml support
+ provides = llvm
provides = compiler-rt
- provides = compiler-rt-svn
+ provides = clang
provides = lld
provides = lldb
- provides = lldb-svn
- provides = lld-svn
- provides = llvm
- provides = llvm-libs
- provides = llvm-libs-svn
- provides = llvm-svn
- conflicts = clang
- conflicts = clang-analyzer
- conflicts = clang-compiler-rt
- conflicts = clang-tools-extra
+ provides = polly
+ provides = llvm-ocaml
+ conflicts = llvm
conflicts = compiler-rt
+ conflicts = clang
conflicts = lld
conflicts = lldb
- conflicts = llvm
- conflicts = llvm-libs
- replaces = clang-analyzer
- replaces = clang-analyzer-svn
- replaces = clang-compiler-rt
- replaces = clang-compiler-rt-svn
- replaces = clang-tools-extra
- replaces = clang-tools-extra-svn
- options = staticlibs
- options = !strip
- source = llvm::git+https://github.com/llvm/llvm-project.git
- source = llvm-config.h
- sha256sums = SKIP
- sha256sums = 844408b3cb84b4757e3c096dc89e24694f852bfc11a9cec295bc888748f4e10d
- depends_x86_64 = lib32-gcc-libs
+ conflicts = polly
+ conflicts = llvm-ocaml
-pkgname = llvm-git
+pkgname = llvm-libs-git
+ pkgdesc = runtime libraries for llvm-git
+ depends = gcc-libs
+ depends = zlib
+ depends = libffi
+ depends = libedit
+ depends = ncurses
+ depends = libxml2
+ provides = llvm-libs
diff --git a/PKGBUILD b/PKGBUILD
index 17dbb0701d4d..d47e2343e4fc 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,8 +1,11 @@
-# Maintainer: Yurii Kolesnykov <root@yurikoles.com>
+# Maintainer: Lone_Wolf <lonewolf@xs4all.nl>
+# Contributor: yurikoles <root@yurikoles.com>
+# Contributor: bearoso <bearoso@gmail.com>
# Contributor: Luchesar V. ILIEV <luchesar%2eiliev%40gmail%2ecom>
# Contributor: Anders Bergh <anders@archlinuxppc.org>
# Contributor: Armin K. <krejzi at email dot com>
# Contributor: Christian Babeux <christian.babeux@0x80.ca>
+# Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
# Contributor: Evangelos Foutras <evangelos@foutrelis.com>
# Contributor: Hesiod (https://github.com/hesiod)
# Contributor: Roberto Alsina <ralsina@kde.org>
@@ -10,192 +13,183 @@
# Contributor: Tomas Lindquist Olsen <tomas@famolsen.dk>
# Contributor: Tomas Wilhelmsson <tomas.wilhelmsson@gmail.com>
-pkgname=llvm-git
-_pkgname='llvm'
-pkgver=9.0.0_r313660.af1cbdd3bac
-pkgrel=1
-arch=('i686' 'x86_64')
-url='https://llvm.org/'
+
+pkgname=('llvm-git' 'llvm-libs-git')
+pkgver=9.0.0_r314109.3dc7c7ca311
+pkgrel=2
+_ocaml_ver=4.07.1
+arch=('x86_64')
+url="https://llvm.org/"
license=('custom:University of Illinois/NCSA Open Source License')
-makedepends=(
- 'cmake'
- 'doxygen'
- 'gcc'
- 'gcc-libs'
- 'git'
- 'graphviz'
- 'jsoncpp'
- 'libelf'
- 'libevent'
- 'libffi'
- 'mathjax'
- 'ncurses'
- 'ninja'
- 'python-recommonmark'
- 'python-requests'
- 'python-sphinx'
- 'swig'
- 'valgrind')
-depends=(
- 'libedit'
- 'libxml2'
- 'python')
-depends_x86_64=('lib32-gcc-libs')
-pkgdesc="Collection of modular and reusable compiler and toolchain technologies (git)"
-optdepends=('openmp: OpenMP support in clang with -fopenmp')
-provides=(
- 'clang'
- "clang=$pkgver"
- "clang-analyzer=$pkgver"
- "clang-analyzer-svn"
- 'clang-compiler-rt'
- 'clang-compiler-rt-svn'
- 'clang-svn'
- "clang-tools-extra=$pkgver"
- 'clang-tools-extra-svn'
- 'compiler-rt'
- 'compiler-rt-svn'
- 'lld'
- 'lldb'
- 'lldb-svn'
- 'lld-svn'
- 'llvm'
- 'llvm-libs'
- 'llvm-libs-svn'
- 'llvm-svn')
-conflicts=(
- 'clang'
- 'clang-analyzer'
- 'clang-compiler-rt'
- 'clang-tools-extra'
- 'compiler-rt'
- 'lld'
- 'lldb'
- 'llvm'
- 'llvm-libs')
-replaces=(
- 'clang-analyzer'
- 'clang-analyzer-svn'
- 'clang-compiler-rt'
- 'clang-compiler-rt-svn'
- 'clang-tools-extra'
- 'clang-tools-extra-svn')
-# this is always the latest git so debug info can be useful
-options=('staticlibs' '!strip')
-source=("${_pkgname}::git+https://github.com/llvm/llvm-project.git"
- 'llvm-config.h')
+makedepends=( 'git' 'cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2' 'python-sphinx'
+ "ocaml=$_ocaml_ver" 'ocaml-ctypes' 'ocaml-findlib'
+ 'python-sphinx' 'python-recommonmark' 'swig' 'python')
+
+options=('staticlibs')
+source=("llvm-project::git+https://github.com/llvm/llvm-project.git"
+ llvm-config.h
+ enable-SSP-and-PIE-by-default.patch)
sha256sums=('SKIP'
- '844408b3cb84b4757e3c096dc89e24694f852bfc11a9cec295bc888748f4e10d')
+ '597dc5968c695bbdbb0eac9e8eb5117fcd2773bc91edf5ec103ecffffab8bc48'
+ '58f86da25eb230ed6d423b5b61870cbf3bef88f38103ca676a2c7f34b2372171')
+
+_python_optimize() {
+ python -m compileall "$@"
+ python -O -m compileall "$@"
+ python -OO -m compileall "$@"
+}
+
pkgver() {
- cd "${srcdir}/${_pkgname}/${_pkgname}"
+ cd llvm-project/llvm
# This will almost match the output of `llvm-config --version` when the
# LLVM_APPEND_VC_REV cmake flag is turned on. The only difference is
# dash being replaced with underscore because of Pacman requirements.
- local _pkgver=$(awk -F 'MAJOR |MINOR |PATCH |SUFFIX |)' \
+ local _pkgver=$(awk -F 'MAJOR |MINOR |PATCH |)' \
'BEGIN { ORS="." ; i=0 } \
/set\(LLVM_VERSION_/ { print $2 ; i++ ; if (i==2) ORS="" } \
END { print "\n" }' \
CMakeLists.txt)_r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
- echo "${_pkgver//svn}"
+ echo "$_pkgver"
}
-build() {
- cd "${srcdir}/${_pkgname}"
- mkdir -p "${srcdir}/build"
- cd "${srcdir}/build"
-
- export PKG_CONFIG_PATH='/usr/lib/pkgconfig'
-
- cmake -G Ninja \
- -DLLVM_ENABLE_PROJECTS='clang;lldb;compiler-rt;lld' \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_INSTALL_PREFIX=/usr \
- -DPYTHON_EXECUTABLE=/usr/bin/python \
- -DLLVM_HOST_TRIPLE=$CHOST \
- -DLLVM_BUILD_LLVM_DYLIB=ON \
- -DLLVM_LINK_LLVM_DYLIB=ON \
- -DLLVM_INSTALL_UTILS=ON \
- -DLLVM_ENABLE_BINDINGS=OFF \
- -DLLVM_ENABLE_RTTI=ON \
- -DLLVM_ENABLE_FFI=ON \
- -DLLVM_BUILD_TESTS=OFF \
- -DLLVM_BUILD_DOCS=ON \
- -DLLVM_ENABLE_SPHINX=ON \
- -DLLVM_ENABLE_DOXYGEN=OFF \
- -DLLVM_LINK_LLVM_DYLIB=ON \
- -DSPHINX_WARNINGS_AS_ERRORS=OFF \
- -DLLDB_USE_SYSTEM_SIX=1 \
- -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
- -DLLVM_BINUTILS_INCDIR=/usr/include \
- "../${_pkgname}/${_pkgname}" \
-
- ninja all
+prepare() {
+ if [ -d _build ]; then
+ rm -rf _build
+ fi
+ mkdir _build
+ cd llvm-project
+ pushd clang
+ patch -Np1 -i "$srcdir"/enable-SSP-and-PIE-by-default.patch
+ popd
+ mv clang llvm/tools/clang
+ mv clang-tools-extra llvm/tools/clang/tools/extra
+ mv compiler-rt llvm/projects/compiler-rt
+ mv lld llvm/tools/lld
+ mv lldb llvm/tools/lldb
+ mv polly llvm/tools/polly
}
-package() {
- cd "${srcdir}/build"
-
- DESTDIR="$pkgdir" ninja install
-
- if [[ $CARCH == x86_64 ]]; then
- # Needed for multilib (https://bugs.archlinux.org/task/29951)
- # Header stub is taken from Fedora
- mv "$pkgdir/usr/include/llvm/Config/llvm-config"{,-64}.h
- cp "$srcdir/llvm-config.h" "$pkgdir/usr/include/llvm/Config/llvm-config.h"
- fi
-
- _install_licenses "${srcdir}/clang"
- _install_licenses "${srcdir}/compiler-rt"
- _install_licenses "${srcdir}/lld"
- _install_licenses "${srcdir}/lldb"
- _install_licenses "${srcdir}/llvm"
-
- python3 -m compileall "$pkgdir"
- python3 -O -m compileall "$pkgdir"
- python3 -OO -m compileall "$pkgdir"
+build() {
- rm -rf "$pkgdir/usr/libexec"
- sed -i 's|libexec|lib/clang|' "$pkgdir/usr/bin/scan-build"
+ cd _build
+ cmake "$srcdir"/llvm-project/llvm -G Ninja \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DLLVM_APPEND_VC_REV=ON \
+ -DLLVM_HOST_TRIPLE=$CHOST \
+ -DLLVM_ENABLE_RTTI=ON \
+ -DLLVM_ENABLE_FFI=ON \
+ -DFFI_INCLUDE_DIR:PATH="$(pkg-config --variable=includedir libffi)" \
+ -DLLVM_BUILD_LLVM_DYLIB=ON \
+ -DLLVM_LINK_LLVM_DYLIB=ON \
+ -DLLVM_INSTALL_UTILS=ON \
+ -DLLVM_BUILD_TESTS=ON \
+ -DLLVM_BUILD_DOCS=ON \
+ -DLLVM_ENABLE_DOXYGEN=OFF \
+ -DLLVM_ENABLE_SPHINX=ON \
+ -DSPHINX_OUTPUT_HTML:BOOL=OFF \
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF \
+ -DLLVM_BINUTILS_INCDIR=/usr/include \
+ -DLLVM_VERSION_SUFFIX="" \
+ -DPOLLY_ENABLE_GPGPU_CODEGEN=ON \
+ -DLINK_POLLY_INTO_TOOLS=ON
+ ninja all ocaml_doc
}
check() {
- cd "${srcdir}/build"
- ninja check
+ cd _build
+ # Dirty fix for unittests failing because the shared lib is not in the library path.
+ # Also, disable the LLVM tests on i686 as they seem to fail too often there.
+ [[ "$CARCH" == "i686" ]] || LD_LIBRARY_PATH="$srcdir"/_build/lib ninja check
+ ninja check-clang
+ ninja check-polly
+ ninja check-lld
+ ninja check-lldb
+}
+
+package_llvm-git() {
+ pkgdesc="LLVM development version. includes clang and many other tools"
+ depends=('llvm-libs-git' 'perl')
+ optdepends=( 'python: for scripts'
+ 'python-setuptools: for using lit (LLVM Integrated Tester)'
+ 'ocaml: for ocaml support')
+ # yes, I know polly is not in official repos
+ provides=('llvm' 'compiler-rt' 'clang' 'lld' 'lldb' 'polly' 'llvm-ocaml')
+ conflicts=('llvm' 'compiler-rt' 'clang' 'lld' 'lldb' 'polly' 'llvm-ocaml')
+
+ pushd _build
+
+ DESTDIR="$pkgdir" ninja install
+
+ popd
+ # Clean up conflicting files
+ # TODO: This should probably be discussed with upstream.
+ rm -rf "${pkgdir}/usr/lib/python3.7/site-packages/six.py"
+ # Include lit for running lit-based tests in other projects
+ pushd llvm-project/llvm/utils/lit
+ python setup.py install --root="$pkgdir" -O1
+ popd
+
+
+ # Move analyzer scripts out of /usr/libexec
+ mv "$pkgdir"/usr/libexec/{ccc,c++}-analyzer "$pkgdir"/usr/lib/clang/
+ rmdir "$pkgdir"/usr/libexec
+ sed -i 's|libexec|lib/clang|' "$pkgdir"/usr/bin/scan-build
+
+ # The runtime libraries go into llvm-libs
+ mv -f "$pkgdir"/usr/lib/lib{LLVM,LTO}*.so* "$srcdir"
+ mv -f "$pkgdir"/usr/lib/LLVMgold.so "$srcdir"
+
+ if [[ $CARCH == x86_64 ]]; then
+ # Needed for multilib (https://bugs.archlinux.org/task/29951)
+ # Header stub is taken from Fedora
+ mv "$pkgdir"/usr/include/llvm/Config/llvm-config{,-64}.h
+ cp "$srcdir"/llvm-config.h "$pkgdir"/usr/include/llvm/Config/llvm-config.h
+ fi
+
+ cd llvm-project/llvm
+ # Install Python bindings and optimize them
+ cp -a bindings/python/llvm "$pkgdir"/usr/lib/python3.7/site-packages/
+ cp -a tools/clang/bindings/python/clang "$pkgdir"/usr/lib/python3.7/site-packages/
+ _python_optimize "$pkgdir"/usr/lib/python3.7/site-packages
+
+ #optimize other python files except 2 problem cases
+ _python_optimize "$pkgdir"/usr/share -x 'clang-include-fixer|run-find-all-symbols'
+
+ install -Dm644 LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/llvm-LICENSE
+ install -Dm644 tools/clang/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/clang-LICENSE
+ install -Dm644 tools/clang/tools/extra/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/clang-tools-extra-LICENSE
+ install -Dm644 projects/compiler-rt/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/compiler-rt-LICENSE
+ install -Dm644 tools/lld/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/lld-LICENSE
+ install -Dm644 tools/lldb/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/lldb-LICENSE
+ install -Dm644 tools/polly/LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/polly-LICENSE
}
-#
-# BEGIN INTERNAL VARIABLES AND FUNCTIONS
-#
-
-# Install the license files for a package
-# Arguments: source_directory_to_install_from
-# Notes: We prune some directories that are inserted into the tree in prepare()
-# in order to eliminate possible duplicates. We also use NULL-terminated
-# strings, just in case we have paths including spaces. Finally, we opt
-# for a flat directory structure, so all license files in subdirectories
-# get their names from the relative path with '/'s replaced by dashes.
-# Not the most elegant solution, but should be working well enough.
-_install_licenses() {
- find "${1}" \
- \( \
- -path "${srcdir}/${_pkgname}/tools/lld" -o \
- -path "${srcdir}/${_pkgname}/tools/clang" -o \
- -path "${srcdir}/${_pkgname}/tools/lldb" -o \
- -path "${srcdir}/${_pkgname}/projects/compiler-rt" \
- \) -prune -o \
- \( \
- -iname 'license*' -o \
- -iname 'credits*' -o \
- -iname 'copyright*' \
- \) -printf '%P\0' \
- | while read -d $'\0' license_file; do
- install -D -m 0644 \
- "${1}/${license_file}" \
- "${pkgdir}/usr/share/licenses/${pkgname}/${license_file//\//-}"
- done
+package_llvm-libs-git() {
+ pkgdesc="runtime libraries for llvm-git"
+ depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2')
+ provides=('llvm-libs')
+
+ install -d "$pkgdir"/usr/lib
+ cp -P \
+ "$srcdir"/lib{LLVM,LTO}*.so* \
+ "$srcdir"/LLVMgold.so \
+ "$pkgdir"/usr/lib/
+
+ # Symlink LLVMgold.so from /usr/lib/bfd-plugins
+ # https://bugs.archlinux.org/task/28479
+ install -d "$pkgdir"/usr/lib/bfd-plugins
+ ln -s ../LLVMgold.so "$pkgdir"/usr/lib/bfd-plugins/LLVMgold.so
+
+ cd llvm-project/llvm
+ install -Dm644 LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/llvm-LICENSE
+ install -Dm644 tools/clang/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/clang-LICENSE
+ install -Dm644 tools/clang/tools/extra/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/clang-tools-extra-LICENSE
+ install -Dm644 projects/compiler-rt/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/compiler-rt-LICENSE
+ install -Dm644 tools/lld/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/lld-LICENSE
+ install -Dm644 tools/lldb/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/lldb-LICENSE
+ install -Dm644 tools/polly/LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/polly-LICENSE
}
-#
-# END INTERNAL VARIABLES AND FUNCTIONS
-#
+# vim:set ts=2 sw=2 et:
diff --git a/enable-SSP-and-PIE-by-default.patch b/enable-SSP-and-PIE-by-default.patch
new file mode 100644
index 000000000000..2c8bd20f5dee
--- /dev/null
+++ b/enable-SSP-and-PIE-by-default.patch
@@ -0,0 +1,289 @@
+From a076711d030ca5777465dab9f11c0639478a5cc8 Mon Sep 17 00:00:00 2001
+From: Evangelos Foutras <evangelos@foutrelis.com>
+Date: Tue, 26 Mar 2019 01:35:50 +0200
+Subject: [PATCH] Enable SSP and PIE by default
+
+This is a minimal set of changes needed to make clang use SSP and PIE by
+default on Arch Linux. Tests that were easy to adjust have been changed
+accordingly; only test/Driver/linux-ld.c has been marked as "expected
+failure" due to the number of changes it would require (mostly replacing
+crtbegin.o with crtbeginS.o).
+
+Doing so is needed in order to align clang with the new default GCC
+behavior in Arch which generates PIE executables by default and also
+defaults to -fstack-protector-strong. It is not meant to be a long term
+solution, but a simple temporary fix.
+
+Hopefully these changes will be obsoleted by the introduction upstream
+of a compile-time option (https://bugs.llvm.org/show_bug.cgi?id=13410)
+---
+ lib/Driver/ToolChains/Linux.cpp | 14 ++++++++++++--
+ lib/Driver/ToolChains/Linux.h | 1 +
+ test/Driver/cross-linux.c | 16 ++++++++--------
+ test/Driver/env.c | 2 +-
+ test/Driver/fsanitize.c | 14 +++++++-------
+ test/Driver/gcc-toolchain.cpp | 2 +-
+ test/Driver/hexagon-toolchain-elf.c | 2 +-
+ test/Driver/linux-as.c | 4 ++--
+ test/Driver/linux-ld.c | 2 ++
+ test/Driver/ppc-abi.c | 4 ++--
+ test/Driver/riscv32-toolchain.c | 4 ++--
+ test/Driver/stack-protector.c | 4 ++--
+ 12 files changed, 41 insertions(+), 28 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp
+index 65ab9b2daf..5b757b8028 100644
+--- a/lib/Driver/ToolChains/Linux.cpp
++++ b/lib/Driver/ToolChains/Linux.cpp
+@@ -968,8 +968,18 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
+ }
+
+ bool Linux::isPIEDefault() const {
+- return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
+- getTriple().isMusl() || getSanitizerArgs().requiresPIE();
++ const bool IsMips = getTriple().isMIPS();
++ const bool IsAndroid = getTriple().isAndroid();
++
++ if (IsMips || IsAndroid)
++ return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
++ getTriple().isMusl() || getSanitizerArgs().requiresPIE();
++
++ return true;
++}
++
++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const {
++ return 2;
+ }
+
+ bool Linux::IsMathErrnoDefault() const {
+diff --git a/lib/Driver/ToolChains/Linux.h b/lib/Driver/ToolChains/Linux.h
+index 4a662cb4b4..4f369c6090 100644
+--- a/lib/Driver/ToolChains/Linux.h
++++ b/lib/Driver/ToolChains/Linux.h
+@@ -40,6 +40,7 @@ public:
+ CXXStdlibType GetDefaultCXXStdlibType() const override;
+ bool isPIEDefault() const override;
+ bool IsMathErrnoDefault() const override;
++ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override;
+ SanitizerMask getSupportedSanitizers() const override;
+ void addProfileRTLibs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const override;
+diff --git a/test/Driver/cross-linux.c b/test/Driver/cross-linux.c
+index a5ea832e77..1949c05a60 100644
+--- a/test/Driver/cross-linux.c
++++ b/test/Driver/cross-linux.c
+@@ -42,8 +42,8 @@
+ // CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI32-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI32-I386: "-m" "elf_i386"
+-// CHECK-MULTI32-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI32-I386: "-L[[gcc_install]]"
++// CHECK-MULTI32-I386: "crti.o" "crtbeginS.o"
++// CHECK-MULTI32-I386: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]"
+ // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib32"
+ // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
+ // CHECK-MULTI32-I386: "-L[[sysroot]]/lib"
+@@ -59,8 +59,8 @@
+ // CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI32-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI32-X86-64: "-m" "elf_x86_64"
+-// CHECK-MULTI32-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI32-X86-64: "-L[[gcc_install]]/64"
++// CHECK-MULTI32-X86-64: "crti.o" "crtbeginS.o"
++// CHECK-MULTI32-X86-64: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64"
+ // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib64"
+ // CHECK-MULTI32-X86-64: "-L[[gcc_install]]"
+ // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
+@@ -77,8 +77,8 @@
+ // CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI64-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI64-I386: "-m" "elf_i386"
+-// CHECK-MULTI64-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]/32{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI64-I386: "-L[[gcc_install]]/32"
++// CHECK-MULTI64-I386: "crti.o" "crtbeginS.o"
++// CHECK-MULTI64-I386: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]/32"
+ // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib32"
+ // CHECK-MULTI64-I386: "-L[[gcc_install]]"
+ // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
+@@ -95,8 +95,8 @@
+ // CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI64-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI64-X86-64: "-m" "elf_x86_64"
+-// CHECK-MULTI64-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI64-X86-64: "-L[[gcc_install]]"
++// CHECK-MULTI64-X86-64: "crti.o" "crtbeginS.o"
++// CHECK-MULTI64-X86-64: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]"
+ // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib64"
+ // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
+ // CHECK-MULTI64-X86-64: "-L[[sysroot]]/lib"
+diff --git a/test/Driver/env.c b/test/Driver/env.c
+index 0371bc91c4..ea89f52512 100644
+--- a/test/Driver/env.c
++++ b/test/Driver/env.c
+@@ -20,7 +20,7 @@
+ //
+ // CHECK-LD-32-NOT: warning:
+ // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+-// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0{{/|\\\\}}crtbegin.o"
++// CHECK-LD-32: "crtbeginS.o"
+ // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
+ // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
+ // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
+diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c
+index db88872399..76af9bd8fe 100644
+--- a/test/Driver/fsanitize.c
++++ b/test/Driver/fsanitize.c
+@@ -331,15 +331,15 @@
+ // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
+ // OK
+
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target x86_64-unknown-freebsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target aarch64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-NO-PIE
+ // RUN: %clang -target arm-linux-androideabi24 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target aarch64-linux-android -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
+-// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
++// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+
+ // CHECK-NO-PIE-NOT: "-pie"
+ // CHECK-NO-PIE: "-mrelocation-model" "static"
+@@ -687,12 +687,12 @@
+ // RUN: %clang -fno-sanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NOSP
+ // NOSP-NOT: "-fsanitize=safe-stack"
+
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
+ // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP-ASAN
+ // RUN: %clang -target x86_64-linux-gnu -fstack-protector -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
+ // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SP
+-// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
+-// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
++// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
++// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
+ // RUN: %clang -target i386-contiki-unknown -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
+ // NO-SP-NOT: stack-protector
+ // NO-SP: "-fsanitize=safe-stack"
+diff --git a/test/Driver/gcc-toolchain.cpp b/test/Driver/gcc-toolchain.cpp
+index ca96757a2b..ae1c25e989 100644
+--- a/test/Driver/gcc-toolchain.cpp
++++ b/test/Driver/gcc-toolchain.cpp
+@@ -24,6 +24,6 @@
+ // the same precise formatting of the path as the '-internal-system' flags
+ // above, so we just blanket wildcard match the 'crtbegin.o'.
+ // CHECK: "{{[^"]*}}ld{{(.exe)?}}"
+-// CHECK: "{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5{{/|\\\\}}crtbegin.o"
++// CHECK: "crtbeginS.o"
+ // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+ // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+diff --git a/test/Driver/hexagon-toolchain-elf.c b/test/Driver/hexagon-toolchain-elf.c
+index a7eeca0fdb..32f648372e 100644
+--- a/test/Driver/hexagon-toolchain-elf.c
++++ b/test/Driver/hexagon-toolchain-elf.c
+@@ -457,7 +457,7 @@
+ // RUN: %s 2>&1 \
+ // RUN: | FileCheck -check-prefix=CHECK042 %s
+ // CHECK042: "-cc1"
+-// CHECK042: "-mrelocation-model" "static"
++// CHECK042: "-mrelocation-model" "pic"
+ // CHECK042: "-mllvm" "-hexagon-small-data-threshold=8"
+ // CHECK042-NEXT: llvm-mc
+ // CHECK042: "-gpsize=8"
+diff --git a/test/Driver/linux-as.c b/test/Driver/linux-as.c
+index a9335ebf71..a72041865b 100644
+--- a/test/Driver/linux-as.c
++++ b/test/Driver/linux-as.c
+@@ -164,7 +164,7 @@
+ // CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu"
+ //
+ // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
+-// RUN: -no-integrated-as -c %s 2>&1 \
++// RUN: -no-integrated-as -fno-pic -c %s 2>&1 \
+ // RUN: | FileCheck -check-prefix=CHECK-SPARCV9 %s
+ // CHECK-SPARCV9: as
+ // CHECK-SPARCV9: -64
+@@ -173,7 +173,7 @@
+ // CHECK-SPARCV9: -o
+ //
+ // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
+-// RUN: -no-integrated-as -fpic -c %s 2>&1 \
++// RUN: -no-integrated-as -c %s 2>&1 \
+ // RUN: | FileCheck -check-prefix=CHECK-SPARCV9PIC %s
+ // CHECK-SPARCV9PIC: as
+ // CHECK-SPARCV9PIC: -64
+diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
+index 3ab81be490..fd6b67dd9a 100644
+--- a/test/Driver/linux-ld.c
++++ b/test/Driver/linux-ld.c
+@@ -1,3 +1,5 @@
++// XFAIL: linux
++
+ // General tests that ld invocations on Linux targets sane. Note that we use
+ // sysroot to make these tests independent of the host system.
+ //
+diff --git a/test/Driver/ppc-abi.c b/test/Driver/ppc-abi.c
+index a82a01de27..35de94a4ad 100644
+--- a/test/Driver/ppc-abi.c
++++ b/test/Driver/ppc-abi.c
+@@ -26,11 +26,11 @@
+
+ // CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
+ // CHECK-ELFv1: "-target-abi" "elfv1"
+-// CHECK-ELFv1-LE: "-mrelocation-model" "static"
++// CHECK-ELFv1-LE: "-mrelocation-model" "pic" "-pic-level" "2"
+ // CHECK-ELFv1-LE: "-target-abi" "elfv1"
+ // CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
+ // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
+-// CHECK-ELFv2: "-mrelocation-model" "static"
++// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
+ // CHECK-ELFv2: "-target-abi" "elfv2"
+ // CHECK-ELFv2-BE: "-mrelocation-model" "pic" "-pic-level" "2"
+ // CHECK-ELFv2-BE: "-target-abi" "elfv2"
+diff --git a/test/Driver/riscv32-toolchain.c b/test/Driver/riscv32-toolchain.c
+index 9e8af3a8ff..171392d172 100644
+--- a/test/Driver/riscv32-toolchain.c
++++ b/test/Driver/riscv32-toolchain.c
+@@ -78,7 +78,7 @@
+ // C-RV32-LINUX-MULTI-ILP32: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
+ // C-RV32-LINUX-MULTI-ILP32: "-m" "elf32lriscv"
+ // C-RV32-LINUX-MULTI-ILP32: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32.so.1"
+-// C-RV32-LINUX-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32{{/|\\\\}}crtbegin.o"
++// C-RV32-LINUX-MULTI-ILP32: "crtbeginS.o"
+ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32"
+ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32"
+ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
+@@ -94,7 +94,7 @@
+ // C-RV32-LINUX-MULTI-ILP32D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
+ // C-RV32-LINUX-MULTI-ILP32D: "-m" "elf32lriscv"
+ // C-RV32-LINUX-MULTI-ILP32D: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32d.so.1"
+-// C-RV32-LINUX-MULTI-ILP32D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d{{/|\\\\}}crtbegin.o"
++// C-RV32-LINUX-MULTI-ILP32D: "crtbeginS.o"
+ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d"
+ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32d"
+ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32d"
+diff --git a/test/Driver/stack-protector.c b/test/Driver/stack-protector.c
+index a3e40b50ee..dfffe0d6cf 100644
+--- a/test/Driver/stack-protector.c
++++ b/test/Driver/stack-protector.c
+@@ -3,11 +3,11 @@
+ // NOSSP-NOT: "-stack-protector-buffer-size"
+
+ // RUN: %clang -target i386-unknown-linux -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP
+-// SSP: "-stack-protector" "1"
++// SSP: "-stack-protector" "2"
+ // SSP-NOT: "-stack-protector-buffer-size"
+
+ // RUN: %clang -target i386-unknown-linux -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-BUF
+-// SSP-BUF: "-stack-protector" "1"
++// SSP-BUF: "-stack-protector" "2"
+ // SSP-BUF: "-stack-protector-buffer-size" "16"
+
+ // RUN: %clang -target i386-pc-openbsd -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD
+--
+2.21.0
+
diff --git a/llvm-config.h b/llvm-config.h
index 1edc183c8061..2fa08c9be696 100644
--- a/llvm-config.h
+++ b/llvm-config.h
@@ -6,4 +6,4 @@
#include "llvm-config-64.h"
#else
#error "Unknown word size"
-#endif \ No newline at end of file
+#endif