diff options
author | xentec <xentec@aix0.eu> | 2017-10-23 18:27:32 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2017-11-14 18:42:44 +0100 |
commit | 60c32c79a11ee7715f20aeebd381299120c43eb0 (patch) | |
tree | 22de0e87cb31a859622fce93eec1afca6440a348 /main/clang | |
parent | b4767fa4037857bb3393650e351e69d16a5d7e56 (diff) | |
download | aports-60c32c79a11ee7715f20aeebd381299120c43eb0.tar.bz2 aports-60c32c79a11ee7715f20aeebd381299120c43eb0.tar.xz |
main/clang: upgrade to 5.0.0
Diffstat (limited to 'main/clang')
12 files changed, 292 insertions, 218 deletions
diff --git a/main/clang/clang-0001-Add-Alpine-Linux-distro.patch b/main/clang/0001-Add-Alpine-Linux-distro.patch index f69baf5b83..59e292f62e 100644 --- a/main/clang/clang-0001-Add-Alpine-Linux-distro.patch +++ b/main/clang/0001-Add-Alpine-Linux-distro.patch @@ -1,11 +1,18 @@ -From: Natanael Copa <ncopa@alpinelinux.org> +From 73460524593da572f34f2994a75d1d946613e54a Mon Sep 17 00:00:00 2001 From: Jakub Jirutka <jakub@jirutka.cz> Date: Sun, 16 Apr 2017 16:49:00 +0100 -Subject: [PATCH] Add Alpine Linux distro +Subject: [PATCH 1/7] Add Alpine Linux distro +--- + include/clang/Driver/Distro.h | 5 +++++ + lib/Driver/Distro.cpp | 3 +++ + 2 files changed, 8 insertions(+) + +diff --git a/include/clang/Driver/Distro.h b/include/clang/Driver/Distro.h +index fab4986..17775bf 100644 --- a/include/clang/Driver/Distro.h +++ b/include/clang/Driver/Distro.h -@@ -26,6 +26,7 @@ +@@ -26,6 +26,7 @@ public: // 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(). @@ -13,7 +20,7 @@ Subject: [PATCH] Add Alpine Linux distro ArchLinux, DebianLenny, DebianSqueeze, -@@ -97,6 +98,10 @@ +@@ -98,6 +99,10 @@ public: /// @name Convenience Predicates /// @{ @@ -24,9 +31,11 @@ Subject: [PATCH] Add Alpine Linux distro bool IsRedhat() const { return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7); } +diff --git a/lib/Driver/Distro.cpp b/lib/Driver/Distro.cpp +index 2df297f..4cf2c2e 100644 --- a/lib/Driver/Distro.cpp +++ b/lib/Driver/Distro.cpp -@@ -128,6 +128,9 @@ +@@ -129,6 +129,9 @@ static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) { if (VFS.exists("/etc/arch-release")) return Distro::ArchLinux; @@ -35,3 +44,7 @@ Subject: [PATCH] Add Alpine Linux distro + return Distro::UnknownDistro; } + +-- +2.14.1 + diff --git a/main/clang/0002-Use-z-relro-on-Alpine-Linux.patch b/main/clang/0002-Use-z-relro-on-Alpine-Linux.patch new file mode 100644 index 0000000000..5b176ac2c0 --- /dev/null +++ b/main/clang/0002-Use-z-relro-on-Alpine-Linux.patch @@ -0,0 +1,25 @@ +From 00ca60386046258f55b11313e9e63e6551698ee0 Mon Sep 17 00:00:00 2001 +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH 2/7] Use "-z relro" on Alpine Linux + +--- + lib/Driver/ToolChains/Linux.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 08a27fa..9dbf9bd 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -210,7 +210,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + + Distro Distro(D.getVFS()); + +- if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) { ++ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) { + ExtraOpts.push_back("-z"); + ExtraOpts.push_back("relro"); + } +-- +2.14.1 + diff --git a/main/clang/0003-Use-hash-style-gnu-for-Alpine-Linux.patch b/main/clang/0003-Use-hash-style-gnu-for-Alpine-Linux.patch new file mode 100644 index 0000000000..542fefcd20 --- /dev/null +++ b/main/clang/0003-Use-hash-style-gnu-for-Alpine-Linux.patch @@ -0,0 +1,25 @@ +From 54f4c1daac9e4489b48c477758217cd01c6c8f0a Mon Sep 17 00:00:00 2001 +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH 3/7] Use --hash-style=gnu for Alpine Linux + +--- + lib/Driver/ToolChains/Linux.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 9dbf9bd..1201df6 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -232,7 +232,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // Android loader does not support .gnu.hash. + // Hexagon linker/loader does not support .gnu.hash + if (!IsMips && !IsAndroid && !IsHexagon) { +- if (Distro.IsRedhat() || Distro.IsOpenSUSE() || ++ if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() || + (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick)) + ExtraOpts.push_back("--hash-style=gnu"); + +-- +2.14.1 + diff --git a/main/clang/clang-0004-Add-musl-targets.patch b/main/clang/0004-Add-musl-targets.patch index d77294980e..303d1bc2b8 100644 --- a/main/clang/clang-0004-Add-musl-targets.patch +++ b/main/clang/0004-Add-musl-targets.patch @@ -1,11 +1,18 @@ -From: Natanael Copa <ncopa@alpinelinux.org> +From 8f14313cb2ee5221e481e292bcd066a473b1edb8 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka <jakub@jirutka.cz> Date: Sun, 16 Apr 2017 16:49:00 +0100 -Subject: [PATCH] Add musl targets +Subject: [PATCH 4/7] Add musl targets ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -1644,7 +1644,8 @@ +--- + lib/Driver/ToolChains/Gnu.cpp | 6 ++++-- + lib/Driver/ToolChains/Linux.cpp | 15 ++++++++++++--- + 2 files changed, 16 insertions(+), 5 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index 72a9f85..40ad3f5 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -1917,7 +1917,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const { case llvm::Triple::arm: case llvm::Triple::thumb: LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); @@ -15,7 +22,7 @@ Subject: [PATCH] Add musl targets TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); } else { TripleAliases.append(begin(ARMTriples), end(ARMTriples)); -@@ -1653,7 +1654,8 @@ +@@ -1926,7 +1927,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const { case llvm::Triple::armeb: case llvm::Triple::thumbeb: LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs)); @@ -25,7 +32,11 @@ Subject: [PATCH] Add musl targets TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples)); } else { TripleAliases.append(begin(ARMebTriples), end(ARMebTriples)); -@@ -3956,7 +3958,8 @@ +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 1201df6..9eea3f0 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -54,7 +54,8 @@ static std::string getMultiarchTriple(const Driver &D, // regardless of what the actual target triple is. case llvm::Triple::arm: case llvm::Triple::thumb: @@ -35,7 +46,7 @@ Subject: [PATCH] Add musl targets if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf")) return "arm-linux-gnueabihf"; } else { -@@ -3966,7 +3969,8 @@ +@@ -64,7 +65,8 @@ static std::string getMultiarchTriple(const Driver &D, break; case llvm::Triple::armeb: case llvm::Triple::thumbeb: @@ -45,7 +56,7 @@ Subject: [PATCH] Add musl targets if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabihf")) return "armeb-linux-gnueabihf"; } else { -@@ -4334,6 +4338,12 @@ +@@ -434,6 +436,12 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const { ArchName = "armeb"; IsArm = true; break; @@ -53,12 +64,12 @@ Subject: [PATCH] Add musl targets + ArchName = "powerpc"; + break; + case llvm::Triple::x86: -+ ArchName = "i386"; ++ ArchName = "i386"; + break; default: ArchName = Triple.getArchName().str(); } -@@ -4544,7 +4554,8 @@ +@@ -644,7 +652,8 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, break; case llvm::Triple::arm: case llvm::Triple::thumb: @@ -68,49 +79,6 @@ Subject: [PATCH] Add musl targets MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs; else MultiarchIncludeDirs = ARMMultiarchIncludeDirs; +-- +2.14.1 ---- 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/main/clang/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch b/main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch index 7cd79addcc..782419ab44 100644 --- a/main/clang/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch +++ b/main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch @@ -1,41 +1,52 @@ -From: Natanael Copa <ncopa@alpinelinux.org> +From bb174d2f1fd3b936c1c8b75b83c6fb15b3dece2c Mon Sep 17 00:00:00 2001 From: Jakub Jirutka <jakub@jirutka.cz> Date: Sun, 16 Apr 2017 16:49:00 +0100 -Subject: [PATCH] Enable PIE by default for Alpine Linux +Subject: [PATCH 5/7] Enable PIE by default for Alpine Linux Alpine Linux uses PIE by default. +--- + lib/Driver/ToolChains/Gnu.cpp | 4 +++- + lib/Driver/ToolChains/Linux.cpp | 5 ++++- + test/Driver/pic.c | 12 ++++++++++++ + 3 files changed, 19 insertions(+), 2 deletions(-) ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -4721,7 +4721,10 @@ +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index 40ad3f5..842afb9 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -443,7 +443,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + 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"); + + if (Args.hasArg(options::OPT_rdynamic)) +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 9eea3f0..ce9cf35 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -819,7 +819,10 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs, } } -bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); } +bool Linux::isPIEDefault() const { -+ return getSanitizerArgs().requiresPIE() || ++ 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"); +diff --git a/test/Driver/pic.c b/test/Driver/pic.c +index 6b01c58..0643edd 100644 --- a/test/Driver/pic.c +++ b/test/Driver/pic.c -@@ -244,6 +244,18 @@ - // RUN: %clang %s -target i386-pc-openbsd -nopie -### 2>&1 \ +@@ -251,6 +251,18 @@ + // RUN: %clang %s -target i386-pc-openbsd -no-pie -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD // +// On Alpine Linux, we want similar PIE-by-default behavior @@ -53,3 +64,6 @@ Alpine Linux uses PIE by default. // On Android PIC is enabled by default // RUN: %clang -c %s -target i686-linux-android -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC2 +-- +2.14.1 + diff --git a/main/clang/0006-Link-with-z-now-by-default-for-Alpine-Linux.patch b/main/clang/0006-Link-with-z-now-by-default-for-Alpine-Linux.patch new file mode 100644 index 0000000000..a2bb49a6a6 --- /dev/null +++ b/main/clang/0006-Link-with-z-now-by-default-for-Alpine-Linux.patch @@ -0,0 +1,28 @@ +From 2c6ae087cddd8a53e264814e404db8f3c29e4e53 Mon Sep 17 00:00:00 2001 +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH 6/7] Link with -z now by default for Alpine Linux + +--- + lib/Driver/ToolChains/Linux.cpp | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index ce9cf35..1583c9d 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -212,6 +212,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + + 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"); +-- +2.14.1 + diff --git a/main/clang/0007-Enable-stack-protector-by-default-for-Alpine-Linux.patch b/main/clang/0007-Enable-stack-protector-by-default-for-Alpine-Linux.patch new file mode 100644 index 0000000000..38865ff15b --- /dev/null +++ b/main/clang/0007-Enable-stack-protector-by-default-for-Alpine-Linux.patch @@ -0,0 +1,100 @@ +From b329713c3249d237d1827c326c1fc065104002a6 Mon Sep 17 00:00:00 2001 +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sun, 16 Apr 2017 16:49:00 +0100 +Subject: [PATCH 7/7] Enable stack protector by default for Alpine Linux + +--- + lib/Driver/ToolChains/Linux.cpp | 7 +++++++ + lib/Driver/ToolChains/Linux.h | 1 + + test/Driver/fsanitize.c | 10 ++++++---- + test/Driver/stack-protector.c | 14 ++++++++++++++ + 4 files changed, 28 insertions(+), 4 deletions(-) + +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 1583c9d..981f9ae 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -829,6 +829,13 @@ bool Linux::isPIEDefault() const { + Linux::getTriple().getVendorName().compare("alpine") == 0; + } + ++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { ++ StringRef VendorName = Linux::getTriple().getVendorName(); ++ if (VendorName.compare("alpine") == 0) ++ return 2; ++ return 1; ++} ++ + SanitizerMask Linux::getSupportedSanitizers() const { + const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; + const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; +diff --git a/lib/Driver/ToolChains/Linux.h b/lib/Driver/ToolChains/Linux.h +index 9778c18..ddd46a1 100644 +--- a/lib/Driver/ToolChains/Linux.h ++++ b/lib/Driver/ToolChains/Linux.h +@@ -36,6 +36,7 @@ public: + 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; +diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c +index 0752ef6..263485f 100644 +--- a/test/Driver/fsanitize.c ++++ b/test/Driver/fsanitize.c +@@ -491,12 +491,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=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP-ASAN ++// 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" +@@ -506,6 +506,8 @@ + + // NO-SP-ASAN-NOT: stack-protector + // NO-SP-ASAN: "-fsanitize=address,safe-stack" ++// SP-ASAN: "-fsanitize=address,safe-stack" ++// SP-ASAN: -stack-protector + // NO-SP-ASAN-NOT: stack-protector + + // RUN: %clang -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-SANM +diff --git a/test/Driver/stack-protector.c b/test/Driver/stack-protector.c +index 6769b65..553c189 100644 +--- 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" +-- +2.14.1 + diff --git a/main/clang/APKBUILD b/main/clang/APKBUILD index 8521c949f9..f08bb9b239 100644 --- a/main/clang/APKBUILD +++ b/main/clang/APKBUILD @@ -2,9 +2,9 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=clang # Note: Update together with llvm. -pkgver=4.0.0 +pkgver=5.0.0 pkgrel=0 -_vermajor=${pkgver%%.*} +_llvmver=${pkgver%%.*} pkgdesc="A C language family front-end for LLVM" arch="all" url="http://llvm.org/" @@ -12,60 +12,66 @@ license="UOI-NCSA" makedepends=" cmake isl-dev + libedit-dev libxml2-dev libxml2-utils - llvm-dev>=$_vermajor - llvm-static>=$_vermajor - paxmark + llvm-dev>=$_llvmver + llvm-static>=$_llvmver + llvm-test-utils>=$_llvmver python2 " depends_dev="$pkgname=$pkgver-r$pkgrel" subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs $pkgname-analyzer::noarch" -source="http://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 +source="https://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.xz + 0001-Add-Alpine-Linux-distro.patch + 0002-Use-z-relro-on-Alpine-Linux.patch + 0003-Use-hash-style-gnu-for-Alpine-Linux.patch + 0004-Add-musl-targets.patch + 0005-Enable-PIE-by-default-for-Alpine-Linux.patch + 0006-Link-with-z-now-by-default-for-Alpine-Linux.patch + 0007-Enable-stack-protector-by-default-for-Alpine-Linux.patch " builddir="$srcdir/cfe-$pkgver.src" +prepare() { + default_prepare + + # FIXME: fails on 5.0.0 + rm "$builddir/test/OpenMP/task_firstprivate_codegen.cpp" +} + build() { mkdir -p "$builddir"/build cd "$builddir"/build - cmake .. -G "Unix Makefiles" -Wno-dev \ + cmake .. -Wno-dev \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_VERBOSE_MAKEFILE=OFF \ + -DCLANG_VENDOR=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 \ - || return 1 + -DLLVM_ENABLE_RTTI=ON - make clang-tblgen || return 1 + make clang-tblgen make } check() { cd "$builddir"/build - ./bin/clang --version - ./bin/clang-check --version - ./bin/clang-format --version + make check-clang } package() { cd "$builddir"/build - make DESTDIR="$pkgdir" install || return 1 + make DESTDIR="$pkgdir" install install -m 644 lib/libclang.a "$pkgdir"/usr/lib } @@ -85,16 +91,16 @@ analyzer() { mkdir -p "$subpkgdir"/usr/bin \ "$subpkgdir"/usr/libexec \ "$subpkgdir"/usr/share/ - mv usr/bin/scan-* "$subpkgdir"/usr/bin/ || return 1 - mv usr/libexec/*-analyzer "$subpkgdir"/usr/libexec/ || return 1 + 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" +sha512sums="14acdd622310122b544c952ee5b932b7006d9d8424319f0e3974f2503d40a0cec4200fdd3d813a32ce0d877bcfbb9a5bd5c36f6142b4330e6c814f113ca2efe8 cfe-5.0.0.src.tar.xz +98ae759832b2f4c41152f8d16c909044c8d5afb1f4ef3ec10fdc8c3419b2ce8a14a21be989d3919f98869a46ee21f702651d59becb1c87b258846e0d81398358 0001-Add-Alpine-Linux-distro.patch +a45d766005500736a270204424e3b3ea6e2334f4807c431cfcb79563d34ac8d6f1519291b3b1422152e2888ee243a060733a09120c17c706d310f5e04a7daae9 0002-Use-z-relro-on-Alpine-Linux.patch +ca551fb4e8a844424c63e381c4e1e1239ee95548c7561d46d4e8ae01c65b5e46ece7c51021f152ad4aa10dcdd40c0638728b29aed93ddd65d9aeff2af2e878e8 0003-Use-hash-style-gnu-for-Alpine-Linux.patch +0ba4e6cb6d6854ef627f7f6d60f9f6843490e6c8f91dba7e238742574aecf3c07b1f5928850ce755fca9eac07ef3ce814728da58aa1ed9afb03a397ce4c30562 0004-Add-musl-targets.patch +08486325536871346b190b4af3a7b80b58a0066028e6268b06714eb00b29925b3b414ea62fa5ec4ff908763aeec4257536e04275b40c3d55e0a6c5b433625b5c 0005-Enable-PIE-by-default-for-Alpine-Linux.patch +fe5927b7851a97a5223d5b698c5dd01a47ef2fa23d9556cfee976aa7bda639af922785cbe34169e121aab79b38bbb1704aebaf11b1f4f41bcd448947f6e9562b 0006-Link-with-z-now-by-default-for-Alpine-Linux.patch +609ebc1c6cbccd43f8b08e6b653e6da996a09cdcf008744a56af7d8846f1e7a9fc6945d3cc68fba0d06071b6f8de796747606a34d1d5008e0dc620dc0812e3e0 0007-Enable-stack-protector-by-default-for-Alpine-Linux.patch" diff --git a/main/clang/clang-0002-Use-z-relro-on-Alpine-Linux.patch b/main/clang/clang-0002-Use-z-relro-on-Alpine-Linux.patch deleted file mode 100644 index 45fce6e13a..0000000000 --- a/main/clang/clang-0002-Use-z-relro-on-Alpine-Linux.patch +++ /dev/null @@ -1,16 +0,0 @@ -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/main/clang/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch b/main/clang/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch deleted file mode 100644 index 0b66323288..0000000000 --- a/main/clang/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch +++ /dev/null @@ -1,16 +0,0 @@ -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/main/clang/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch b/main/clang/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch deleted file mode 100644 index 90de948f64..0000000000 --- a/main/clang/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch +++ /dev/null @@ -1,19 +0,0 @@ -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/main/clang/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch b/main/clang/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch deleted file mode 100644 index 3487799b1b..0000000000 --- a/main/clang/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch +++ /dev/null @@ -1,54 +0,0 @@ -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" |