From 30bed693419cdb6d4bfe15b0b3b5dc8513ea81c0 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Sat, 8 Feb 2020 12:34:22 +0100 Subject: [PATCH] llvm-project-netbsd: Drop local LLD patches They no longer apply and may be done differently. --- llvm-project-netbsd/distinfo | 5 - .../patches/patch-lld_CMakeLists.txt | 12 -- .../patches/patch-lld_ELF_Arch_AArch64.cpp | 20 -- .../patches/patch-lld_ELF_Config.h | 31 --- .../patches/patch-lld_ELF_Driver.cpp | 199 ------------------ .../patches/patch-lld_ELF_Options.td | 23 -- 6 files changed, 290 deletions(-) delete mode 100644 llvm-project-netbsd/patches/patch-lld_CMakeLists.txt delete mode 100644 llvm-project-netbsd/patches/patch-lld_ELF_Arch_AArch64.cpp delete mode 100644 llvm-project-netbsd/patches/patch-lld_ELF_Config.h delete mode 100644 llvm-project-netbsd/patches/patch-lld_ELF_Driver.cpp delete mode 100644 llvm-project-netbsd/patches/patch-lld_ELF_Options.td diff --git a/llvm-project-netbsd/distinfo b/llvm-project-netbsd/distinfo index 33bdc59337..7deed2dd0a 100644 --- a/llvm-project-netbsd/distinfo +++ b/llvm-project-netbsd/distinfo @@ -12,8 +12,3 @@ SHA1 (patch-clang_lib_Basic_Targets_OSTargets.h) = 435a8b95936b37827fb9eed515faa SHA1 (patch-clang_lib_Driver_ToolChains_NetBSD.cpp) = 3783663621709052758c7e41af34bdbc35680606 SHA1 (patch-clang_test_Sema_128bitfloat.cpp) = 4c9bec849623d24cbd9e1deb01a05251b7ba57f8 SHA1 (patch-clang_tools_clang-format_CMakeLists.txt) = d9c64d5dd140e04b6375a927555fb06750789641 -SHA1 (patch-lld_CMakeLists.txt) = c6113b515c50a3fd71d4d64ad76c63a96d396300 -SHA1 (patch-lld_ELF_Arch_AArch64.cpp) = 9f12e997e423a7356b43a2f717d06e079674e4bb -SHA1 (patch-lld_ELF_Config.h) = 9c674c6a1cfb55aa25941715afa1abefb38bdf39 -SHA1 (patch-lld_ELF_Driver.cpp) = bbe40591fc4160b14b8350016a16d9d55a217d95 -SHA1 (patch-lld_ELF_Options.td) = 573c1e79cee468192803e2deeeed30d3183f6ef0 diff --git a/llvm-project-netbsd/patches/patch-lld_CMakeLists.txt b/llvm-project-netbsd/patches/patch-lld_CMakeLists.txt deleted file mode 100644 index 78dc8e2064..0000000000 --- a/llvm-project-netbsd/patches/patch-lld_CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -$NetBSD$ - ---- lld/CMakeLists.txt.orig 2019-10-23 20:24:31.000000000 +0000 -+++ lld/CMakeLists.txt -@@ -85,7 +85,6 @@ Please install Python or specify the PYT - endif() - set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) - if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h -- AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) - add_subdirectory(${UNITTEST_DIR} utils/unittest) - endif() diff --git a/llvm-project-netbsd/patches/patch-lld_ELF_Arch_AArch64.cpp b/llvm-project-netbsd/patches/patch-lld_ELF_Arch_AArch64.cpp deleted file mode 100644 index bd51592582..0000000000 --- a/llvm-project-netbsd/patches/patch-lld_ELF_Arch_AArch64.cpp +++ /dev/null @@ -1,20 +0,0 @@ -$NetBSD$ - ---- lld/ELF/Arch/AArch64.cpp.orig 2019-10-23 20:24:31.000000000 +0000 -+++ lld/ELF/Arch/AArch64.cpp -@@ -67,9 +67,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 --git a/llvm-project-netbsd/patches/patch-lld_ELF_Config.h b/llvm-project-netbsd/patches/patch-lld_ELF_Config.h deleted file mode 100644 index cdb6b665c1..0000000000 --- a/llvm-project-netbsd/patches/patch-lld_ELF_Config.h +++ /dev/null @@ -1,31 +0,0 @@ -$NetBSD$ - ---- lld/ELF/Config.h.orig 2019-11-01 18:04:25.969170065 +0000 -+++ lld/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" -@@ -150,6 +151,7 @@ struct Configuration { - bool enableNewDtags; - bool executeOnly; - bool exportDynamic; -+ bool fixCortexA53Errata835769; - bool fixCortexA53Errata843419; - bool fixCortexA8; - bool forceBTI; -@@ -311,6 +313,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 --git a/llvm-project-netbsd/patches/patch-lld_ELF_Driver.cpp b/llvm-project-netbsd/patches/patch-lld_ELF_Driver.cpp deleted file mode 100644 index 93cc0e956e..0000000000 --- a/llvm-project-netbsd/patches/patch-lld_ELF_Driver.cpp +++ /dev/null @@ -1,199 +0,0 @@ -$NetBSD$ - ---- lld/ELF/Driver.cpp.orig 2019-11-01 18:04:25.969815957 +0000 -+++ lld/ELF/Driver.cpp -@@ -55,6 +55,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 -@@ -74,6 +75,8 @@ LinkerDriver *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 link(ArrayRef args, bool canExitEarly, raw_ostream &error) { - errorHandler().logName = args::getFilenameWithoutExe(args[0]); -@@ -129,7 +132,7 @@ static std::tuple ret = - StringSwitch>(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"); - -@@ -344,6 +350,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) -@@ -431,6 +440,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 argsArr) { - ELFOptTable parser; - opt::InputArgList args = parser.parse(argsArr.slice(1)); -@@ -445,6 +504,8 @@ void LinkerDriver::main(ArrayReftargetTriple.str()); -+ } - - if (const char *path = getReproduceOption(args)) { - // Note that --reproduce is a debug option so you can ignore it -@@ -479,6 +542,8 @@ void LinkerDriver::main(ArrayReftargetTriple = llvm::Triple(targetOpt); -+ return; -+ } else -+ error("Unsupported --target=" + targetOpt + ": " + targetError); -+ } -+ -+ // Secondly, try to get it from program name prefix -+ std::string ProgName = llvm::sys::path::stem(argv0); -+ size_t lastComponent = ProgName.rfind('-'); -+ if (lastComponent != std::string::npos) { -+ std::string prefix = ProgName.substr(0, lastComponent); -+ if (llvm::TargetRegistry::lookupTarget(prefix, targetError)) { -+ config->targetTriple = llvm::Triple(prefix); -+ return; -+ } -+ } -+ -+ // Finally, use the default target triple -+ config->targetTriple = llvm::Triple(getDefaultTargetTriple()); -+} -+ - // Initializes Config members by the command line options. - static void readConfigs(opt::InputArgList &args) { - errorHandler().verbose = args.hasArg(OPT_verbose); -@@ -865,7 +958,8 @@ static void readConfigs(opt::InputArgLis - config->callGraphProfileSort = args.hasFlag( - OPT_call_graph_profile_sort, OPT_no_call_graph_profile_sort, true); - config->enableNewDtags = -- args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true); -+ args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, -+ !config->targetTriple.isOSNetBSD()); - config->entry = args.getLastArgValue(OPT_entry); - config->executeOnly = - args.hasFlag(OPT_execute_only, OPT_no_execute_only, false); -@@ -873,6 +967,7 @@ static void readConfigs(opt::InputArgLis - args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false); - config->filterList = args::getStrings(args, OPT_filter); - config->fini = args.getLastArgValue(OPT_fini, "_fini"); -+ config->fixCortexA53Errata835769 = args.hasArg(OPT_fix_cortex_a53_843419); - config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419); - config->fixCortexA8 = args.hasArg(OPT_fix_cortex_a8); - config->forceBTI = args.hasArg(OPT_force_bti); -@@ -1286,7 +1381,7 @@ void LinkerDriver::inferMachineType() { - // each target. - static uint64_t getMaxPageSize(opt::InputArgList &args) { - uint64_t val = args::getZOptionValue(args, OPT_z, "max-page-size", -- target->defaultMaxPageSize); -+ lld::elf::target->defaultMaxPageSize); - if (!isPowerOf2_64(val)) - error("max-page-size: value isn't a power of 2"); - if (config->nmagic || config->omagic) { diff --git a/llvm-project-netbsd/patches/patch-lld_ELF_Options.td b/llvm-project-netbsd/patches/patch-lld_ELF_Options.td deleted file mode 100644 index fda4cc45e4..0000000000 --- a/llvm-project-netbsd/patches/patch-lld_ELF_Options.td +++ /dev/null @@ -1,23 +0,0 @@ -$NetBSD$ - ---- lld/ELF/Options.td.orig 2019-11-01 18:04:25.971104878 +0000 -+++ lld/ELF/Options.td -@@ -168,6 +168,9 @@ defm filter: Eq<"filter", "Set DT_FILTER - - defm fini: Eq<"fini", "Specify a finalizer function">, MetaVarName<"">; - -+def fix_cortex_a53_835769: F<"fix-cortex-a53-835769">, -+ HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 835769">; -+ - def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">, - HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">; - -@@ -350,6 +353,8 @@ defm symbol_ordering_file: - - defm sysroot: Eq<"sysroot", "Set the system root">; - -+defm target: Eq<"target", "Apply configuration defaults for a given target">; -+ - def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">; - - def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;