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

llvm-svn: 326506
This commit is contained in:
Rui Ueyama 2018-03-01 23:06:10 +00:00
parent 03e1c8b8f9
commit 036ed36f0a
6 changed files with 20 additions and 18 deletions

View File

@ -772,7 +772,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
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;

View File

@ -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, string help2> {
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">, MetaVarName<"<magic>">,
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-symbols-file">,
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<"Strip all symbols">;
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">, Alias<define_common>;
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">, Alias<strip_all>;
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-passes=">,
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-in-init-array">;
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">;

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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