[lld] r326506 - Accept both `--foo bar` and `--foo=bar` styles options.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 1 15:06:10 PST 2018
Author: ruiu
Date: Thu Mar 1 15:06:10 2018
New Revision: 326506
URL: http://llvm.org/viewvc/llvm-project?rev=326506&view=rev
Log:
Accept both `--foo bar` and `--foo=bar` styles options.
GNU linkers by convention supports both `--foo bar` and `--foo=bar` styles
for all long options that take arguments.
Differential Revision: https://reviews.llvm.org/D43972
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/test/ELF/auxiliary.s
lld/trunk/test/ELF/pack-dyn-relocs.s
lld/trunk/test/ELF/sectionstart.s
lld/trunk/test/ELF/symbol-ordering-file.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=326506&r1=326505&r2=326506&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Mar 1 15:06:10 2018
@@ -772,7 +772,7 @@ void LinkerDriver::readConfigs(opt::Inpu
std::tie(Config->BuildId, Config->BuildIdVector) = getBuildId(Args);
- if (auto *Arg = Args.getLastArg(OPT_pack_dyn_relocs_eq)) {
+ if (auto *Arg = Args.getLastArg(OPT_pack_dyn_relocs)) {
StringRef S = Arg->getValue();
if (S == "android")
Config->AndroidPackDynRelocs = true;
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=326506&r1=326505&r2=326506&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Thu Mar 1 15:06:10 2018
@@ -4,7 +4,6 @@ include "llvm/Option/OptParser.td"
// two can precede the option name except those that start with 'o'.
class F<string name>: Flag<["--", "-"], name>;
class J<string name>: Joined<["--", "-"], name>;
-class S<string name>: Separate<["--", "-"], name>;
multiclass Eq<string name> {
def NAME: Separate<["--", "-"], name>;
@@ -16,7 +15,8 @@ multiclass B<string name, string help1,
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
}
-def auxiliary: S<"auxiliary">, HelpText<"Set DT_AUXILIARY field to the specified name">;
+defm auxiliary: Eq<"auxiliary">,
+ HelpText<"Set DT_AUXILIARY field to the specified name">;
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
@@ -67,7 +67,7 @@ defm as_needed: B<"as-needed",
"Always set DT_NEEDED for shared libraries">;
// -chroot doesn't have a help text because it is an internal option.
-def chroot: S<"chroot">;
+defm chroot: Eq<"chroot">;
def color_diagnostics: F<"color-diagnostics">,
HelpText<"Use colors in diagnostics">;
@@ -94,7 +94,7 @@ def discard_locals: F<"discard-locals">,
def discard_none: F<"discard-none">,
HelpText<"Keep all symbols in the symbol table">;
-def dynamic_linker: S<"dynamic-linker">,
+defm dynamic_linker: Eq<"dynamic-linker">,
HelpText<"Which dynamic linker to use">;
defm dynamic_list: Eq<"dynamic-list">,
@@ -227,7 +227,7 @@ def omagic: Flag<["--"], "omagic">, Meta
defm orphan_handling: Eq<"orphan-handling">,
HelpText<"Control how orphan sections are handled when linker script used">;
-def pack_dyn_relocs_eq: J<"pack-dyn-relocs=">, MetaVarName<"<format>">,
+defm pack_dyn_relocs: Eq<"pack-dyn-relocs">, MetaVarName<"<format>">,
HelpText<"Pack dynamic relocations in the given format (none or android)">;
defm pie: B<"pie",
@@ -258,7 +258,7 @@ defm retain_symbols_file: Eq<"retain-sym
defm script: Eq<"script">, HelpText<"Read linker script">;
-def section_start: S<"section-start">, MetaVarName<"<address>">,
+defm section_start: Eq<"section-start">, MetaVarName<"<address>">,
HelpText<"Set address of section">;
def shared: F<"shared">, HelpText<"Build a shared object">;
@@ -275,7 +275,7 @@ def strip_all: F<"strip-all">, HelpText<
def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
-def symbol_ordering_file: S<"symbol-ordering-file">,
+defm symbol_ordering_file: Eq<"symbol-ordering-file">,
HelpText<"Layout sections in the order specified by symbol file">;
defm sysroot: Eq<"sysroot">, HelpText<"Set the system root">;
@@ -350,12 +350,11 @@ def alias_define_common_dc: F<"dc">, Ali
def alias_define_common_dp: F<"dp">, Alias<define_common>;
def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>;
def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
-def alias_dynamic_linker_eq: J<"dynamic-linker=">, Alias<dynamic_linker>;
def alias_emit_relocs: Flag<["-"], "q">, Alias<emit_relocs>;
def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
def alias_export_dynamic_E: Flag<["-"], "E">, Alias<export_dynamic>;
def alias_filter: Separate<["-"], "F">, Alias<filter>;
-def alias_format_b: S<"b">, Alias<format>;
+def alias_format_b: Separate<["-"], "b">, Alias<format>;
def alias_library: JoinedOrSeparate<["-"], "l">, Alias<library>;
def alias_library_path: JoinedOrSeparate<["-"], "L">, Alias<library_path>;
def alias_no_pie_pic_executable: F<"no-pic-executable">, Alias<no_pie>;
@@ -373,8 +372,8 @@ def alias_strip_all: Flag<["-"], "s">, A
def alias_strip_debug_S: Flag<["-"], "S">, Alias<strip_debug>;
def alias_trace: Flag<["-"], "t">, Alias<trace>;
def alias_trace_symbol_y : JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>;
-def alias_Ttext_segment: S<"Ttext-segment">, Alias<Ttext>;
-def alias_Ttext_segment_eq: J<"Ttext-segment=">, Alias<Ttext>;
+def alias_Ttext_segment: Separate<["-", "--"], "Ttext-segment">, Alias<Ttext>;
+def alias_Ttext_segment_eq: Joined<["-", "--"], "Ttext-segment=">, Alias<Ttext>;
def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
def alias_version_V: Flag<["-"], "V">, Alias<version>;
@@ -394,7 +393,7 @@ def lto_newpm_passes: J<"lto-newpm-passe
def lto_partitions: J<"lto-partitions=">,
HelpText<"Number of LTO codegen partitions">;
def disable_verify: F<"disable-verify">;
-def mllvm: S<"mllvm">;
+defm mllvm: Eq<"mllvm">;
def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
HelpText<"YAML output file for optimization remarks">;
def opt_remarks_with_hotness: Flag<["--"], "opt-remarks-with-hotness">,
@@ -404,7 +403,7 @@ defm plugin_opt: Eq<"plugin-opt">,
def save_temps: F<"save-temps">;
def thinlto_cache_dir: J<"thinlto-cache-dir=">,
HelpText<"Path to ThinLTO cached object file directory">;
-def thinlto_cache_policy: S<"thinlto-cache-policy">,
+defm thinlto_cache_policy: Eq<"thinlto-cache-policy">,
HelpText<"Pruning policy for the ThinLTO cache">;
def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
@@ -430,8 +429,7 @@ def no_ctors_in_init_array: F<"no-ctors-
def no_keep_memory: F<"no-keep-memory">;
def no_mmap_output_file: F<"no-mmap-output-file">;
def no_warn_mismatch: F<"no-warn-mismatch">;
-def rpath_link: S<"rpath-link">;
-def rpath_link_eq: J<"rpath-link=">;
+defm rpath_link: Eq<"rpath-link">;
def sort_common: F<"sort-common">;
def stats: F<"stats">;
def warn_execstack: F<"warn-execstack">;
Modified: lld/trunk/test/ELF/auxiliary.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/auxiliary.s?rev=326506&r1=326505&r2=326506&view=diff
==============================================================================
--- lld/trunk/test/ELF/auxiliary.s (original)
+++ lld/trunk/test/ELF/auxiliary.s Thu Mar 1 15:06:10 2018
@@ -2,6 +2,8 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld %t.o -shared -f aaa --auxiliary bbb -o %t
# RUN: llvm-readobj --dynamic-table %t | FileCheck %s
+# RUN: ld.lld %t.o -shared -f aaa --auxiliary=bbb -o %t
+# RUN: llvm-readobj --dynamic-table %t | FileCheck %s
# CHECK: DynamicSection [
# CHECK-NEXT: Tag Type Name/Value
Modified: lld/trunk/test/ELF/pack-dyn-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/pack-dyn-relocs.s?rev=326506&r1=326505&r2=326506&view=diff
==============================================================================
--- lld/trunk/test/ELF/pack-dyn-relocs.s (original)
+++ lld/trunk/test/ELF/pack-dyn-relocs.s Thu Mar 1 15:06:10 2018
@@ -5,7 +5,7 @@
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.a32
// RUN: ld.lld -pie --pack-dyn-relocs=none %t.a32 %t.a32.so -o %t2.a32
// RUN: llvm-readobj -relocations %t2.a32 | FileCheck --check-prefix=UNPACKED32 %s
-// RUN: ld.lld -pie --pack-dyn-relocs=android %t.a32 %t.a32.so -o %t3.a32
+// RUN: ld.lld -pie --pack-dyn-relocs android %t.a32 %t.a32.so -o %t3.a32
// RUN: llvm-readobj -s -dynamic-table %t3.a32 | FileCheck --check-prefix=PACKED32-HEADERS %s
// RUN: llvm-readobj -relocations %t3.a32 | FileCheck --check-prefix=PACKED32 %s
Modified: lld/trunk/test/ELF/sectionstart.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/sectionstart.s?rev=326506&r1=326505&r2=326506&view=diff
==============================================================================
--- lld/trunk/test/ELF/sectionstart.s (original)
+++ lld/trunk/test/ELF/sectionstart.s Thu Mar 1 15:06:10 2018
@@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld %t.o --section-start .text=0x100000 \
-# RUN: --section-start .data=0x110000 --section-start .bss=0x200000 -o %t
+# RUN: --section-start=.data=0x110000 --section-start .bss=0x200000 -o %t
# RUN: llvm-objdump -section-headers %t | FileCheck %s
# CHECK: Sections:
Modified: lld/trunk/test/ELF/symbol-ordering-file.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/symbol-ordering-file.s?rev=326506&r1=326505&r2=326506&view=diff
==============================================================================
--- lld/trunk/test/ELF/symbol-ordering-file.s (original)
+++ lld/trunk/test/ELF/symbol-ordering-file.s Thu Mar 1 15:06:10 2018
@@ -21,6 +21,8 @@
# RUN: ld.lld --symbol-ordering-file %t_order.txt %t.o -o %t2.out
# RUN: llvm-objdump -s %t2.out| FileCheck %s --check-prefix=AFTER
+# RUN: ld.lld --symbol-ordering-file=%t_order.txt %t.o -o %t2.out
+# RUN: llvm-objdump -s %t2.out| FileCheck %s --check-prefix=AFTER
# AFTER: Contents of section .foo:
# AFTER-NEXT: 201000 44335566 2211
More information about the llvm-commits
mailing list