Index: ELF/ScriptParser.cpp =================================================================== --- ELF/ScriptParser.cpp +++ ELF/ScriptParser.cpp @@ -251,16 +251,16 @@ } void ScriptParser::addFile(StringRef S) { - if (IsUnderSysroot && S.startswith("/")) { - SmallString<128> PathData; - StringRef Path = (Config->Sysroot + S).toStringRef(PathData); - if (sys::fs::exists(Path)) { - Driver->addFile(Saver.save(Path), /*WithLOption=*/false); - return; - } - } + assert(!ErrorCount); if (S.startswith("/")) { + if (IsUnderSysroot) { + SmallString<128> PathData; + StringRef Path = (Config->Sysroot + S).toStringRef(PathData); + if (sys::fs::exists(Path)) + S = Saver.save(Path); + } + Driver->addFile(S, /*WithLOption=*/false); } else if (S.startswith("=")) { if (Config->Sysroot.empty()) @@ -278,6 +278,9 @@ else setError("unable to find " + S); } + + if (ErrorCount) + error(">>> location:" + getCurrentLocation()); } void ScriptParser::readAsNeeded() { Index: test/ELF/linkerscript/group.s =================================================================== --- test/ELF/linkerscript/group.s +++ test/ELF/linkerscript/group.s @@ -51,6 +51,20 @@ # RUN: ld.lld -o %t2 %t.script # RUN: llvm-readobj %t2 > /dev/null +# RUN: echo "INPUT(/no_such_file)" > %t.script +# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s +# ERR: cannot open {{.*}}no_such_file: {{[Nn]}}o such file or directory +# ERR: >>> location:{{.*}}.script:1 + +# RUN: echo "INPUT(AS_NEEDED(/no_such_file))" > %t.script +# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s + +# RUN: echo "GROUP(/no_such_file)" > %t.script +# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s + +# RUN: echo "GROUP(AS_NEEDED(/no_such_file))" > %t.script +# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s + .globl _start _start: ret