The `icf` command-line option is not present in ld64, so it should use the LLD option syntax, which begins with double dashes and separates primary option from any suboption with the equal sign.
Differential Revision: https://reviews.llvm.org/D104548
static ICFLevel getICFLevel(const ArgList &args) {
bool noDeduplicate = args.hasArg(OPT_no_deduplicate);
- StringRef icfLevelStr = args.getLastArgValue(OPT_icf);
+ StringRef icfLevelStr = args.getLastArgValue(OPT_icf_eq);
auto icfLevel = StringSwitch<ICFLevel>(icfLevelStr)
.Cases("none", "", ICFLevel::none)
.Case("safe", ICFLevel::safe)
.Case("all", ICFLevel::all)
.Default(ICFLevel::unknown);
if (icfLevel == ICFLevel::unknown) {
- warn(Twine("unknown -icf OPTION `") + icfLevelStr +
+ warn(Twine("unknown --icf=OPTION `") + icfLevelStr +
"', defaulting to `none'");
icfLevel = ICFLevel::none;
} else if (icfLevel != ICFLevel::none && noDeduplicate) {
- warn(Twine("`-icf " + icfLevelStr +
+ warn(Twine("`--icf=" + icfLevelStr +
"' conflicts with -no_deduplicate, setting to `none'"));
icfLevel = ICFLevel::none;
} else if (icfLevel == ICFLevel::safe) {
- warn(Twine("`-icf safe' is not yet implemented, reverting to `none'"));
+ warn(Twine("`--icf=safe' is not yet implemented, reverting to `none'"));
icfLevel = ICFLevel::none;
}
return icfLevel;
def print_dylib_search: Flag<["--"], "print-dylib-search">,
HelpText<"Print which paths lld searched when trying to find dylibs">,
Group<grp_lld>;
+def icf_eq: Joined<["--"], "icf=">,
+ HelpText<"Set level for identical code folding (default: none)">,
+ MetaVarName<"[none,safe,all]">,
+ Group<grp_lld>;
// This is a complete Options.td compiled from Apple's ld(1) manpage
// dated 2018-03-07 and cross checked with ld64 source code in repo
HelpText<"Disable infra for branches beyond the maximum branch distance.">,
Flags<[HelpHidden]>,
Group<grp_opts>;
-def icf: Separate<["-"], "icf">,
- HelpText<"Set level for identical code folding (default: none)">,
- MetaVarName<"[none,safe,all]">,
- Group<grp_opts>;
def no_deduplicate : Flag<["-"], "no_deduplicate">,
- HelpText<"Disable code deduplicaiton (synonym for `-icf none')">,
+ HelpText<"Disable code deduplicaiton (synonym for `--icf=none')">,
Group<grp_opts>;
def grp_version : OptionGroup<"version">, HelpText<"VERSION TARGETING">;
# RUN: rm -rf %t; mkdir %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
-# RUN: %lld -lSystem -icf all -o %t/all %t/main.o 2>&1 \
+# RUN: %lld -lSystem --icf=all -o %t/all %t/main.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
-# RUN: %lld -lSystem -icf none -o %t/none %t/main.o 2>&1 \
+# RUN: %lld -lSystem --icf=none -o %t/none %t/main.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
# RUN: %lld -lSystem -no_deduplicate -o %t/no_dedup %t/main.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
-# RUN: not %lld -lSystem -icf safe -o %t/safe %t/main.o 2>&1 \
+# RUN: not %lld -lSystem --icf=safe -o %t/safe %t/main.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DIAG-SAFE
-# RUN: not %lld -lSystem -icf junk -o %t/junk %t/main.o 2>&1 \
+# RUN: not %lld -lSystem --icf=junk -o %t/junk %t/main.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DIAG-JUNK
-# RUN: not %lld -lSystem -icf all -no_deduplicate -o %t/clash %t/main.o 2>&1 \
+# RUN: not %lld -lSystem --icf=all -no_deduplicate -o %t/clash %t/main.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DIAG-CLASH
# DIAG-EMPTY-NOT: {{.}}
-# DIAG-SAFE: `-icf safe' is not yet implemented, reverting to `none'
-# DIAG-JUNK: unknown -icf OPTION `junk', defaulting to `none'
-# DIAG-CLASH: `-icf all' conflicts with -no_deduplicate, setting to `none'
+# DIAG-SAFE: `--icf=safe' is not yet implemented, reverting to `none'
+# DIAG-JUNK: unknown --icf=OPTION `junk', defaulting to `none'
+# DIAG-CLASH: `--icf=all' conflicts with -no_deduplicate, setting to `none'
# RUN: llvm-objdump -d --syms %t/all | FileCheck %s --check-prefix=FOLD
# RUN: llvm-objdump -d --syms %t/none | FileCheck %s --check-prefix=NOOP
# RUN: rm -rf %t*
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
-# RUN: %lld -lSystem -icf all -o %t %t.o
+# RUN: %lld -lSystem --icf=all -o %t %t.o
# RUN: llvm-objdump -d --syms %t | FileCheck %s
## When ICF has fewer than 1 Ki functions to segregate into equivalence classes,
# RUN: rm -rf %t; mkdir %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
-# RUN: %lld -lSystem -icf all -o %t/main %t/main.o
+# RUN: %lld -lSystem --icf=all -o %t/main %t/main.o
# RUN: llvm-objdump -d --syms %t/main | FileCheck %s
# CHECK-LABEL: SYMBOL TABLE: