diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2018-03-07 15:21:48 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2018-03-07 15:21:48 -0600 |
commit | 7442499990b44130ad9de911808161177b214322 (patch) | |
tree | e0f9588b2552682e1176322fe19b6d15b67e9c47 | |
parent | 00f714f7a538159c8a821e1872c1d39d75cbf144 (diff) | |
download | packages-7442499990b44130ad9de911808161177b214322.tar.gz packages-7442499990b44130ad9de911808161177b214322.tar.bz2 packages-7442499990b44130ad9de911808161177b214322.tar.xz packages-7442499990b44130ad9de911808161177b214322.zip |
system/clang: yay, a non-GCC compiler
8 files changed, 416 insertions, 0 deletions
diff --git a/system/clang/APKBUILD b/system/clang/APKBUILD new file mode 100644 index 000000000..d23bb3675 --- /dev/null +++ b/system/clang/APKBUILD @@ -0,0 +1,103 @@ +# Contributor Travis Tilley <ttilley@gmail.com> +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> +pkgname=clang +# Note: Update together with llvm. +pkgver=4.0.0 +pkgrel=0 +_llvmver=${pkgver%%.*} +pkgdesc="A C language family front-end for LLVM" +arch="all" +url="http://llvm.org/" +license="UOI-NCSA" +makedepends=" + cmake + isl-dev + libedit-dev + libxml2-dev + libxml2-utils + llvm-dev>=$_llvmver + llvm-static>=$_llvmver + llvm-test-utils>=$_llvmver + " +depends_dev="$pkgname=$pkgver-r$pkgrel" +subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs + $pkgname-analyzer::noarch" +source="https://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.xz + clang-0001-Add-Alpine-Linux-distro.patch + clang-0002-Use-z-relro-on-Alpine-Linux.patch + clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch + clang-0004-Add-musl-targets.patch + clang-0005-Enable-PIE-by-default-for-alpine-linux.patch + clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch + clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch + " +builddir="$srcdir/cfe-$pkgver.src" + +build() { + mkdir -p "$builddir"/build + cd "$builddir"/build + + cmake .. -Wno-dev \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_VERBOSE_MAKEFILE=OFF \ + \ + -DCLANG_VENDOR=${DISTRO_SHORT_NAME:-Alpine} \ + -DCLANG_BUILD_EXAMPLES=OFF \ + -DCLANG_INCLUDE_DOCS=ON \ + -DCLANG_INCLUDE_TESTS=ON \ + -DCLANG_PLUGIN_SUPPORT=ON \ + -DLIBCLANG_BUILD_STATIC=ON \ + -DLLVM_ENABLE_EH=ON \ + -DLLVM_ENABLE_RTTI=ON + + make clang-tblgen + make +} + +check() { + cd "$builddir"/build + + make check-clang +} + +package() { + cd "$builddir"/build + + make DESTDIR="$pkgdir" install + install -m 644 lib/libclang.a "$pkgdir"/usr/lib + mkdir -p "$pkgdir"/etc + cat >"$pkgdir"/etc/alpine-release <<-EOF +Adélie Linux 1.0 (like Alpine 3.8) +EOF +} + +static() { + pkgdesc="Static libraries for clang" + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/ +} + +analyzer() { + pkgdesc="Clang source code analysis framework" + depends="$pkgname=$pkgver-r$pkgrel perl python3" + + cd "$pkgdir" + + mkdir -p "$subpkgdir"/usr/bin \ + "$subpkgdir"/usr/libexec \ + "$subpkgdir"/usr/share/ + mv usr/bin/scan-* "$subpkgdir"/usr/bin/ + mv usr/libexec/*-analyzer "$subpkgdir"/usr/libexec/ + mv usr/share/scan-* "$subpkgdir"/usr/share/ +} + +sha512sums="a0d9972ec337a5c105fcbe7abc4076ba1e580f28908a3318f43bbfe59143f446ed5b78dad210f624145d7e5a3d56c15bfead78826c068422b60120fa1cfa482a cfe-4.0.0.src.tar.xz +4014984a187e4d0331d8315727d1b831e573843cd8d113df43424524cb348bc73ce3d12783351d9a14f9fd14111d75ce71d8f2a85d82b6437a61b11d85796cfb clang-0001-Add-Alpine-Linux-distro.patch +53741890ec3805dd0d5a930ed526cb5bac5f75c459c6910c9461017719186383cf54638af4eea7a38eb7f9f423b18086bd5584b11f7e4babf6cd0edf8b4f4f48 clang-0002-Use-z-relro-on-Alpine-Linux.patch +f06e351785d5755827459f17d3533415772ba84b4fbd4e49f418bafd20394e98d42b33a94aa34cff2a7b54c79cf06a6f5d382af5a55cba63a81116f0568d4b25 clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch +2998ab2dfbc3d5629dd7e65e7e39dc0ab96f61e24733cb8d2d4faee50a89f0f159ad44d10182ed4c96f060180f4e22510881f4e9eb00ced01278bde99adf3389 clang-0004-Add-musl-targets.patch +6215080a796fa1fc6f7634781ef77fc245037880dbf075a656823aae5f9f4911294dc6d61172db399b063adbe445c38b73cec12fc66dbe16bd9d84dc58035846 clang-0005-Enable-PIE-by-default-for-alpine-linux.patch +d151a6ecca470abb1f4dbc06910155db0688322475655e28cdcb9c0b21930c8bcaf166e9df9fc9dca1be654cf497587961e461d91ee2871fdf454bbd33c5fffe clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch +f8c46bb64202c9233595362eb54288c30fbd28309308cbcafe1802dc50ffd676c7a70e6cbdbfd73464f872b40a90acd2eb736dcc9622fd434dbd44a5b0005027 clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch" diff --git a/system/clang/clang-0001-Add-Alpine-Linux-distro.patch b/system/clang/clang-0001-Add-Alpine-Linux-distro.patch new file mode 100644 index 000000000..f69baf5b8 --- /dev/null +++ b/system/clang/clang-0001-Add-Alpine-Linux-distro.patch @@ -0,0 +1,37 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Add Alpine Linux distro + +--- a/include/clang/Driver/Distro.h ++++ b/include/clang/Driver/Distro.h +@@ -26,6 +26,7 @@ + // NB: Releases of a particular Linux distro should be kept together + // in this enum, because some tests are done by integer comparison against + // the first and last known member in the family, e.g. IsRedHat(). ++ AlpineLinux, + ArchLinux, + DebianLenny, + DebianSqueeze, +@@ -97,6 +98,10 @@ + /// @name Convenience Predicates + /// @{ + ++ bool IsAlpineLinux() const { ++ return DistroVal == AlpineLinux; ++ } ++ + bool IsRedhat() const { + return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7); + } +--- a/lib/Driver/Distro.cpp ++++ b/lib/Driver/Distro.cpp +@@ -128,6 +128,9 @@ + if (VFS.exists("/etc/arch-release")) + return Distro::ArchLinux; + ++ if (VFS.exists("/etc/alpine-release")) ++ return Distro::AlpineLinux; ++ + return Distro::UnknownDistro; + } diff --git a/system/clang/clang-0002-Use-z-relro-on-Alpine-Linux.patch b/system/clang/clang-0002-Use-z-relro-on-Alpine-Linux.patch new file mode 100644 index 000000000..45fce6e13 --- /dev/null +++ b/system/clang/clang-0002-Use-z-relro-on-Alpine-Linux.patch @@ -0,0 +1,16 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Use "-z relro" on Alpine Linux + +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4112,7 +4112,7 @@ + + Distro Distro(D.getVFS()); + +- if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) { ++ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) { + ExtraOpts.push_back("-z"); + ExtraOpts.push_back("relro"); + } diff --git a/system/clang/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch b/system/clang/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch new file mode 100644 index 000000000..0b6632328 --- /dev/null +++ b/system/clang/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch @@ -0,0 +1,16 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Use --hash-style=gnu for Alpine Linux + +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4132,7 +4132,7 @@ + // ABI requires a mapping between the GOT and the symbol table. + // Android loader does not support .gnu.hash. + if (!IsMips && !IsAndroid) { +- if (Distro.IsRedhat() || Distro.IsOpenSUSE() || ++ if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() || + (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick)) + ExtraOpts.push_back("--hash-style=gnu"); + diff --git a/system/clang/clang-0004-Add-musl-targets.patch b/system/clang/clang-0004-Add-musl-targets.patch new file mode 100644 index 000000000..d77294980 --- /dev/null +++ b/system/clang/clang-0004-Add-musl-targets.patch @@ -0,0 +1,116 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Add musl targets + +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -1644,7 +1644,8 @@ + case llvm::Triple::arm: + case llvm::Triple::thumb: + LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); +- if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { ++ if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); + } else { + TripleAliases.append(begin(ARMTriples), end(ARMTriples)); +@@ -1653,7 +1654,8 @@ + case llvm::Triple::armeb: + case llvm::Triple::thumbeb: + LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs)); +- if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { ++ if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples)); + } else { + TripleAliases.append(begin(ARMebTriples), end(ARMebTriples)); +@@ -3956,7 +3958,8 @@ + // regardless of what the actual target triple is. + case llvm::Triple::arm: + case llvm::Triple::thumb: +- if (TargetEnvironment == llvm::Triple::GNUEABIHF) { ++ if (TargetEnvironment == llvm::Triple::GNUEABIHF || ++ TargetEnvironment == llvm::Triple::MuslEABIHF) { + if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf")) + return "arm-linux-gnueabihf"; + } else { +@@ -3966,7 +3969,8 @@ + break; + case llvm::Triple::armeb: + case llvm::Triple::thumbeb: +- if (TargetEnvironment == llvm::Triple::GNUEABIHF) { ++ if (TargetEnvironment == llvm::Triple::GNUEABIHF || ++ TargetEnvironment == llvm::Triple::MuslEABIHF) { + if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabihf")) + return "armeb-linux-gnueabihf"; + } else { +@@ -4334,6 +4338,12 @@ + ArchName = "armeb"; + IsArm = true; + break; ++ case llvm::Triple::ppc: ++ ArchName = "powerpc"; ++ break; ++ case llvm::Triple::x86: ++ ArchName = "i386"; ++ break; + default: + ArchName = Triple.getArchName().str(); + } +@@ -4544,7 +4554,8 @@ + break; + case llvm::Triple::arm: + case llvm::Triple::thumb: +- if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF) ++ if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF || ++ getTriple().getEnvironment() == llvm::Triple::MuslEABIHF) + MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs; + else + MultiarchIncludeDirs = ARMMultiarchIncludeDirs; + +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -953,6 +953,7 @@ + case llvm::Triple::FreeBSD: + switch (Triple.getEnvironment()) { + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + ABI = FloatABI::Hard; + break; + default: +@@ -9198,6 +9200,8 @@ + switch (getToolChain().getTriple().getEnvironment()) { + case llvm::Triple::GNUEABIHF: + case llvm::Triple::GNUEABI: ++ case llvm::Triple::MuslEABIHF: ++ case llvm::Triple::MuslEABI: + case llvm::Triple::EABI: + CmdArgs.push_back("-meabi=5"); + break; +@@ -9541,10 +9545,12 @@ + switch (getToolChain().getTriple().getEnvironment()) { + case llvm::Triple::EABI: + case llvm::Triple::GNUEABI: ++ case llvm::Triple::MuslEABI: + CmdArgs.push_back("armelf_nbsd_eabi"); + break; + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + CmdArgs.push_back("armelf_nbsd_eabihf"); + break; + default: +@@ -9559,10 +9565,12 @@ + switch (getToolChain().getTriple().getEnvironment()) { + case llvm::Triple::EABI: + case llvm::Triple::GNUEABI: ++ case llvm::Triple::MuslEABI: + CmdArgs.push_back("armelfb_nbsd_eabi"); + break; + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + CmdArgs.push_back("armelfb_nbsd_eabihf"); + break; + default: diff --git a/system/clang/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch b/system/clang/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch new file mode 100644 index 000000000..7cd79addc --- /dev/null +++ b/system/clang/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch @@ -0,0 +1,55 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Enable PIE by default for Alpine Linux + +Alpine Linux uses PIE by default. + +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4721,7 +4721,10 @@ + } + } + +-bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); } ++bool Linux::isPIEDefault() const { ++ return getSanitizerArgs().requiresPIE() || ++ Linux::getTriple().getVendorName().compare("alpine") == 0; ++} + + SanitizerMask Linux::getSupportedSanitizers() const { + const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -9258,7 +9258,9 @@ + if (!D.SysRoot.empty()) + CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); + +- if (IsPIE) ++ if (Args.hasArg(options::OPT_nopie)) ++ CmdArgs.push_back("-nopie"); ++ else if (IsPIE) + CmdArgs.push_back("-pie"); + + CmdArgs.push_back("--eh-frame-hdr"); +--- a/test/Driver/pic.c ++++ b/test/Driver/pic.c +@@ -244,6 +244,18 @@ + // RUN: %clang %s -target i386-pc-openbsd -nopie -### 2>&1 \ + // RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD + // ++// On Alpine Linux, we want similar PIE-by-default behavior ++// RUN: %clang -c %s -target x86_64-alpine-linux-musl -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang -c %s -target i686-alpine-linux-musl -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang -c %s -target armv6-alpine-linux-musleabihf -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang -c %s -target armv7-alpine-linux-musleabihf -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang %s -target x86_64-alpine-linux-musl -nopie -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD ++// + // On Android PIC is enabled by default + // RUN: %clang -c %s -target i686-linux-android -### 2>&1 \ + // RUN: | FileCheck %s --check-prefix=CHECK-PIC2 diff --git a/system/clang/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch b/system/clang/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch new file mode 100644 index 000000000..90de948f6 --- /dev/null +++ b/system/clang/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch @@ -0,0 +1,19 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Link with -z now by default for Alpine Linux + +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4116,6 +4116,11 @@ + + Distro Distro(D.getVFS()); + ++ if (Distro.IsAlpineLinux()) { ++ ExtraOpts.push_back("-z"); ++ ExtraOpts.push_back("now"); ++ } ++ + if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) { + ExtraOpts.push_back("-z"); + ExtraOpts.push_back("relro"); diff --git a/system/clang/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch b/system/clang/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch new file mode 100644 index 000000000..3487799b1 --- /dev/null +++ b/system/clang/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch @@ -0,0 +1,54 @@ +From: Natanael Copa <ncopa@alpinelinux.org> +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH] Enable stack protector by default for Alpine Linux + +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4866,6 +4866,13 @@ + CmdArgs.push_back("-lunwind"); + } + ++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { ++ StringRef VendorName = Linux::getTriple().getVendorName(); ++ if (VendorName.compare("alpine") == 0) ++ return 2; ++ return 1; ++} ++ + /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. + + DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple, +--- a/lib/Driver/ToolChains.h ++++ b/lib/Driver/ToolChains.h +@@ -880,6 +880,7 @@ + void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; + bool isPIEDefault() 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; +--- a/test/Driver/stack-protector.c ++++ b/test/Driver/stack-protector.c +@@ -24,6 +24,20 @@ + // SSP-ALL: "-stack-protector" "3" + // SSP-ALL-NOT: "-stack-protector-buffer-size" + ++// RUN: %clang -target x86_64-alpine-linux-musl -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE ++// ALPINE: "-stack-protector" "2" ++ ++// RUN: %clang -target x86_64-alpine-linux-musl -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_SPS ++// ALPINE_SPS: "-stack-protector" "2" ++ ++// RUN: %clang -target x86_64-alpine-linux-musl -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_ALL ++// ALPINE_ALL: "-stack-protector" "3" ++// ALPINE_ALL-NOT: "-stack-protector-buffer-size" ++ ++// RUN: %clang -target x86_64-alpine-linux-musl -fno-stack-protector -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_NOSSP ++// ALPINE_NOSSP-NOT: "-stack-protector" ++// ALPINE_NOSSP-NOT: "-stack-protector-buffer-size" ++ + // RUN: %clang -target x86_64-scei-ps4 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4 + // RUN: %clang -target x86_64-scei-ps4 -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4 + // SSP-PS4: "-stack-protector" "2" |