forked from OSchip/llvm-project
COFF: /OPT should accept comma-separated multiple arguments.
/OPT:foo,bar is equivalent to /OPT:foo /OPT:bar. Reported by alexchandel. https://llvm.org/bugs/show_bug.cgi?id=25228 llvm-svn: 250728
This commit is contained in:
parent
45ca5dada1
commit
75656eebb8
|
@ -361,35 +361,39 @@ void LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
|
|||
|
||||
// Handle /opt
|
||||
for (auto *Arg : Args.filtered(OPT_opt)) {
|
||||
std::string S = StringRef(Arg->getValue()).lower();
|
||||
if (S == "noref") {
|
||||
Config->DoGC = false;
|
||||
Config->DoICF = false;
|
||||
continue;
|
||||
std::string Str = StringRef(Arg->getValue()).lower();
|
||||
SmallVector<StringRef, 1> Vec;
|
||||
StringRef(Str).split(Vec, ',');
|
||||
for (StringRef S : Vec) {
|
||||
if (S == "noref") {
|
||||
Config->DoGC = false;
|
||||
Config->DoICF = false;
|
||||
continue;
|
||||
}
|
||||
if (S == "icf" || StringRef(S).startswith("icf=")) {
|
||||
Config->DoICF = true;
|
||||
continue;
|
||||
}
|
||||
if (S == "noicf") {
|
||||
Config->DoICF = false;
|
||||
continue;
|
||||
}
|
||||
if (StringRef(S).startswith("lldlto=")) {
|
||||
StringRef OptLevel = StringRef(S).substr(7);
|
||||
if (OptLevel.getAsInteger(10, Config->LTOOptLevel) ||
|
||||
Config->LTOOptLevel > 3)
|
||||
error("/opt:lldlto: invalid optimization level: " + OptLevel);
|
||||
continue;
|
||||
}
|
||||
if (StringRef(S).startswith("lldltojobs=")) {
|
||||
StringRef Jobs = StringRef(S).substr(11);
|
||||
if (Jobs.getAsInteger(10, Config->LTOJobs) || Config->LTOJobs == 0)
|
||||
error("/opt:lldltojobs: invalid job count: " + Jobs);
|
||||
continue;
|
||||
}
|
||||
if (S != "ref" && S != "lbr" && S != "nolbr")
|
||||
error(Twine("/opt: unknown option: ") + S);
|
||||
}
|
||||
if (S == "icf" || StringRef(S).startswith("icf=")) {
|
||||
Config->DoICF = true;
|
||||
continue;
|
||||
}
|
||||
if (S == "noicf") {
|
||||
Config->DoICF = false;
|
||||
continue;
|
||||
}
|
||||
if (StringRef(S).startswith("lldlto=")) {
|
||||
StringRef OptLevel = StringRef(S).substr(7);
|
||||
if (OptLevel.getAsInteger(10, Config->LTOOptLevel) ||
|
||||
Config->LTOOptLevel > 3)
|
||||
error("/opt:lldlto: invalid optimization level: " + OptLevel);
|
||||
continue;
|
||||
}
|
||||
if (StringRef(S).startswith("lldltojobs=")) {
|
||||
StringRef Jobs = StringRef(S).substr(11);
|
||||
if (Jobs.getAsInteger(10, Config->LTOJobs) || Config->LTOJobs == 0)
|
||||
error("/opt:lldltojobs: invalid job count: " + Jobs);
|
||||
continue;
|
||||
}
|
||||
if (S != "ref" && S != "lbr" && S != "nolbr")
|
||||
error(Twine("/opt: unknown option: ") + S);
|
||||
}
|
||||
|
||||
// Handle /failifmismatch
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
|
||||
# RUN: /verbose /opt:noicf %t.obj > %t.log 2>&1
|
||||
# RUN: FileCheck -check-prefix=NOICF %s < %t.log
|
||||
# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
|
||||
# RUN: /verbose /opt:noref,noicf %t.obj > %t.log 2>&1
|
||||
# RUN: FileCheck -check-prefix=NOICF %s < %t.log
|
||||
|
||||
# NOICF-NOT: Removed foo
|
||||
# NOICF-NOT: Removed bar
|
||||
|
|
Loading…
Reference in New Issue