forked from OSchip/llvm-project
[MachO] Use error instead of fatal for missing -arch
`fatal` should only be used for malformed inputs according to ErrorHandler.h; `error` is more appropriate for missing arguments, accompanied by a check to bail out early in case of the error. Some tests need to be adjusted accordingly. Makes `lld/test/MachO/arch.s` pass with `LLD_IN_TEST=2`. Reviewed By: #lld-macho, int3 Differential Revision: https://reviews.llvm.org/D112879
This commit is contained in:
parent
0cf624cad7
commit
264d3b6d4e
|
@ -659,10 +659,12 @@ static PlatformKind parsePlatformVersion(const ArgList &args) {
|
|||
// Has the side-effect of setting Config::target.
|
||||
static TargetInfo *createTargetInfo(InputArgList &args) {
|
||||
StringRef archName = args.getLastArgValue(OPT_arch);
|
||||
if (archName.empty())
|
||||
fatal("must specify -arch");
|
||||
PlatformKind platform = parsePlatformVersion(args);
|
||||
if (archName.empty()) {
|
||||
error("must specify -arch");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PlatformKind platform = parsePlatformVersion(args);
|
||||
config->platformInfo.target =
|
||||
MachO::Target(getArchitectureFromName(archName), platform);
|
||||
|
||||
|
@ -680,7 +682,8 @@ static TargetInfo *createTargetInfo(InputArgList &args) {
|
|||
case CPU_TYPE_ARM:
|
||||
return createARMTargetInfo(cpuSubtype);
|
||||
default:
|
||||
fatal("missing or unsupported -arch " + archName);
|
||||
error("missing or unsupported -arch " + archName);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,6 +1121,8 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
|
|||
target = createTargetInfo(args);
|
||||
depTracker =
|
||||
make<DependencyTracker>(args.getLastArgValue(OPT_dependency_info));
|
||||
if (errorCount())
|
||||
return false;
|
||||
|
||||
config->osoPrefix = args.getLastArgValue(OPT_oso_prefix);
|
||||
if (!config->osoPrefix.empty()) {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
# Windows command prompt doesn't support ANSI escape sequences.
|
||||
# REQUIRES: shell
|
||||
|
||||
# RUN: not %lld -xyz --color-diagnostics /nosuchfile 2>&1 \
|
||||
# RUN: not %lld --color-diagnostics /nosuchfile 2>&1 \
|
||||
# RUN: | FileCheck -check-prefix=COLOR %s
|
||||
# RUN: not %lld -xyz --color-diagnostics=always /nosuchfile 2>&1 \
|
||||
# RUN: not %lld --color-diagnostics=always /nosuchfile 2>&1 \
|
||||
# RUN: | FileCheck -check-prefix=COLOR %s
|
||||
|
||||
# COLOR: {{lld: .\[0;31merror: .\[0munknown argument '-xyz'}}
|
||||
# COLOR: {{lld: .\[0;31merror: .\[0mcannot open /nosuchfile}}
|
||||
|
||||
# RUN: not %lld --color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
|
||||
|
|
|
@ -3,5 +3,4 @@ VERSION: LLD
|
|||
|
||||
# RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
|
||||
SPELLHELP: error: unknown argument '---help', did you mean '--help'
|
||||
# FIXME: This should say "no input files" instead
|
||||
SPELLHELP: error: undefined symbol: _main
|
||||
# FIXME: We should also output a "no input files" error
|
||||
|
|
|
@ -3,7 +3,7 @@ REQUIRES: system-darwin
|
|||
|
||||
RUN: mkdir -p %t1 %t2
|
||||
|
||||
RUN: not ld64.lld -arch x86_64 -v -L%t1 -F%t2 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 %s
|
||||
RUN: not ld64.lld -arch x86_64 -platform_version macos 10.5 11.0 -v -L%t1 -F%t2 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 %s
|
||||
CHECK: Library search paths:
|
||||
CHECK-NEXT: [[LDIR]]
|
||||
CHECK-NEXT: /usr/lib
|
||||
|
@ -12,7 +12,7 @@ CHECK-NEXT: [[FDIR]]
|
|||
CHECK-NEXT: /Library/Frameworks
|
||||
CHECK-NEXT: /System/Library/Frameworks
|
||||
|
||||
RUN: not ld64.lld -arch x86_64 -v -L%t1 -F%t2 -Z 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 --check-prefix=CHECK_Z %s
|
||||
RUN: not ld64.lld -arch x86_64 -platform_version macos 10.5 11.0 -v -L%t1 -F%t2 -Z 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 --check-prefix=CHECK_Z %s
|
||||
CHECK_Z: Library search paths:
|
||||
CHECK_Z-NEXT: [[LDIR]]
|
||||
CHECK_Z-NEXT: Framework search paths:
|
||||
|
|
Loading…
Reference in New Issue