From 5910060f8ec65a8b925affc5c7f892f29ae65dea Mon Sep 17 00:00:00 2001 From: Steven Ramirez Rosa Date: Tue, 23 Jun 2026 11:23:25 -0700 Subject: [PATCH] [Diagnostics] Add diagnostic for conflicting command-line options Introduce a new diagnostic that detects and warns when mutually conflicting CLI flags are provided (e.g. --warn-mismatch vs --no-warn-mismatch). This helps prevent unintended or ambiguous behavior at invocation time by surfacing issues early. Additionally, add the -W[no-]conflicting-options command line option to enable/disable this diagnostic. Fix: qualcomm#1222 Signed-off-by: Steven Ramirez Rosa --- .../documentation/options/options.rst | 345 +++++++++++++ include/eld/Config/LinkerConfig.h | 15 + include/eld/Diagnostics/DiagCommonKinds.inc | 2 +- include/eld/Driver/GnuLinkerOptions.td | 2 + lib/Config/LinkerConfig.cpp | 8 + lib/LinkerWrapper/GnuLdDriver.cpp | 188 +++++++- lib/LinkerWrapper/RISCVLinkDriver.cpp | 28 ++ .../standalone/EmitRelocs/EmitRelocs.test | 6 - .../FatalWarnings/fatalwarnings.test | 8 +- .../FlagOverwrite/FlagOverwrite.test | 455 +++++++++++++----- .../FlagOverwrite/Inputs/{1.cpp => 1.c} | 0 .../standalone/FlagOverwrite/Inputs/1.script | 10 - .../standalone/FlagOverwrite/Inputs/2.cpp | 6 - .../standalone/FlagOverwrite/Inputs/2.script | 5 - .../standalone/FlagOverwrite/Inputs/2.yaml | 54 --- .../standalone/FlagOverwrite/Inputs/3.script | 5 - .../SymDef/Incompatible/Incompatible.test | 13 - .../standalone/SymDef/Incompatible/Inputs/1.c | 4 - .../SymDef/Incompatible/Inputs/x.symdef | 2 - .../FlagOverwrite/FlagOverwrite.test | 29 +- .../RISCV/standalone/FlagOverwrite/Inputs/1.c | 1 + .../RISCV/standalone/FlagOverwrite/Inputs/1.s | 20 - .../standalone/FlagOverwrite/Inputs/script.t | 9 - 23 files changed, 938 insertions(+), 277 deletions(-) rename test/Common/standalone/FlagOverwrite/Inputs/{1.cpp => 1.c} (100%) delete mode 100644 test/Common/standalone/FlagOverwrite/Inputs/2.cpp delete mode 100644 test/Common/standalone/FlagOverwrite/Inputs/2.script delete mode 100644 test/Common/standalone/FlagOverwrite/Inputs/2.yaml delete mode 100644 test/Common/standalone/FlagOverwrite/Inputs/3.script delete mode 100644 test/Common/standalone/SymDef/Incompatible/Incompatible.test delete mode 100644 test/Common/standalone/SymDef/Incompatible/Inputs/1.c delete mode 100644 test/Common/standalone/SymDef/Incompatible/Inputs/x.symdef create mode 100644 test/RISCV/standalone/FlagOverwrite/Inputs/1.c delete mode 100644 test/RISCV/standalone/FlagOverwrite/Inputs/1.s delete mode 100644 test/RISCV/standalone/FlagOverwrite/Inputs/script.t diff --git a/docs/userguide/documentation/options/options.rst b/docs/userguide/documentation/options/options.rst index 7830f9aca..97e281d7f 100644 --- a/docs/userguide/documentation/options/options.rst +++ b/docs/userguide/documentation/options/options.rst @@ -265,3 +265,348 @@ Record command line ``--no-record-command-line`` Do not record the linker command line in the ``.comment`` section. + +Conflicting command line options +-------------------------------- + +Command line options listed here conflict with each other. These should never +be used together. The last one specified will take precedence unless any +specific behavior is mentioned here. + +Warnings +^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--fatal-warnings`` + - ``--no-fatal-warnings`` + - Last specified + * - ``--warn-shared-textrel`` + - ``--no-warn-shared-textrel`` + - Last specified + * - ``--warn-mismatch`` + - ``--no-warn-mismatch`` + - Last specified + * - ``-Wlinker-script`` + - ``-Wno-linker-script`` + - Last specified + * - ``-Werror`` + - ``-Wno-error`` + - Last specified + * - ``-Wattribute-mix`` + - ``-Wno-attribute-mix`` + - Last specified + * - ``-Warchive-file`` + - ``-Wno-archive-file`` + - Last specified + * - ``-Wlinker-script-memory`` + - ``-Wno-linker-script-memory`` + - Last specified + * - ``-Wbad-dot-assignments`` + - ``-Wno-bad-dot-assignments`` + - Last specified + * - ``-Wwhole-archive`` + - ``-Wno-whole-archive`` + - Last specified + * - ``-Wosabi`` + - ``-Wno-osabi`` + - Last specified + * - ``-Wconflicting-options`` + - ``-Wno-conflicting-options`` + - Last specified + +Output type +^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--pie`` + - ``--no-pie`` + - Last specified + * - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``-Bdynamic`` / ``--call_shared`` / ``--dy`` + - Last specified + * - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``--dynamic`` + - Last specified + * - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``--shared`` / ``--Bshareable`` + - Last specified + * - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``-r`` / ``--relocatable`` + - Last specified + * - ``-Bdynamic`` / ``--call_shared`` / ``--dy`` + - ``--dynamic`` + - Last specified + * - ``-Bdynamic`` / ``--call_shared`` / ``--dy`` + - ``--shared`` / ``--Bshareable`` + - Last specified + * - ``-Bdynamic`` / ``--call_shared`` / ``--dy`` + - ``-r`` / ``--relocatable`` + - Last specified + * - ``--dynamic`` + - ``--shared`` / ``--Bshareable`` + - Last specified + * - ``--dynamic`` + - ``-r`` / ``--relocatable`` + - Last specified + * - ``--shared`` / ``--Bshareable`` + - ``-r`` / ``--relocatable`` + - Last specified + +Export and symbol visibility +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--export-dynamic`` / ``-E`` + - ``--no-export-dynamic`` + - Last specified + * - ``--Bsymbolic`` + - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``--static`` always wins + * - ``--Bsymbolic-functions`` + - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``--static`` always wins + +Relocation emission +^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--emit-relocs`` + - ``--no-emit-relocs`` + - Last specified + * - ``--emit-relocs-llvm`` + - ``--no-emit-relocs`` + - Last specified + * - ``--emit-relocs`` + - ``--emit-relocs-llvm`` + - Last specified + * - ``--emit-relocs`` + - ``--shared`` / ``--Bshareable`` + - ``--shared`` / ``--Bshareable`` always wins + * - ``--emit-relocs`` + - ``--pie`` + - ``--pie`` always wins + * - ``--emit-relocs`` + - ``-r`` / ``--relocatable`` + - ``-r`` / ``--relocatable`` always wins + * - ``--emit-relocs-llvm`` + - ``--shared`` / ``--Bshareable`` + - ``--shared`` / ``--Bshareable`` always wins + * - ``--emit-relocs-llvm`` + - ``--pie`` + - ``--pie`` always wins + * - ``--emit-relocs-llvm`` + - ``-r`` / ``--relocatable`` + - ``-r`` / ``--relocatable`` always wins + +Symbol definition export +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--symdef`` + - ``--shared`` / ``--Bshareable`` + - ``--shared`` / ``--Bshareable`` always wins + * - ``--symdef`` + - ``--pie`` + - ``--pie`` always wins + * - ``--symdef`` + - ``-r`` / ``--relocatable`` + - ``-r`` / ``--relocatable`` always wins + * - ``--symdef-file`` + - ``--shared`` / ``--Bshareable`` + - ``--shared`` / ``--Bshareable`` always wins + * - ``--symdef-file`` + - ``--pie`` + - ``--pie`` always wins + * - ``--symdef-file`` + - ``-r`` / ``--relocatable`` + - ``-r`` / ``--relocatable`` always wins + +Miscellaneous +^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--enable-new-dtags`` + - ``--disable-new-dtags`` + - Last specified + * - ``--enable-linker-version`` + - ``--disable-linker-version`` + - Last specified + * - ``--record-command-line`` + - ``--no-record-command-line`` + - Last specified + * - ``--fat-lto-objects`` / ``-ffat-lto-objects`` + - ``--no-fat-lto-objects`` / ``-fno-fat-lto-objects`` + - Last specified + * - ``--fatal-internal-errors`` + - ``--no-fatal-internal-errors`` + - Last specified + * - ``--gc-sections`` + - ``--no-gc-sections`` + - Last specified + * - ``--check-sections`` + - ``--no-check-sections`` + - Last specified + +Segment alignment +^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--align-segments`` + - ``--no-align-segments`` + - Last specified + * - ``--align-segments`` + - ``--omagic`` / ``-N`` + - ``--omagic`` / ``-N`` always wins + * - ``--align-segments`` + - ``-T`` / ``--script`` + - ``-T`` / ``--script`` always wins + * - ``--omagic`` / ``-N`` + - ``--no-omagic`` + - Last specified + +Threads +^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--threads`` + - ``--no-threads`` + - Last specified + * - ``--enable-threads`` + - ``--no-threads`` + - Last specified + * - ``--enable-threads`` + - ``--threads`` + - Last specified + * - ``--thread-count`` + - ``--no-threads`` + - ``--no-threads`` always wins + +Demangling +^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--demangle`` + - ``--no-demangle`` + - Last specified + * - ``--demangle-style`` + - ``--demangle`` + - Last specified + * - ``--demangle-style`` + - ``--no-demangle`` + - Last specified + +-z keyword options +^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``-z combreloc`` + - ``-z nocombreloc`` + - Last specified + * - ``-z relro`` + - ``-z norelro`` + - Last specified + * - ``-z lazy`` + - ``-z now`` + - Last specified + * - ``-z lazy`` + - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``--static`` always wins + * - ``-z now`` + - ``--static`` / ``--Bstatic`` / ``--dn`` / ``--non_shared`` + - ``--static`` always wins + * - ``-z text`` + - ``-z notext`` + - Last specified + * - ``-z execstack`` + - ``-z noexecstack`` + - Last specified + * - ``-z separate-code`` + - ``-z noseparate-code`` + - Last specified + * - ``-z separate-code`` + - ``-z separate-loadable-segments`` + - Last specified + * - ``-z noseparate-code`` + - ``-z separate-loadable-segments`` + - Last specified + +RISCV relaxation +^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 40 40 20 + + * - Option A + - Option B + - Winner + * - ``--relax`` + - ``--no-relax`` + - Last specified + * - ``--relax-xqci`` + - ``--no-relax-xqci`` + - Last specified + * - ``--relax-tbljal`` + - ``--no-relax-tbljal`` + - Last specified + diff --git a/include/eld/Config/LinkerConfig.h b/include/eld/Config/LinkerConfig.h index 3d18459b6..80349ab37 100644 --- a/include/eld/Config/LinkerConfig.h +++ b/include/eld/Config/LinkerConfig.h @@ -85,6 +85,7 @@ class LinkerConfig { std::optional EnableWholeArchiveWarnings; std::optional EnableCommandLineWarnings; std::optional EnableOSABIWarnings; + std::optional EnableConflictingOptionsWarnings; }; struct MappingFileInfo { @@ -299,6 +300,10 @@ class LinkerConfig { return WarnOpt.EnableWholeArchiveWarnings.has_value(); } + bool hasConflictingOptionsWarnings() const { + return WarnOpt.EnableConflictingOptionsWarnings.has_value(); + } + bool showAllWarnings() const { return (hasShowAllWarnings() && *WarnOpt.EnableAllWarnings); } @@ -348,6 +353,11 @@ class LinkerConfig { return (hasOSABIWarnings() && *WarnOpt.EnableOSABIWarnings); } + bool showConflictingOptionsWarnings() const { + return (hasConflictingOptionsWarnings() && + *WarnOpt.EnableConflictingOptionsWarnings); + } + void setShowAllWarnings() { WarnOpt.EnableAllWarnings = true; WarnOpt.EnableLinkerScriptWarnings = true; @@ -358,6 +368,7 @@ class LinkerConfig { WarnOpt.EnableBadDotAssignmentWarnings = true; WarnOpt.EnableWholeArchiveWarnings = true; WarnOpt.EnableOSABIWarnings = true; + WarnOpt.EnableConflictingOptionsWarnings = true; } void setShowLinkerScriptWarning(bool Option) { @@ -396,6 +407,10 @@ class LinkerConfig { WarnOpt.EnableOSABIWarnings = Option; } + void setShowConflictingOptionsWarning(bool Option) { + WarnOpt.EnableConflictingOptionsWarnings = Option; + } + bool setWarningOption(llvm::StringRef WarnOpt); /// Returns true if UseOldStyleTrampolineNames contains any value. diff --git a/include/eld/Diagnostics/DiagCommonKinds.inc b/include/eld/Diagnostics/DiagCommonKinds.inc index e6d6b3d92..48de2dba2 100644 --- a/include/eld/Diagnostics/DiagCommonKinds.inc +++ b/include/eld/Diagnostics/DiagCommonKinds.inc @@ -51,7 +51,7 @@ DIAG(fatal_unwritable_output, DiagnosticEngine::Fatal, DIAG(warn_unsupported_option, DiagnosticEngine::Warning, "Unrecognized option `%0'") DIAG(warn_incompatible_option, DiagnosticEngine::Warning, - "Option `-%0' is disabled as it is incompatible with `-%1`") + "Option `%0' is disabled as it is incompatible with `%1`") DIAG(symdef_incompatible_option, DiagnosticEngine::Fatal, "SymDef files are valid only when building executables") DIAG(warn_shared_textrel, DiagnosticEngine::Warning, diff --git a/include/eld/Driver/GnuLinkerOptions.td b/include/eld/Driver/GnuLinkerOptions.td index ded855fd2..10fe25ddb 100644 --- a/include/eld/Driver/GnuLinkerOptions.td +++ b/include/eld/Driver/GnuLinkerOptions.td @@ -1003,6 +1003,8 @@ def W : Joined<["-"], "W">, "whole-archive is enabled for any archive file\n" "\t\t\t -W[no-]osabi : display a warning when linking objects " "with different values for OS/ABI\n" + "\t\t\t -W[no-]conflicting-options : display warnings for " + "conflicting command line options\n" >, Group; diff --git a/lib/Config/LinkerConfig.cpp b/lib/Config/LinkerConfig.cpp index 7d2db7193..0aea336fb 100644 --- a/lib/Config/LinkerConfig.cpp +++ b/lib/Config/LinkerConfig.cpp @@ -256,6 +256,14 @@ bool LinkerConfig::setWarningOption(llvm::StringRef WarnOption) { if (WarnOpt == "no-osabi") { setShowOSABIWarning(false); } + if (WarnOpt == "conflicting-options") { + setShowConflictingOptionsWarning(true); + return true; + } + if (WarnOpt == "no-conflicting-options") { + setShowConflictingOptionsWarning(false); + return true; + } return false; } diff --git a/lib/LinkerWrapper/GnuLdDriver.cpp b/lib/LinkerWrapper/GnuLdDriver.cpp index 41d9f3f16..67b3814de 100644 --- a/lib/LinkerWrapper/GnuLdDriver.cpp +++ b/lib/LinkerWrapper/GnuLdDriver.cpp @@ -199,17 +199,180 @@ void GnuLdDriver::printVersionInfo() const { } // Some command line options or some combinations of them are not allowed. -// This function checks for such errors. +// This function checks for such issues and generate warnings or errors. template bool GnuLdDriver::checkOptions(llvm::opt::InputArgList &Args) const { - // TODO: Disabled since this will get replaced with a warning. - // check --thread-count and if threads are disabled. - // if (Args.getLastArg(T::thread_count)) { - // if (!Config.options().threadsEnabled()) { - // Config.raise(Diag::thread_count_with_no_threads); - // return false; - // } - // } + if (!Config.showConflictingOptionsWarnings()) + return true; + + // Build a map of option spelling -> last seen index, for all args and -z + // sub-options, so that conflicting pairs can be checked uniformly. + llvm::StringMap SeenOpts; + unsigned OptIndex = 0; + for (llvm::opt::Arg *Arg : Args) { + StringRef Spelling = Arg->getSpelling(); + // Options with Aliasses or values + switch (Arg->getOption().getID()) { + case T::export_dynamic: + Spelling = "--export-dynamic/-E"; + break; + case T::fat_lto_objects: + Spelling = "--[f]fat-lto-objects"; + break; + case T::no_fat_lto_objects: + Spelling = "--[f]no-fat-lto-objects"; + break; + case T::omagic: + Spelling = "--omagic/-N"; + break; + case T::T: + Spelling = "-T/--script"; + break; + case T::enable_threads: + Spelling = "--enable-threads"; + break; + case T::static_link: + Spelling = "--static/--Bstatic/--dn/--non_shared"; + break; + case T::Bdynamic: + Spelling = "-Bdynamic/--call_shared/--dy"; + break; + case T::shared: + Spelling = "--shared/--Bshareable"; + break; + case T::W: + case T::dash_z: + Spelling = Arg->getValue(); + break; + default: + break; + } + SeenOpts[Spelling] = OptIndex++; + } + + // Table of conflicting option pairs. Each entry is {Opt1, Opt2} where + // the option with the higher index in SeenOpts is the winner (last wins). + const std::pair ConflictingOpts[] = { + // clang-format off + {"--fatal-warnings", "--no-fatal-warnings"}, + {"--pie", "--no-pie"}, + {"--export-dynamic/-E", "--no-export-dynamic"}, + {"--warn-shared-textrel", "--no-warn-shared-textrel"}, + {"--enable-new-dtags", "--disable-new-dtags"}, + {"--enable-linker-version", "--disable-linker-version"}, + {"--record-command-line", "--no-record-command-line"}, + {"--warn-mismatch", "--no-warn-mismatch"}, + {"--[f]fat-lto-objects", "--[f]no-fat-lto-objects"}, + {"--align-segments", "--no-align-segments"}, + {"--align-segments", "--omagic/-N"}, + {"--align-segments", "-T/--script"}, + {"--fatal-internal-errors", "--no-fatal-internal-errors"}, + {"--gc-sections", "--no-gc-sections"}, + {"--check-sections", "--no-check-sections"}, + {"--omagic/-N", "--no-omagic"}, + {"--threads", "--no-threads"}, + {"--enable-threads", "--no-threads"}, + {"--enable-threads", "--threads"}, + {"--thread-count", "--no-threads"}, + {"--demangle", "--no-demangle"}, + {"--demangle-style", "--demangle"}, + {"--demangle-style", "--no-demangle"}, + {"--emit-relocs", "--no-emit-relocs"}, + {"--emit-relocs-llvm", "--no-emit-relocs"}, + {"--emit-relocs-llvm", "--shared/--Bshareable"}, + {"--emit-relocs-llvm", "--pie"}, + {"--emit-relocs-llvm", "-r"}, + {"--emit-relocs", "--emit-relocs-llvm"}, + {"--emit-relocs", "--shared/--Bshareable"}, + {"--emit-relocs", "--pie"}, + {"--emit-relocs", "-r"}, + {"--symdef", "--shared/--Bshareable"}, + {"--symdef", "--pie"}, + {"--symdef", "-r"}, + {"--symdef-file", "--shared/--Bshareable"}, + {"--symdef-file", "--pie"}, + {"--symdef-file", "-r"}, + {"--static/--Bstatic/--dn/--non_shared", "-Bdynamic/--call_shared/--dy"}, + {"--static/--Bstatic/--dn/--non_shared", "--dynamic"}, + {"--static/--Bstatic/--dn/--non_shared", "--shared/--Bshareable"}, + {"--static/--Bstatic/--dn/--non_shared", "-r"}, + {"-Bdynamic/--call_shared/--dy", "--dynamic"}, + {"-Bdynamic/--call_shared/--dy", "--shared/--Bshareable"}, + {"-Bdynamic/--call_shared/--dy", "-r"}, + {"--dynamic", "--shared/--Bshareable"}, + {"--dynamic", "-r"}, + {"--shared/--Bshareable", "-r"}, + {"--Bsymbolic", "--static/--Bstatic/--dn/--non_shared"}, + {"--Bsymbolic-functions", "--static/--Bstatic/--dn/--non_shared"}, + {"combreloc", "nocombreloc"}, + {"relro", "norelro"}, + {"lazy", "now"}, + {"lazy", "--static/--Bstatic/--dn/--non_shared"}, + {"now", "--static/--Bstatic/--dn/--non_shared"}, + {"text", "notext"}, + {"execstack", "noexecstack"}, + {"separate-code", "noseparate-code"}, + {"separate-code", "separate-loadable-segments"}, + {"noseparate-code", "separate-loadable-segments"}, + {"linker-script", "no-linker-script"}, + {"error", "no-error"}, + {"attribute-mix", "no-attribute-mix"}, + {"archive-file", "no-archive-file"}, + {"linker-script-memory", "no-linker-script-memory"}, + {"bad-dot-assignments", "no-bad-dot-assignments"}, + {"whole-archive", "no-whole-archive"}, + {"osabi", "no-osabi"}, + {"conflicting-options", "no-conflicting-options"}, + // clang-format on + }; + for (auto [Opt1, Opt2] : ConflictingOpts) { + auto It1 = SeenOpts.find(Opt1); + auto It2 = SeenOpts.find(Opt2); + if (It1 == SeenOpts.end() || It2 == SeenOpts.end()) + continue; + + // Special cases + + // Threads won so --thread-count is not disabled. + if (Config.options().threadsEnabled() && Opt1 == "--thread-count") + continue; + + bool Opt1Won = It1->second > It2->second; + // -T and -N require alignment to be false, so they will take precedence + // over + // --align-segments. + if (Opt1 == "--align-segments" && + (Opt2 == "--omagic/-N" || Opt2 == "-T/--script")) + Opt1Won = false; + // --thread-count is disabled if --no-threads + else if (Opt1 == "--thread-count" && Opt2 == "--no-threads") + Opt1Won = false; + // emit relocs is disabled if -shared,-pie,-r + else if ((Opt1 == "--emit-relocs" || Opt1 == "--emit-relocs-llvm") && + (Opt2 == "--shared/--Bshareable" || Opt2 == "--pie" || + Opt2 == "-r")) + Opt1Won = false; + // symdef is disabled if -shared,-pie,-r + else if ((Opt1 == "--symdef" || Opt1 == "--symdef-file") && + (Opt2 == "--shared/--Bshareable" || Opt2 == "--pie" || + Opt2 == "-r")) + Opt1Won = false; + // -Bsymbolic/-Bsymbolic-functions are disabled if -static + else if ((Opt1 == "--Bsymbolic" || Opt1 == "--Bsymbolic-functions") && + Opt2 == "--static/--Bstatic/--dn/--non_shared") + Opt1Won = false; + // lazy is disabled if -static,-r + else if (Opt1 == "lazy" && + (Opt2 == "--static/--Bstatic/--dn/--non_shared" || Opt2 == "-r")) + Opt1Won = false; + // now is disabled if -static + else if (Opt1 == "now" && Opt2 == "--static/--Bstatic/--dn/--non_shared") + Opt1Won = false; + + StringRef Enabled = Opt1Won ? Opt1 : Opt2; + StringRef Disabled = Opt1Won ? Opt2 : Opt1; + Config.raise(Diag::warn_incompatible_option) << Disabled << Enabled; + } return true; } @@ -1021,8 +1184,6 @@ bool GnuLdDriver::processOptions(llvm::opt::InputArgList &Args) { // Disable emit relocs if -shared/-pie/relocatable if (Config.options().emitRelocs() && !conflictingOption.empty()) { - Config.raise(Diag::warn_incompatible_option) - << "-emit-relocs" << conflictingOption; Config.options().setEmitRelocs(false); Config.options().setEmitGNUCompatRelocs(false); } @@ -1100,11 +1261,8 @@ bool GnuLdDriver::processOptions(llvm::opt::InputArgList &Args) { } // Disable symdef if -shared/-pie/-relocatable - if (Config.options().symDef() && !conflictingOption.empty()) { - Config.raise(Diag::warn_incompatible_option) - << "-symdef/--symdef-file" << conflictingOption; + if (Config.options().symDef() && !conflictingOption.empty()) Config.options().setSymDef(false); - } // --unresolved-symbols=ignore-all,report-all,ignore-in-object-files, // ignore-in-shared-libs diff --git a/lib/LinkerWrapper/RISCVLinkDriver.cpp b/lib/LinkerWrapper/RISCVLinkDriver.cpp index 14f6720d4..c496b391b 100644 --- a/lib/LinkerWrapper/RISCVLinkDriver.cpp +++ b/lib/LinkerWrapper/RISCVLinkDriver.cpp @@ -189,6 +189,34 @@ RISCVLinkDriver::parseOptions(ArrayRef Args, Config.options().setUnknownOptions( ArgList.getAllArgValues(OPT_RISCVLinkOptTable::UNKNOWN)); + if (!Config.showConflictingOptionsWarnings()) + return {}; + + llvm::StringMap SeenOpts; + unsigned OptIndex = 0; + for (const llvm::opt::Arg *Arg : ArgList) + SeenOpts[Arg->getSpelling()] = OptIndex++; + + // Table of RISCV-specific conflicting option pairs (last wins). + const std::pair ConflictingOpts[] = { + // clang-format off + {"--relax", "--no-relax"}, + {"--relax-xqci", "--no-relax-xqci"}, + {"--relax-tbljal", "--no-relax-tbljal"}, + // clang-format on + }; + for (auto [Opt1, Opt2] : ConflictingOpts) { + auto It1 = SeenOpts.find(Opt1); + auto It2 = SeenOpts.find(Opt2); + if (It1 == SeenOpts.end() || It2 == SeenOpts.end()) + continue; + + bool Opt1Won = It1->second > It2->second; + StringRef Enabled = Opt1Won ? Opt1 : Opt2; + StringRef Disabled = Opt1Won ? Opt2 : Opt1; + Config.raise(Diag::warn_incompatible_option) << Disabled << Enabled; + } + return {}; } diff --git a/test/AArch64/standalone/EmitRelocs/EmitRelocs.test b/test/AArch64/standalone/EmitRelocs/EmitRelocs.test index 8b239def2..c05c34e8a 100644 --- a/test/AArch64/standalone/EmitRelocs/EmitRelocs.test +++ b/test/AArch64/standalone/EmitRelocs/EmitRelocs.test @@ -5,9 +5,7 @@ RUN: %clang %clangopts -target aarch64 -c %p/test.c -g -gdwarf-4 -o %t_g1.o RUN: %clang %clangopts -target aarch64 -c %p/bar.c -g -gdwarf-4 -o %t_g2.o -RUN: %link %linkopts -march=aarch64 -static %t2.o -emit-relocs -r -o %t1.out 2>&1 | %filecheck %s -check-prefix=PARTIAL RUN: %link %linkopts -march=aarch64 -static -Ttext=0x1000 %t1.o %t2.o -emit-relocs -o %t2.out -RUN: %link %linkopts -march=aarch64 -shared -Ttext=0x1000 %t1.o %t2.o -emit-relocs -o %t2.so 2>&1 | %filecheck %s --check-prefix=SO RUN: %link %linkopts -march=aarch64 -static -Ttext=0x1000 %t1.o %t2.o -T %p/test.ld -emit-relocs -o %t3.out RUN: %link %linkopts -march=aarch64 -static -Ttext=0x1000 %t_g1.o %t_g2.o -emit-relocs -o %t3_g.out @@ -18,8 +16,6 @@ RUN: %readelf -r %t3.out | %filecheck %s --check-prefix=SCRIPT RUN: %readelf -r %t3_g.out | %filecheck %s --check-prefix=DEBUG RUN: %readelf -W -S %t2.out | %filecheck %s --check-prefix=SECT -PARTIAL: Warning: Option `--emit-relocs' is disabled as it is incompatible with `-relocatable` - OBJ1: Relocation section '.relamycode_1' at offset {{.*}} contains OBJ1: x + 0 OBJ1: x + 0 @@ -60,8 +56,6 @@ EXE-DAG: {{[0-9a-f]+}} {{.*}} y + 0 EXE-DAG: {{[0-9a-f]+}} {{.*}} x + 0 EXE-DAG: {{[0-9a-f]+}} {{.*}} x + 0 -SO: Option `--emit-relocs' is disabled as it is incompatible with `-shared` - SCRIPT: Relocation section '.relaCODE' at offset {{.*}} contains SCRIPT-DAG: {{[0-9a-f]+}} {{.*}} x + 0 SCRIPT-DAG: {{[0-9a-f]+}} {{.*}} x + 0 diff --git a/test/Common/standalone/FatalWarnings/fatalwarnings.test b/test/Common/standalone/FatalWarnings/fatalwarnings.test index ffc78838f..1245631d4 100644 --- a/test/Common/standalone/FatalWarnings/fatalwarnings.test +++ b/test/Common/standalone/FatalWarnings/fatalwarnings.test @@ -1,7 +1,7 @@ # This test checks the result of using the switch # --fatal-warnings/--no-fatal-warnings. RUN: %clang %clangopts -c %p/Inputs/1.c -fPIC -o %t1.o -RUN: %not %link %linkopts -shared %t1.o --emit-relocs-llvm -o %t2.so.1 --fatal-warnings 2>&1 | %filecheck %s -check-prefix=FATAL -RUN: %link %linkopts -shared %t1.o --emit-relocs-llvm -o %t2.so.2 --no-fatal-warnings 2>&1 | %filecheck %s -check-prefix=WARN -#FATAL: Fatal: Option `--emit-relocs' is disabled -#WARN: Warning: Option `--emit-relocs' is disabled +RUN: %not %link %linkopts -Wconflicting-options -shared %t1.o --emit-relocs-llvm -o %t2.so.1 --fatal-warnings 2>&1 | %filecheck %s -check-prefix=FATAL +RUN: %link %linkopts -Wconflicting-options -shared %t1.o --emit-relocs-llvm -o %t2.so.2 --no-fatal-warnings 2>&1 | %filecheck %s -check-prefix=WARN +#FATAL: Fatal: Option `--emit-relocs-llvm' is disabled +#WARN: Warning: Option `--emit-relocs-llvm' is disabled diff --git a/test/Common/standalone/FlagOverwrite/FlagOverwrite.test b/test/Common/standalone/FlagOverwrite/FlagOverwrite.test index fb340372f..07368868f 100644 --- a/test/Common/standalone/FlagOverwrite/FlagOverwrite.test +++ b/test/Common/standalone/FlagOverwrite/FlagOverwrite.test @@ -1,152 +1,379 @@ #---FlagOverwrite.test--------------------- Executable --------------------# -UNSUPPORTED: x86 #BEGIN_COMMENT # Check that the last option is the one being used for mutually exclusive flags. #END_COMMENT #START_TEST COM: --[no-]fatal-warnings -RUN: %clang %clangopts -ffunction-sections -c %p/Inputs/1.cpp -o %t.1.o -RUN: %not %link %linkopts -o %t.1.out -shared -z=notext %t.1.o --warn-shared-textrel --no-fatal-warnings --fatal-warnings 2>&1 | %filecheck %s -check-prefix=FATAL -RUN: %link %linkopts -o %t.1.out -shared -z=notext %t.1.o --warn-shared-textrel --fatal-warnings --no-fatal-warnings 2>&1 | %filecheck %s -check-prefix=NOFATAL +RUN: %clang %clangopts -c %p/Inputs/1.c -o %t.1.o +RUN: %not %link %linkopts %t.1.o -Wconflicting-options --no-fatal-warnings --fatal-warnings 2>&1 | \ +RUN: %filecheck %s -check-prefix=FATAL +RUN: %link %linkopts %t.1.o -Wconflicting-options --fatal-warnings --no-fatal-warnings 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--fatal-warnings -DENABLED=--no-fatal-warnings -COM: --[no-]check-sections -RUN: %not %link %linkopts -T %p/Inputs/1.script %t.1.o -o %t.1.out --no-check-sections --check-sections --verbose 2>&1 | %filecheck %s -check-prefix=CHECKSECT -RUN: %link %linkopts -T %p/Inputs/1.script %t.1.o -o %t.1.out --check-sections --no-check-sections --verbose 2>&1 | %filecheck %s -check-prefix=NOCHECKSECT +COM: --[no-]pie +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-pie --pie 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-pie -DENABLED=--pie +RUN: %link %linkopts %t.1.o -Wconflicting-options --pie --no-pie 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--pie -DENABLED=--no-pie -COM: --[no-]gc-sections -RUN: %link %linkopts %t.1.o -T %p/Inputs/2.script --no-gc-sections --gc-sections -o %t.1.out -M 2>&1 | %filecheck %s -check-prefix=GCSECT -RUN: %link %linkopts %t.1.o -T %p/Inputs/2.script --gc-sections --no-gc-sections -o %t.1.out -M 2>&1 | %filecheck %s -check-prefix=NOGCSECT +COM: --[no-]export-dynamic, -E +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-export-dynamic --export-dynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-export-dynamic -DENABLED=--export-dynamic/-E +RUN: %link %linkopts %t.1.o -Wconflicting-options --export-dynamic --no-export-dynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--export-dynamic/-E -DENABLED=--no-export-dynamic + +COM: --[no-]warn-shared-textrel +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-warn-shared-textrel --warn-shared-textrel 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-warn-shared-textrel -DENABLED=--warn-shared-textrel +RUN: %link %linkopts %t.1.o -Wconflicting-options --warn-shared-textrel --no-warn-shared-textrel 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--warn-shared-textrel -DENABLED=--no-warn-shared-textrel + +COM: --[disable/enable]-new-dtags +RUN: %link %linkopts %t.1.o -Wconflicting-options --disable-new-dtags --enable-new-dtags 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--disable-new-dtags -DENABLED=--enable-new-dtags +RUN: %link %linkopts %t.1.o -Wconflicting-options --enable-new-dtags --disable-new-dtags 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--enable-new-dtags -DENABLED=--disable-new-dtags + +COM: --[disable/enable]-linker-version +RUN: %link %linkopts %t.1.o -Wconflicting-options --disable-linker-version --enable-linker-version 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--disable-linker-version -DENABLED=--enable-linker-version +RUN: %link %linkopts %t.1.o -Wconflicting-options --enable-linker-version --disable-linker-version 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--enable-linker-version -DENABLED=--disable-linker-version + +COM: --[no-]record-command-line +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-record-command-line --record-command-line 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-record-command-line -DENABLED=--record-command-line +RUN: %link %linkopts %t.1.o -Wconflicting-options --record-command-line --no-record-command-line 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--record-command-line -DENABLED=--no-record-command-line + +COM: --[no-]warn-mismatch +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-warn-mismatch --warn-mismatch 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-warn-mismatch -DENABLED=--warn-mismatch +RUN: %link %linkopts %t.1.o -Wconflicting-options --warn-mismatch --no-warn-mismatch 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--warn-mismatch -DENABLED=--no-warn-mismatch + +COM: --[no-]fat-lto-objects / -f[no-]fat-lto-objects +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-fat-lto-objects --fat-lto-objects 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--[f]no-fat-lto-objects -DENABLED=--[f]fat-lto-objects +RUN: %link %linkopts %t.1.o -Wconflicting-options --fat-lto-objects --no-fat-lto-objects 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--[f]fat-lto-objects -DENABLED=--[f]no-fat-lto-objects COM: --[no-]align-segments -RUN: %clang %clangopts -ffunction-sections -c %p/Inputs/2.cpp -o %t.2.o -RUN: %link %linkopts --rosegment --no-align-segments --align-segments %t.2.o -o %t.2.out --noinhibit-exec -RUN: %readelf -l -W %t.2.out | %filecheck %s -check-prefix=ALIGN -RUN: %link %linkopts --rosegment --align-segments --no-align-segments %t.2.o -o %t.2.out --noinhibit-exec -RUN: %readelf -l -W %t.2.out | %filecheck %s -check-prefix=NOALIGN -COM: Special case. omagic takes precendence over --align-segments -RUN: %link %linkopts -o %t.1.out %t.1.o --no-omagic --omagic --align-segments -z max-page-size=0x1000 -RUN: %readelf --elf-output-style LLVM -l -W %t.1.out 2>&1 | %filecheck %s -check-prefix=OMAGIC +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-align-segments --align-segments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-align-segments -DENABLED=--align-segments +RUN: %link %linkopts %t.1.o -Wconflicting-options --align-segments --no-align-segments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--align-segments -DENABLED=--no-align-segments +COM: Special case. --omagic and --script take precendence over --align-segments +RUN: %link %linkopts %t.1.o -Wconflicting-options --omagic --align-segments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--align-segments -DENABLED=--omagic/-N +RUN: %link %linkopts %t.1.o -Wconflicting-options -T %p/Inputs/1.script --align-segments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--align-segments -DENABLED=-T/--script + +COM: --[no-]fatal-internal-errors +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-fatal-internal-errors --fatal-internal-errors 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-fatal-internal-errors -DENABLED=--fatal-internal-errors +RUN: %link %linkopts %t.1.o -Wconflicting-options --fatal-internal-errors --no-fatal-internal-errors 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--fatal-internal-errors -DENABLED=--no-fatal-internal-errors + +COM: --[no-]gc-sections +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-gc-sections --gc-sections 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-gc-sections -DENABLED=--gc-sections +RUN: %link %linkopts %t.1.o -Wconflicting-options --gc-sections --no-gc-sections 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--gc-sections -DENABLED=--no-gc-sections + +COM: --[no-]check-sections +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-check-sections --check-sections 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-check-sections -DENABLED=--check-sections +RUN: %link %linkopts %t.1.o -Wconflicting-options --check-sections --no-check-sections 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--check-sections -DENABLED=--no-check-sections + +COM: --[no-]omagic, -N +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-omagic --omagic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-omagic -DENABLED=--omagic/-N +RUN: %link %linkopts %t.1.o -Wconflicting-options --omagic --no-omagic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--omagic/-N -DENABLED=--no-omagic + +COM: emit relocs is disabled if -shared +RUN: %link %linkopts %t.1.o -Wconflicting-options -shared --emit-relocs-llvm 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs-llvm -DENABLED=--shared/--Bshareable +RUN: %link %linkopts %t.1.o -Wconflicting-options -shared --emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs -DENABLED=--shared/--Bshareable + +COM: emit relocs is disabled if -pie +RUN: %link %linkopts %t.1.o -Wconflicting-options -pie --emit-relocs-llvm 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs-llvm -DENABLED=--pie +RUN: %link %linkopts %t.1.o -Wconflicting-options -pie --emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs -DENABLED=--pie + +COM: emit relocs is disabled if -r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --emit-relocs-llvm 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs-llvm -DENABLED=-r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs -DENABLED=-r + +COM: Disable --symdef/--symdef-file if -shared +RUN: %link %linkopts %t.1.o -Wconflicting-options -shared --symdef 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--symdef -DENABLED=--shared/--Bshareable +RUN: %link %linkopts %t.1.o -Wconflicting-options -shared --symdef-file %t.1.symdef 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--symdef-file -DENABLED=--shared/--Bshareable + +COM: Disable --symdef/--symdef-file if -pie +RUN: %link %linkopts %t.1.o -Wconflicting-options -pie --symdef 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--symdef -DENABLED=--pie +RUN: %link %linkopts %t.1.o -Wconflicting-options -pie --symdef-file %t.1.symdef 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--symdef-file -DENABLED=--pie + +COM: Disable --symdef/--symdef-file if -r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --symdef 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--symdef -DENABLED=-r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --symdef-file %t.1.symdef 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--symdef-file -DENABLED=-r + +COM: --[no-]threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-threads --threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-threads -DENABLED=--threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --threads --no-threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--threads -DENABLED=--no-threads + +COM: --threads, --enable-threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --enable-threads --threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--enable-threads -DENABLED=--threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --threads --enable-threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--threads -DENABLED=--enable-threads + +COM: --no-threads, --enable-threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --enable-threads --no-threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--enable-threads -DENABLED=--no-threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-threads --enable-threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-threads -DENABLED=--enable-threads + +COM: --thread-count is disabled if --no-threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --thread-count=4 --no-threads 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--thread-count -DENABLED=--no-threads +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-threads --thread-count=4 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--thread-count -DENABLED=--no-threads + +COM: --[no-]demangle +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-demangle --demangle 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-demangle -DENABLED=--demangle +RUN: %link %linkopts %t.1.o -Wconflicting-options --demangle --no-demangle 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--demangle -DENABLED=--no-demangle + +COM: --demangle, --demangle-style +RUN: %link %linkopts %t.1.o -Wconflicting-options --demangle-style=demangle --demangle 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--demangle-style -DENABLED=--demangle +RUN: %link %linkopts %t.1.o -Wconflicting-options --demangle --demangle-style=demangle 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--demangle -DENABLED=--demangle-style + +COM: --no-demangle, --demangle-style +RUN: %link %linkopts %t.1.o -Wconflicting-options --demangle-style=demangle --no-demangle 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--demangle-style -DENABLED=--no-demangle +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-demangle --demangle-style=demangle 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-demangle -DENABLED=--demangle-style COM: --[no-]emit-relocs -RUN: %link %linkopts %t.2.o -o %t.2.out --no-emit-relocs --emit-relocs --noinhibit-exec -RUN: %readelf -r %t.2.out | %filecheck %s -check-prefix=RELOCS -RUN: %link %linkopts %t.2.o -o %t.2.out --emit-relocs --no-emit-relocs --noinhibit-exec -RUN: %readelf -r %t.2.out | %filecheck %s -check-prefix=NORELOCS - -COM: --[no-]threads, --enable-threads -RUN: %link %linkopts %t.1.o -o %t.1.out --emit-relocs --enable-threads=all --no-threads --threads --trace=threads 2>&1 | %filecheck %s -check-prefix=THREADS -RUN: %link %t.1.o -o %t.1.out --emit-relocs --enable-threads=all --threads --no-threads --trace=threads 2>&1 | %filecheck %s -check-prefix=NOTHREADS -RUN: %link %linkopts %t.1.o -o %t.1.out --emit-relocs --no-threads --threads --enable-threads=all --trace=threads 2>&1 | %filecheck %s -check-prefix=GLOBALTHREADS - -COM: --[no-]fat-lto-objects -RUN: printf "eld\n" > %t.invalid -RUN: %objcopy --add-section=.llvm.lto=%t.invalid --set-section-flags=.llvm.lto=exclude --set-section-type=.llvm.lto=0x6fff4c0c %t.1.o %t.fat.invalid.o -RUN: %not %link -r %t.fat.invalid.o -o %t1.out --no-fat-lto-objects --fat-lto-objects --trace=lto 2>&1 | %filecheck %s -check-prefix=FATLTO -RUN: %link -r %t.fat.invalid.o -o %t1.out --fat-lto-objects --no-fat-lto-objects --trace=lto 2>&1 | %filecheck %s -check-prefix=NOFATLTO +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-emit-relocs --emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-emit-relocs -DENABLED=--emit-relocs +RUN: %link %linkopts %t.1.o -Wconflicting-options --emit-relocs --no-emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs -DENABLED=--no-emit-relocs -COM: --[no-]warn-shared-textrel -RUN: %link %linkopts -o %t.1.out -shared -z=notext %t.1.o --no-warn-shared-textrel --warn-shared-textrel 2>&1 | %filecheck %s -check-prefix=TEXTREL -RUN: %link %linkopts -o %t.1.out -shared -z=notext %t.1.o --warn-shared-textrel --no-warn-shared-textrel 2>&1 | %filecheck %s -check-prefix=NOTEXTREL -allow-empty +COM: --emit-relocs, --emit-relocs-llvm +RUN: %link %linkopts %t.1.o -Wconflicting-options --emit-relocs-llvm --emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs-llvm -DENABLED=--emit-relocs +RUN: %link %linkopts %t.1.o -Wconflicting-options --emit-relocs --emit-relocs-llvm 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs -DENABLED=--emit-relocs-llvm -COM: --[no-]demangle, --demangle-style -RUN: %link %linkopts -o %t.1.out %t.1.o --verbose --demangle-style=demangle --no-demangle --demangle 2>&1 | %filecheck %s -check-prefix=DEMANGLE -RUN: %link %linkopts -o %t.1.out %t.1.o --verbose --demangle-style=demangle --demangle --no-demangle 2>&1 | %filecheck %s -check-prefix=NODEMANGLE -RUN: %link %linkopts -o %t.1.out %t.1.o --verbose --demangle --no-demangle --demangle-style=demangle 2>&1 | %filecheck %s -check-prefix=DEMANGLE +COM: --no-emit-relocs, --emit-relocs-llvm +RUN: %link %linkopts %t.1.o -Wconflicting-options --emit-relocs-llvm --no-emit-relocs 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--emit-relocs-llvm -DENABLED=--no-emit-relocs +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-emit-relocs --emit-relocs-llvm 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-emit-relocs -DENABLED=--emit-relocs-llvm -COM: --[no-]omagic -RUN: %link %linkopts -o %t.1.out %t.1.o --no-omagic --omagic -z max-page-size=0x1000 -RUN: %readelf --elf-output-style LLVM -l -W %t.1.out 2>&1 | %filecheck %s -check-prefix=OMAGIC -RUN: %link %linkopts -o %t.1.out %t.1.o --omagic -z max-page-size=0x1000 --no-omagic -RUN: %readelf --elf-output-style LLVM -l -W %t.1.out 2>&1 | %filecheck %s -check-prefix=NOOMAGIC +COM: -static, --Bsymbolic +RUN: %link %linkopts %t.1.o -Wconflicting-options --static --Bsymbolic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--Bsymbolic -DENABLED=--static/--Bstatic/--dn/--non_shared +RUN: %link %linkopts %t.1.o -Wconflicting-options --Bsymbolic --static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--Bsymbolic -DENABLED=--static/--Bstatic/--dn/--non_shared -COM: --[disable/enable]-new-dtags -RUN: %link %linkopts -shared %t.1.o -o %t.1.so -z now --disable-new-dtags --enable-new-dtags -RUN: %readelf -d %t.1.so | %filecheck %s --check-prefix=NEWDTAG -RUN: %link %linkopts -shared %t.1.o -o %t.1.so -z now --enable-new-dtags --disable-new-dtags -RUN: %readelf -d %t.1.so | %filecheck %s --check-prefix=NONEWDTAG +COM: -static, --Bsymbolic-functions +RUN: %link %linkopts %t.1.o -Wconflicting-options --static --Bsymbolic-functions 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--Bsymbolic-functions -DENABLED=--static/--Bstatic/--dn/--non_shared +RUN: %link %linkopts %t.1.o -Wconflicting-options --Bsymbolic-functions --static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--Bsymbolic-functions -DENABLED=--static/--Bstatic/--dn/--non_shared -COM: --[disable/enable]-linker-version -RUN: %link %linkopts %t.1.o -T %p/Inputs/3.script -o %t.1.out --disable-linker-version --enable-linker-version -RUN: %readelf -S -W %t.1.out | %filecheck %s --check-prefix=ENABLEDLINKVER -RUN: %link %linkopts %t.1.o -T %p/Inputs/3.script -o %t.1.out --disable-linker-version --disable-linker-version -RUN: %readelf -S -W %t.1.out | %filecheck %s --check-prefix=NOENABLEDLINKVER +COM: combreloc, nocombreloc +RUN: %link %linkopts %t.1.o -Wconflicting-options -znocombreloc -zcombreloc 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=nocombreloc -DENABLED=combreloc +RUN: %link %linkopts %t.1.o -Wconflicting-options -zcombreloc -znocombreloc 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=combreloc -DENABLED=nocombreloc -COM: --[no-]record-command-line -RUN: %link %linkopts %t.1.o -o %t.1.out --no-record-command-line --record-command-line -RUN: %readelf -p .comment %t.1.out | %filecheck %s --check-prefix=RECORDCOMMAND -RUN: %link %linkopts %t.1.o -o %t.1.out --record-command-line --no-record-command-line -RUN: %readelf -p .comment %t.1.out | %filecheck %s --check-prefix=NORECORDCOMMAND +COM: relro, norelro +RUN: %link %linkopts %t.1.o -Wconflicting-options -znorelro -zrelro 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=norelro -DENABLED=relro +RUN: %link %linkopts %t.1.o -Wconflicting-options -zrelro -znorelro 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=relro -DENABLED=norelro -COM: --[no-]warn-mismatch -RUN: %yaml2obj %p/Inputs/2.yaml -o %t.2.o -RUN: %not %link %emulation %linkopts %t.1.o %t.2.o -o %t.1.out --no-warn-mismatch --warn-mismatch 2>&1 | %filecheck %s --check-prefix=WARNMISMATCH -RUN: %link %emulation %linkopts %t.1.o %t.2.o -o %t.1.out --warn-mismatch --no-warn-mismatch 2>&1 | %filecheck %s --check-prefix=NOWARNMISMATCH --allow-empty +COM: lazy, now +RUN: %link %linkopts %t.1.o -Wconflicting-options -znow -zlazy 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=now -DENABLED=lazy +RUN: %link %linkopts %t.1.o -Wconflicting-options -zlazy -znow 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=lazy -DENABLED=now -COM: --[no-]export-dynamic -RUN: %clang %clangopts -flto -c %p/Inputs/1.cpp -o %t.1.o -RUN: %link %linkopts --no-export-dynamic --export-dynamic %t.1.o -o %t.1.out -RUN: %readelf -s %t.1.out | %filecheck %s -check-prefix=EXPDYN -RUN: %link %linkopts --export-dynamic --no-export-dynamic %t.1.o -o %t.1.out -RUN: %readelf -s %t.1.out | %filecheck %s -check-prefix=NOEXPDYN +COM: text, notext +RUN: %link %linkopts %t.1.o -Wconflicting-options -znotext -ztext 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=notext -DENABLED=text +RUN: %link %linkopts %t.1.o -Wconflicting-options -ztext -znotext 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=text -DENABLED=notext -COM: --[no-]pie -RUN: %clang %clangopts -fPIC -c %p/Inputs/1.cpp -o %t.1.o -RUN: %link %linkopts %t.1.o -o %t.1.out --no-pie --pie -RUN: %readelf --file-header %t.1.out 2>&1 | %filecheck %s --check-prefix=PIE -RUN: %link %linkopts %t.1.o -o %t.1.out --pie --no-pie -RUN: %readelf --file-header %t.1.out 2>&1 | %filecheck %s --check-prefix=NOPIE +COM: execstack, noexecstack +RUN: %link %linkopts %t.1.o -Wconflicting-options -znoexecstack -zexecstack 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=noexecstack -DENABLED=execstack +RUN: %link %linkopts %t.1.o -Wconflicting-options -zexecstack -znoexecstack 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=execstack -DENABLED=noexecstack + +COM: separate-code, noseparate-code +RUN: %link %linkopts %t.1.o -Wconflicting-options -znoseparate-code -zseparate-code 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=noseparate-code -DENABLED=separate-code +RUN: %link %linkopts %t.1.o -Wconflicting-options -zseparate-code -znoseparate-code 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=separate-code -DENABLED=noseparate-code + +COM: separate-code, separate-loadable-segments +RUN: %link %linkopts %t.1.o -Wconflicting-options -zseparate-loadable-segments -zseparate-code 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=separate-loadable-segments -DENABLED=separate-code +RUN: %link %linkopts %t.1.o -Wconflicting-options -zseparate-code -zseparate-loadable-segments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=separate-code -DENABLED=separate-loadable-segments + +COM: noseparate-code, separate-loadable-segments +RUN: %link %linkopts %t.1.o -Wconflicting-options -zseparate-loadable-segments -znoseparate-code 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=separate-loadable-segments -DENABLED=noseparate-code +RUN: %link %linkopts %t.1.o -Wconflicting-options -znoseparate-code -zseparate-loadable-segments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=noseparate-code -DENABLED=separate-loadable-segments + +COM: lazy is disabled if -static +RUN: %link %linkopts %t.1.o -Wconflicting-options -static -zlazy 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=lazy -DENABLED=--static/--Bstatic/--dn/--non_shared +RUN: %link %linkopts %t.1.o -Wconflicting-options -zlazy -static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=lazy -DENABLED=--static/--Bstatic/--dn/--non_shared + +COM: now is disabled if -static +RUN: %link %linkopts %t.1.o -Wconflicting-options -static -znow 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=now -DENABLED=--static/--Bstatic/--dn/--non_shared +RUN: %link %linkopts %t.1.o -Wconflicting-options -znow -static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=now -DENABLED=--static/--Bstatic/--dn/--non_shared + +COM: --static vs -Bdynamic +RUN: %link %linkopts %t.1.o -Wconflicting-options --static -Bdynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--static/--Bstatic/--dn/--non_shared -DENABLED=-Bdynamic/--call_shared/--dy +RUN: %link %linkopts %t.1.o -Wconflicting-options -Bdynamic --static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-Bdynamic/--call_shared/--dy -DENABLED=--static/--Bstatic/--dn/--non_shared + +COM: --static vs --dynamic +RUN: %link %linkopts %t.1.o -Wconflicting-options --static --dynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--static/--Bstatic/--dn/--non_shared -DENABLED=--dynamic +RUN: %link %linkopts %t.1.o -Wconflicting-options --dynamic --static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--dynamic -DENABLED=--static/--Bstatic/--dn/--non_shared + +COM: --static vs --shared +RUN: %link %linkopts %t.1.o -Wconflicting-options --static --shared 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--static/--Bstatic/--dn/--non_shared -DENABLED=--shared/--Bshareable +RUN: %link %linkopts %t.1.o -Wconflicting-options --shared --static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--shared/--Bshareable -DENABLED=--static/--Bstatic/--dn/--non_shared + +COM: --static vs -r +RUN: %link %linkopts %t.1.o -Wconflicting-options --static -r 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--static/--Bstatic/--dn/--non_shared -DENABLED=-r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --static 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-r -DENABLED=--static/--Bstatic/--dn/--non_shared -FATAL: Fatal: Linking had errors ({{.*}}1.out) -NOFATAL-NOT: Fatal: Linking had errors +COM: -Bdynamic vs --dynamic +RUN: %link %linkopts %t.1.o -Wconflicting-options -Bdynamic --dynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-Bdynamic/--call_shared/--dy -DENABLED=--dynamic +RUN: %link %linkopts %t.1.o -Wconflicting-options --dynamic -Bdynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--dynamic -DENABLED=-Bdynamic/--call_shared/--dy -CHECKSECT: section .comment file range overlaps with .text -NOCHECKSECT-NOT: section .comment file range overlaps with .text +COM: -Bdynamic vs --shared +RUN: %link %linkopts %t.1.o -Wconflicting-options -Bdynamic --shared 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-Bdynamic/--call_shared/--dy -DENABLED=--shared/--Bshareable +RUN: %link %linkopts %t.1.o -Wconflicting-options --shared -Bdynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--shared/--Bshareable -DENABLED=-Bdynamic/--call_shared/--dy -GCSECT: # .text 0x0 -NOGCSECT-NOT: # .text 0x0 +COM: -Bdynamic vs -r +RUN: %link %linkopts %t.1.o -Wconflicting-options -Bdynamic -r 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-Bdynamic/--call_shared/--dy -DENABLED=-r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r -Bdynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-r -DENABLED=-Bdynamic/--call_shared/--dy -ALIGN: LOAD 0x00{{[0-9]}}000 {{.*}} 0x1000 -NOALIGN-NOT: LOAD 0x00{{[0-9]}}{{[1-9]}}+ {{.*}} 0x1000 +COM: --dynamic vs --shared +RUN: %link %linkopts %t.1.o -Wconflicting-options --dynamic --shared 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--dynamic -DENABLED=--shared/--Bshareable +RUN: %link %linkopts %t.1.o -Wconflicting-options --shared --dynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--shared/--Bshareable -DENABLED=--dynamic -RELOCS: Relocation section {{.*}} contains -NORELOCS: There are no relocations in this file +COM: --dynamic vs -r +RUN: %link %linkopts %t.1.o -Wconflicting-options --dynamic -r 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--dynamic -DENABLED=-r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --dynamic 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-r -DENABLED=--dynamic -THREADS: Threads Enabled -THREADS: Threads Disabled -NOTHREADS-NOT: Threads Enabled -NOTHREADS: Threads Disabled -GLOBALTHREADS: Threads Enabled -GLOBALTHREADS-NOT: Threads Disabled +COM: --shared vs -r +RUN: %link %linkopts %t.1.o -Wconflicting-options --shared -r 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--shared/--Bshareable -DENABLED=-r +RUN: %link %linkopts %t.1.o -Wconflicting-options -r --shared 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=-r -DENABLED=--shared/--Bshareable -FATLTO: Invalid embedded bitcode in section '.llvm.lto' -NOFATLTO-NOT: Invalid embedded bitcode in section '.llvm.lto' +COM: -Wlinker-script, -Wno-linker-script +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-linker-script -Wlinker-script 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-linker-script -DENABLED=linker-script +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wlinker-script -Wno-linker-script 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=linker-script -DENABLED=no-linker-script -TEXTREL: Warning: Add DT_TEXTREL in a shared object! -NOTEXTREL-NOT: Warning: Add DT_TEXTREL in a shared object! +COM: -Werror, -Wno-error +RUN: %not %link %linkopts %t.1.o -Wconflicting-options -Wno-error -Werror 2>&1 | \ +RUN: %filecheck %s -check-prefix=ERROR +RUN: %link %linkopts %t.1.o -Wconflicting-options -Werror -Wno-error 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=error -DENABLED=no-error -DEMANGLE: Verbose: Adding symbol foo() -NODEMANGLE: Verbose: Adding symbol _Z3foov +COM: -Wattribute-mix, -Wno-attribute-mix +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-attribute-mix -Wattribute-mix 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-attribute-mix -DENABLED=attribute-mix +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wattribute-mix -Wno-attribute-mix 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=attribute-mix -DENABLED=no-attribute-mix -OMAGIC-NOT: 4096 -NOOMAGIC: 4096 +COM: -Warchive-file, -Wno-archive-file +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-archive-file -Warchive-file 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-archive-file -DENABLED=archive-file +RUN: %link %linkopts %t.1.o -Wconflicting-options -Warchive-file -Wno-archive-file 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=archive-file -DENABLED=no-archive-file -NEWDTAG: 0x{{[0]+}}1e (FLAGS) BIND_NOW -NEWDTAG: 0x{{[0]*}}6ffffffb (FLAGS_1) NOW -NONEWDTAG: 0x{{[0]+}}18 (BIND_NOW) 0x1 -NONEWDTAG: 0x{{[0]*}}6ffffffb (FLAGS_1) NOW +COM: -Wlinker-script-memory, -Wno-linker-script-memory +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-linker-script-memory -Wlinker-script-memory 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-linker-script-memory -DENABLED=linker-script-memory +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wlinker-script-memory -Wno-linker-script-memory 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=linker-script-memory -DENABLED=no-linker-script-memory -ENABLEDLINKVER: .myver {{.*}} {{[0-9a-f]+}} {{.*}} -NOENABLEDLINKVER-NOT: .myver +COM: -Wbad-dot-assignments, -Wno-bad-dot-assignments +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-bad-dot-assignments -Wbad-dot-assignments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-bad-dot-assignments -DENABLED=bad-dot-assignments +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wbad-dot-assignments -Wno-bad-dot-assignments 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=bad-dot-assignments -DENABLED=no-bad-dot-assignments -RECORDCOMMAND: Command:{{.*}} --no-record-command-line --record-command-line -NORECORDCOMMAND-NOT: Command +COM: -Wwhole-archive, -Wno-whole-archive +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-whole-archive -Wwhole-archive 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-whole-archive -DENABLED=whole-archive +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wwhole-archive -Wno-whole-archive 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=whole-archive -DENABLED=no-whole-archive -WARNMISMATCH: Error: cannot recognize the format of file -NOWARNMISMATCH-NOT: Error: cannot recognize the format of file +COM: -Wosabi, -Wno-osabi +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-osabi -Wosabi 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-osabi -DENABLED=osabi +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wosabi -Wno-osabi 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=osabi -DENABLED=no-osabi -EXPDYN: {{.}} GLOBAL {{.*}} _Z3foov -NOEXPDYN-NOT: {{.}} GLOBAL {{.*}} _Z3foov +COM: -Wconflicting-options, -Wno-conflicting-options +RUN: %link %linkopts %t.1.o -Wconflicting-options -Wno-conflicting-options -Wconflicting-options 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=no-conflicting-options -DENABLED=conflicting-options -PIE: DYN (Shared object file) -NOPIE: EXEC (Executable file) +FATAL: Fatal: Option `--no-fatal-warnings' is disabled as it is incompatible with `--fatal-warnings` +ERROR: Error: Option `no-error' is disabled as it is incompatible with `error` +WARNING: Warning: Option `[[DISABLED]]' is disabled as it is incompatible with `[[ENABLED]]` #END_TEST \ No newline at end of file diff --git a/test/Common/standalone/FlagOverwrite/Inputs/1.cpp b/test/Common/standalone/FlagOverwrite/Inputs/1.c similarity index 100% rename from test/Common/standalone/FlagOverwrite/Inputs/1.cpp rename to test/Common/standalone/FlagOverwrite/Inputs/1.c diff --git a/test/Common/standalone/FlagOverwrite/Inputs/1.script b/test/Common/standalone/FlagOverwrite/Inputs/1.script index 07a1254e0..e69de29bb 100644 --- a/test/Common/standalone/FlagOverwrite/Inputs/1.script +++ b/test/Common/standalone/FlagOverwrite/Inputs/1.script @@ -1,10 +0,0 @@ -SECTIONS { - . = 0x80000; - .text : { - *(.text*) - . = ALIGN(64); - . = 0x80000+0x10-0x64; - } =0x3020 - .comment : { *(.comment) } - /DISCARD/ : { *(.ARM.exidx*) } -} \ No newline at end of file diff --git a/test/Common/standalone/FlagOverwrite/Inputs/2.cpp b/test/Common/standalone/FlagOverwrite/Inputs/2.cpp deleted file mode 100644 index f8e8766f8..000000000 --- a/test/Common/standalone/FlagOverwrite/Inputs/2.cpp +++ /dev/null @@ -1,6 +0,0 @@ -int printf(const char *, ...); -int a = 100; -int main() { - printf("Hello World"); - return 0; -} diff --git a/test/Common/standalone/FlagOverwrite/Inputs/2.script b/test/Common/standalone/FlagOverwrite/Inputs/2.script deleted file mode 100644 index 3604ef858..000000000 --- a/test/Common/standalone/FlagOverwrite/Inputs/2.script +++ /dev/null @@ -1,5 +0,0 @@ -SECTIONS { - .text : { - *(.text.foo) - } -} \ No newline at end of file diff --git a/test/Common/standalone/FlagOverwrite/Inputs/2.yaml b/test/Common/standalone/FlagOverwrite/Inputs/2.yaml deleted file mode 100644 index ec02199ec..000000000 --- a/test/Common/standalone/FlagOverwrite/Inputs/2.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- !ELF -FileHeader: - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: [[TYPE=ET_REL]] - Machine: EM_NONE -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - AddressAlign: 0x4 - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_WRITE, SHF_ALLOC ] - AddressAlign: 0x4 - - Name: .bss - Type: SHT_NOBITS - Flags: [ SHF_WRITE, SHF_ALLOC ] - AddressAlign: 0x4 - - Name: .comment - Type: SHT_PROGBITS - Flags: [ SHF_MERGE, SHF_STRINGS ] - AddressAlign: 0x1 - EntSize: 0x1 - Content: 004743433A20285562756E747520342E382E312D327562756E7475317E31302E30342E312920342E382E3100 - - Name: .note.GNU-stack - Type: SHT_PROGBITS - AddressAlign: 0x1 -Symbols: - - Name: 1.c - Type: STT_FILE - Index: SHN_ABS - - Name: .text - Type: STT_SECTION - Section: .text - - Name: .data - Type: STT_SECTION - Section: .data - - Name: .bss - Type: STT_SECTION - Section: .bss - - Name: .note.GNU-stack - Type: STT_SECTION - Section: .note.GNU-stack - - Name: .comment - Type: STT_SECTION - Section: .comment - - Name: a - Type: STT_OBJECT - Index: SHN_COMMON - Binding: STB_GLOBAL - Value: 0x4 - Size: 0x4 -... diff --git a/test/Common/standalone/FlagOverwrite/Inputs/3.script b/test/Common/standalone/FlagOverwrite/Inputs/3.script deleted file mode 100644 index c19317718..000000000 --- a/test/Common/standalone/FlagOverwrite/Inputs/3.script +++ /dev/null @@ -1,5 +0,0 @@ -SECTIONS -{ - .myver 0x100 : { LINKER_VERSION } - .text : { *(.text) } -} diff --git a/test/Common/standalone/SymDef/Incompatible/Incompatible.test b/test/Common/standalone/SymDef/Incompatible/Incompatible.test deleted file mode 100644 index c8d93bcaa..000000000 --- a/test/Common/standalone/SymDef/Incompatible/Incompatible.test +++ /dev/null @@ -1,13 +0,0 @@ -UNSUPPORTED: x86 -#---Incompatible.test--------------------------- Relocatable,Shared --------------------# -#BEGIN_COMMENT -# This checks that the linker is able to warn symdef usage with incompaible -# options -#END_COMMENT -#START_TEST -RUN: %clang %clangopts %p/Inputs/1.c -o %t1.1.o -c -RUN: %link %linkopts %t1.1.o --symdef -o %t2.out.1 -r 2>&1 | %filecheck %s -RUN: %link %linkopts %t1.1.o --symdef -o %t2.out.2 -shared 2>&1 | %filecheck %s -RUN: %link %linkopts %t1.1.o --symdef -o %t2.out.3 -pie 2>&1 | %filecheck %s -#CHECK: Option `--symdef/--symdef-file' is disabled as it is incompatible -#END_TEST diff --git a/test/Common/standalone/SymDef/Incompatible/Inputs/1.c b/test/Common/standalone/SymDef/Incompatible/Inputs/1.c deleted file mode 100644 index cab61f434..000000000 --- a/test/Common/standalone/SymDef/Incompatible/Inputs/1.c +++ /dev/null @@ -1,4 +0,0 @@ -int baz(); -int foo() { return 0; } -int bar() { return baz(); } -int baz() { return 0; } diff --git a/test/Common/standalone/SymDef/Incompatible/Inputs/x.symdef b/test/Common/standalone/SymDef/Incompatible/Inputs/x.symdef deleted file mode 100644 index 91f36f2e3..000000000 --- a/test/Common/standalone/SymDef/Incompatible/Inputs/x.symdef +++ /dev/null @@ -1,2 +0,0 @@ -## -0xc FUNC baz diff --git a/test/RISCV/standalone/FlagOverwrite/FlagOverwrite.test b/test/RISCV/standalone/FlagOverwrite/FlagOverwrite.test index d333d160c..f1b4d5df1 100644 --- a/test/RISCV/standalone/FlagOverwrite/FlagOverwrite.test +++ b/test/RISCV/standalone/FlagOverwrite/FlagOverwrite.test @@ -1,16 +1,27 @@ #---FlagOverwrite.test--------------------- Executable------------------# #BEGIN_COMMENT # Check that the last option is the one being used for mutually exclusive flags. -# Currently, it checks for: -# --[no-]relax #END_COMMENT #START_TEST -RUN: %clang %clangopts -c %p/Inputs/1.s -o %t1.1.o -RUN: %link %linkopts --emit-relocs --no-relax --relax -T %p/Inputs/script.t %t1.1.o -o %t1.out -RUN: %objdump --no-print-imm-hex -d %t1.out | %filecheck %s -check-prefix=RELAX -RUN: %link %linkopts --emit-relocs --relax --no-relax -T %p/Inputs/script.t %t1.1.o -o %t1.out -RUN: %objdump --no-print-imm-hex -d %t1.out | %filecheck %s -check-prefix=NORELAX +COM: --[no-]relax +RUN: %clang %clangopts -c %p/Inputs/1.c -o %t.1.o +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-relax --relax 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-relax -DENABLED=--relax +RUN: %link %linkopts %t.1.o -Wconflicting-options --relax --no-relax 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--relax -DENABLED=--no-relax -RELAX-NOT: auipc ra, 0 -NORELAX: auipc ra, 0 +COM: --[no-]relax-xqci +RUN: %clang %clangopts -c %p/Inputs/1.c -o %t.1.o +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-relax-xqci --relax-xqci 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-relax-xqci -DENABLED=--relax-xqci +RUN: %link %linkopts %t.1.o -Wconflicting-options --relax-xqci --no-relax-xqci 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--relax-xqci -DENABLED=--no-relax-xqci + +COM: --[no-]relax-tbljal +RUN: %link %linkopts %t.1.o -Wconflicting-options --no-relax-tbljal --relax-tbljal 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--no-relax-tbljal -DENABLED=--relax-tbljal +RUN: %link %linkopts %t.1.o -Wconflicting-options --relax-tbljal --no-relax-tbljal 2>&1 | \ +RUN: %filecheck %s -check-prefix=WARNING -DDISABLED=--relax-tbljal -DENABLED=--no-relax-tbljal + +WARNING: Warning: Option `[[DISABLED]]' is disabled as it is incompatible with `[[ENABLED]]` #END_TEST \ No newline at end of file diff --git a/test/RISCV/standalone/FlagOverwrite/Inputs/1.c b/test/RISCV/standalone/FlagOverwrite/Inputs/1.c new file mode 100644 index 000000000..05941aa02 --- /dev/null +++ b/test/RISCV/standalone/FlagOverwrite/Inputs/1.c @@ -0,0 +1 @@ +int foo() { return 0; } \ No newline at end of file diff --git a/test/RISCV/standalone/FlagOverwrite/Inputs/1.s b/test/RISCV/standalone/FlagOverwrite/Inputs/1.s deleted file mode 100644 index 9fb94ed21..000000000 --- a/test/RISCV/standalone/FlagOverwrite/Inputs/1.s +++ /dev/null @@ -1,20 +0,0 @@ -.section .text.foo -.globl foo -.type foo, @function -foo: - lui a5,%hi(bar) - lw a5,%lo(bar)(a5) - beqz a5,.L4 - call baz -.L4: - nop - -.section .text.baz -.globl baz -.type baz, @function -baz: - nop -.data -.globl bar -bar: - .word 1 diff --git a/test/RISCV/standalone/FlagOverwrite/Inputs/script.t b/test/RISCV/standalone/FlagOverwrite/Inputs/script.t deleted file mode 100644 index b8fe79646..000000000 --- a/test/RISCV/standalone/FlagOverwrite/Inputs/script.t +++ /dev/null @@ -1,9 +0,0 @@ -SECTIONS { - .text (0x1233000) : { - *(.text.foo) - *(.text.baz) - } - .data (0x12345600) : { - *(.data) - } -}