pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/devel/lld Restore NetBSD patches.
details: https://anonhg.NetBSD.org/pkgsrc/rev/471a37cebf02
branches: trunk
changeset: 403117:471a37cebf02
user: rjs <rjs%pkgsrc.org@localhost>
date: Mon Oct 21 22:07:58 2019 +0000
description:
Restore NetBSD patches.
Set correct link address for NetBSD/aarch64.
Add a dummy option for an aarch64 erratum for gcc compatibility.
diffstat:
devel/lld/Makefile | 3 +-
devel/lld/distinfo | 9 +-
devel/lld/patches/patch-ELF_Arch_AArch64.cpp | 22 ++
devel/lld/patches/patch-ELF_Config.h | 65 +++++++
devel/lld/patches/patch-ELF_Driver.cpp | 250 +++++++++++++++++++++++++++
devel/lld/patches/patch-ELF_Options.td | 28 +++
devel/lld/patches/patch-ELF_Writer.cpp | 32 +++
devel/lld/patches/patch-docs_ld.lld.1 | 18 +
devel/lld/patches/patch-test_ELF_gnustack.s | 25 ++
9 files changed, 450 insertions(+), 2 deletions(-)
diffs (truncated from 500 to 300 lines):
diff -r 48890588fea2 -r 471a37cebf02 devel/lld/Makefile
--- a/devel/lld/Makefile Mon Oct 21 21:55:03 2019 +0000
+++ b/devel/lld/Makefile Mon Oct 21 22:07:58 2019 +0000
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.8 2019/10/21 19:20:18 mgorny Exp $
+# $NetBSD: Makefile,v 1.9 2019/10/21 22:07:58 rjs Exp $
DISTNAME= lld-9.0.0.src
PKGNAME= ${DISTNAME:S/.src//}
+PKGREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://releases.llvm.org/${PKGVERSION_NOREV}/
EXTRACT_SUFX= .tar.xz
diff -r 48890588fea2 -r 471a37cebf02 devel/lld/distinfo
--- a/devel/lld/distinfo Mon Oct 21 21:55:03 2019 +0000
+++ b/devel/lld/distinfo Mon Oct 21 22:07:58 2019 +0000
@@ -1,7 +1,14 @@
-$NetBSD: distinfo,v 1.5 2019/10/19 14:01:36 adam Exp $
+$NetBSD: distinfo,v 1.6 2019/10/21 22:07:58 rjs Exp $
SHA1 (lld-9.0.0.src.tar.xz) = 021a8c38cf27d63db37d939c7cdec46ffd627be2
RMD160 (lld-9.0.0.src.tar.xz) = d46b068f4de55d174be71e061aa38f7d4d1499dc
SHA512 (lld-9.0.0.src.tar.xz) = bc4812232840ef5edbd8edf1d1a329e85a4bfd3a7859fe322e11dd053435e722c6f1140a718fd2b3524ee9783a357178d2ba30d12519847bd3acc294698007f3
Size (lld-9.0.0.src.tar.xz) = 1100608 bytes
SHA1 (patch-CMakeLists.txt) = df8e32f5f23bf2f2615a891177f61dc65359e955
+SHA1 (patch-ELF_Arch_AArch64.cpp) = 45eb8f69b92f8ba764372993363dbce88b50a310
+SHA1 (patch-ELF_Config.h) = 760658ef2d90e8d44ae6c1ef76a183613f445264
+SHA1 (patch-ELF_Driver.cpp) = eaf5a3cd01a82421205831dce86db92bfb4001bc
+SHA1 (patch-ELF_Options.td) = 8e228dee43511efc7fd6107e817288067c393145
+SHA1 (patch-ELF_Writer.cpp) = 210b0a8b60885456cb037d9925c504874efd0e35
+SHA1 (patch-docs_ld.lld.1) = a6865d0099216094422aede3d65f43ee6fee22fe
+SHA1 (patch-test_ELF_gnustack.s) = 22f5eb19e588cc0c1055fd932d7a7b22ecd70e20
diff -r 48890588fea2 -r 471a37cebf02 devel/lld/patches/patch-ELF_Arch_AArch64.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/lld/patches/patch-ELF_Arch_AArch64.cpp Mon Oct 21 22:07:58 2019 +0000
@@ -0,0 +1,22 @@
+$NetBSD: patch-ELF_Arch_AArch64.cpp,v 1.1 2019/10/21 22:07:58 rjs Exp $
+
+Set correct base address on NetBSD.
+
+--- ELF/Arch/AArch64.cpp.orig 2019-07-16 05:50:45.000000000 +0000
++++ ELF/Arch/AArch64.cpp
+@@ -66,9 +66,12 @@ AArch64::AArch64() {
+ pltHeaderSize = 32;
+ defaultMaxPageSize = 65536;
+
+- // Align to the 2 MiB page size (known as a superpage or huge page).
+- // FreeBSD automatically promotes 2 MiB-aligned allocations.
+- defaultImageBase = 0x200000;
++ if (config->targetTriple.isOSNetBSD())
++ defaultImageBase = 0x200100000;
++ else
++ // Align to the 2 MiB page size (known as a superpage or huge page).
++ // FreeBSD automatically promotes 2 MiB-aligned allocations.
++ defaultImageBase = 0x200000;
+
+ needsThunks = true;
+ }
diff -r 48890588fea2 -r 471a37cebf02 devel/lld/patches/patch-ELF_Config.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/lld/patches/patch-ELF_Config.h Mon Oct 21 22:07:58 2019 +0000
@@ -0,0 +1,65 @@
+$NetBSD: patch-ELF_Config.h,v 1.4 2019/10/21 22:07:58 rjs Exp $
+
+Add support for customizing LLD behavior on target triple.
+https://reviews.llvm.org/D56650
+
+Add '-z nognustack' option to disable emitting PT_GNU_STACK.
+https://reviews.llvm.org/D56554
+
+Add dummy option for an AArch64 erratum.
+
+--- ELF/Config.h.orig 2019-07-16 05:50:45.000000000 +0000
++++ ELF/Config.h
+@@ -13,6 +13,7 @@
+ #include "llvm/ADT/MapVector.h"
+ #include "llvm/ADT/StringRef.h"
+ #include "llvm/ADT/StringSet.h"
++#include "llvm/ADT/Triple.h"
+ #include "llvm/BinaryFormat/ELF.h"
+ #include "llvm/Support/CachePruning.h"
+ #include "llvm/Support/CodeGen.h"
+@@ -61,6 +62,9 @@ enum class Target2Policy { Abs, Rel, Got
+ // For tracking ARM Float Argument PCS
+ enum class ARMVFPArgKind { Default, Base, VFP, ToolChain };
+
++// For -z *stack
++enum class GnuStackKind { None, Exec, NoExec };
++
+ struct SymbolVersion {
+ llvm::StringRef name;
+ bool isExternCpp;
+@@ -146,6 +150,7 @@ struct Configuration {
+ bool enableNewDtags;
+ bool executeOnly;
+ bool exportDynamic;
++ bool fixCortexA53Errata835769;
+ bool fixCortexA53Errata843419;
+ bool forceBTI;
+ bool formatBinary = false;
+@@ -206,6 +211,7 @@ struct Configuration {
+ bool zNodefaultlib;
+ bool zNodelete;
+ bool zNodlopen;
++ bool zNognustack;
+ bool zNow;
+ bool zOrigin;
+ bool zRelro;
+@@ -214,6 +220,7 @@ struct Configuration {
+ bool zRetpolineplt;
+ bool zWxneeded;
+ DiscardPolicy discard;
++ GnuStackKind zGnustack;
+ ICFLevel icf;
+ OrphanHandlingPolicy orphanHandling;
+ SortSectionPolicy sortSection;
+@@ -304,6 +311,10 @@ struct Configuration {
+
+ // 4 for ELF32, 8 for ELF64.
+ int wordsize;
++
++ // Target triple, inferred from program name or defaulted to LLVM
++ // default target.
++ llvm::Triple targetTriple;
+ };
+
+ // The only instance of Configuration struct.
diff -r 48890588fea2 -r 471a37cebf02 devel/lld/patches/patch-ELF_Driver.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/lld/patches/patch-ELF_Driver.cpp Mon Oct 21 22:07:58 2019 +0000
@@ -0,0 +1,250 @@
+$NetBSD: patch-ELF_Driver.cpp,v 1.5 2019/10/21 22:07:58 rjs Exp $
+
+Add support for customizing LLD behavior on target triple.
+https://reviews.llvm.org/D56650
+
+Add '-z nognustack' option to disable emitting PT_GNU_STACK.
+https://reviews.llvm.org/D56554
+
+Alter defaults for NetBSD targets:
+* add default library search paths
+* force combined RO+RW segment due to ld.elf_so limitations
+* disable PT_GNU_STACK (meaningless on NetBSD)
+* disable 'new dtags', i.e. force RPATH instead of RUNPATH
+
+Add dummy handler for an AArch64 erratum.
+
+--- ELF/Driver.cpp.orig 2019-07-17 14:54:02.000000000 +0000
++++ ELF/Driver.cpp
+@@ -54,6 +54,7 @@
+ #include "llvm/Support/LEB128.h"
+ #include "llvm/Support/Path.h"
+ #include "llvm/Support/TarWriter.h"
++#include "llvm/Support/TargetRegistry.h"
+ #include "llvm/Support/TargetSelect.h"
+ #include "llvm/Support/raw_ostream.h"
+ #include <cstdlib>
+@@ -73,6 +74,8 @@ LinkerDriver *elf::driver;
+
+ static void setConfigs(opt::InputArgList &args);
+ static void readConfigs(opt::InputArgList &args);
++static void appendDefaultSearchPaths(void);
++static void setTargetTriple(StringRef argv0, opt::InputArgList &args);
+
+ bool elf::link(ArrayRef<const char *> args, bool canExitEarly,
+ raw_ostream &error) {
+@@ -129,7 +132,7 @@ static std::tuple<ELFKind, uint16_t, uin
+ std::pair<ELFKind, uint16_t> ret =
+ StringSwitch<std::pair<ELFKind, uint16_t>>(s)
+ .Cases("aarch64elf", "aarch64linux", "aarch64_elf64_le_vec",
+- {ELF64LEKind, EM_AARCH64})
++ "aarch64nbsd", {ELF64LEKind, EM_AARCH64})
+ .Cases("armelf", "armelf_linux_eabi", {ELF32LEKind, EM_ARM})
+ .Case("elf32_x86_64", {ELF32LEKind, EM_X86_64})
+ .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS})
+@@ -296,6 +299,9 @@ static void checkOptions() {
+ if (config->emachine == EM_MIPS && config->gnuHash)
+ error("the .gnu.hash section is not compatible with the MIPS target");
+
++ if (config->fixCortexA53Errata835769 && config->emachine != EM_AARCH64)
++ error("--fix-cortex-a53-835769 is only supported on AArch64 targets");
++
+ if (config->fixCortexA53Errata843419 && config->emachine != EM_AARCH64)
+ error("--fix-cortex-a53-843419 is only supported on AArch64 targets");
+
+@@ -336,6 +342,9 @@ static void checkOptions() {
+
+ if (config->singleRoRx && !script->hasSectionsCommand)
+ error("-execute-only and -no-rosegment cannot be used together");
++ } else if (config->targetTriple.isOSNetBSD()) {
++ // force-disable RO segment on NetBSD due to ld.elf_so limitations
++ config->singleRoRx = true;
+ }
+
+ if (config->zRetpolineplt && config->requireCET)
+@@ -373,6 +382,20 @@ static bool getZFlag(opt::InputArgList &
+ return Default;
+ }
+
++static GnuStackKind getZGnuStack(opt::InputArgList &args) {
++ for (auto *arg : args.filtered_reverse(OPT_z)) {
++ if (StringRef("execstack") == arg->getValue())
++ return GnuStackKind::Exec;
++ if (StringRef("noexecstack") == arg->getValue())
++ return GnuStackKind::NoExec;
++ if (StringRef("nognustack") == arg->getValue())
++ return GnuStackKind::None;
++ }
++
++ // default
++ return GnuStackKind::NoExec;
++}
++
+ static bool isKnownZFlag(StringRef s) {
+ return s == "combreloc" || s == "copyreloc" || s == "defs" ||
+ s == "execstack" || s == "global" || s == "hazardplt" ||
+@@ -380,6 +403,7 @@ static bool isKnownZFlag(StringRef s) {
+ s == "keep-text-section-prefix" || s == "lazy" || s == "muldefs" ||
+ s == "nocombreloc" || s == "nocopyreloc" || s == "nodefaultlib" ||
+ s == "nodelete" || s == "nodlopen" || s == "noexecstack" ||
++ s == "nognustack" ||
+ s == "nokeep-text-section-prefix" || s == "norelro" || s == "notext" ||
+ s == "now" || s == "origin" || s == "relro" || s == "retpolineplt" ||
+ s == "rodynamic" || s == "text" || s == "wxneeded" ||
+@@ -394,6 +418,56 @@ static void checkZOptions(opt::InputArgL
+ error("unknown -z value: " + StringRef(arg->getValue()));
+ }
+
++static void appendDefaultSearchPaths() {
++ if (config->targetTriple.isOSNetBSD()) {
++ // NetBSD driver relies on the linker knowing the default search paths.
++ // Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
++ // (NetBSD::NetBSD constructor)
++ switch (config->targetTriple.getArch()) {
++ case llvm::Triple::x86:
++ config->searchPaths.push_back("=/usr/lib/i386");
++ break;
++ case llvm::Triple::arm:
++ case llvm::Triple::armeb:
++ case llvm::Triple::thumb:
++ case llvm::Triple::thumbeb:
++ switch (config->targetTriple.getEnvironment()) {
++ case llvm::Triple::EABI:
++ case llvm::Triple::GNUEABI:
++ config->searchPaths.push_back("=/usr/lib/eabi");
++ break;
++ case llvm::Triple::EABIHF:
++ case llvm::Triple::GNUEABIHF:
++ config->searchPaths.push_back("=/usr/lib/eabihf");
++ break;
++ default:
++ config->searchPaths.push_back("=/usr/lib/oabi");
++ break;
++ }
++ break;
++#if 0 // TODO
++ case llvm::Triple::mips64:
++ case llvm::Triple::mips64el:
++ if (tools::mips::hasMipsAbiArg(Args, "o32"))
++ config->searchPaths.push_back("=/usr/lib/o32");
++ else if (tools::mips::hasMipsAbiArg(Args, "64"))
++ config->searchPaths.push_back("=/usr/lib/64");
++ break;
++#endif
++ case llvm::Triple::ppc:
++ config->searchPaths.push_back("=/usr/lib/powerpc");
++ break;
++ case llvm::Triple::sparc:
++ config->searchPaths.push_back("=/usr/lib/sparc");
++ break;
++ default:
++ break;
++ }
++
++ config->searchPaths.push_back("=/usr/lib");
++ }
++}
++
+ void LinkerDriver::main(ArrayRef<const char *> argsArr) {
+ ELFOptTable parser;
+ opt::InputArgList args = parser.parse(argsArr.slice(1));
+@@ -408,6 +482,8 @@ void LinkerDriver::main(ArrayRef<const c
+ return;
+ }
+
++ setTargetTriple(argsArr[0], args);
++
+ // Handle -v or -version.
+ //
+ // A note about "compatible with GNU linkers" message: this is a hack for
+@@ -423,8 +499,10 @@ void LinkerDriver::main(ArrayRef<const c
+ // lot of "configure" scripts out there that are generated by old version
+ // of Libtool. We cannot convince every software developer to migrate to
+ // the latest version and re-generate scripts. So we have this hack.
+- if (args.hasArg(OPT_v) || args.hasArg(OPT_version))
++ if (args.hasArg(OPT_v) || args.hasArg(OPT_version)) {
+ message(getLLDVersion() + " (compatible with GNU linkers)");
++ message("Target: " + config->targetTriple.str());
++ }
+
Home |
Main Index |
Thread Index |
Old Index