diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -659,10 +659,12 @@ // 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 @@ 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 @@ target = createTargetInfo(args); depTracker = make(args.getLastArgValue(OPT_dependency_info)); + if (errorCount()) + return false; config->osoPrefix = args.getLastArgValue(OPT_oso_prefix); if (!config->osoPrefix.empty()) { diff --git a/lld/test/MachO/color-diagnostics.test b/lld/test/MachO/color-diagnostics.test --- a/lld/test/MachO/color-diagnostics.test +++ b/lld/test/MachO/color-diagnostics.test @@ -1,13 +1,19 @@ # Windows command prompt doesn't support ANSI escape sequences. # REQUIRES: shell -# RUN: not %lld -xyz --color-diagnostics /nosuchfile 2>&1 \ -# RUN: | FileCheck -check-prefix=COLOR %s -# RUN: not %lld -xyz --color-diagnostics=always /nosuchfile 2>&1 \ -# RUN: | FileCheck -check-prefix=COLOR %s +# RUN: not %lld -xyz --color-diagnostics 2>&1 \ +# RUN: | FileCheck -check-prefix=COLOR-UNKNOWN-ARGUMENT %s +# RUN: not %lld -xyz --color-diagnostics=always 2>&1 \ +# RUN: | FileCheck -check-prefix=COLOR-UNKNOWN-ARGUMENT %s -# COLOR: {{lld: .\[0;31merror: .\[0munknown argument '-xyz'}} -# COLOR: {{lld: .\[0;31merror: .\[0mcannot open /nosuchfile}} +# COLOR-UNKNOWN-ARGUMENT: {{lld: .\[0;31merror: .\[0munknown argument '-xyz'}} + +# RUN: not %lld --color-diagnostics /nosuchfile 2>&1 \ +# RUN: | FileCheck -check-prefix=COLOR-NO-SUCH-FILE %s +# RUN: not %lld --color-diagnostics=always /nosuchfile 2>&1 \ +# RUN: | FileCheck -check-prefix=COLOR-NO-SUCH-FILE %s + +# COLOR-NO-SUCH-FILE: {{lld: .\[0;31merror: .\[0mcannot open /nosuchfile}} # RUN: not %lld --color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s # ERR: unknown option: --color-diagnostics=foobar diff --git a/lld/test/MachO/driver.test b/lld/test/MachO/driver.test --- a/lld/test/MachO/driver.test +++ b/lld/test/MachO/driver.test @@ -3,5 +3,4 @@ # 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 diff --git a/lld/test/MachO/search-paths-darwin.test b/lld/test/MachO/search-paths-darwin.test --- a/lld/test/MachO/search-paths-darwin.test +++ b/lld/test/MachO/search-paths-darwin.test @@ -3,7 +3,7 @@ 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: /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: