Skip to content

Commit 6e73750

Browse files
authored
[clang-linker-wrapper] Add error handling for missing linker path (#113613)
In clang-linker-wrapper, we do not explicitly check if --linker-path is provided. This PR adds a check to capture this. Thanks --------- Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent d3c29e8 commit 6e73750

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

clang/test/Driver/linker-wrapper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,7 @@ __attribute__((visibility("protected"), used)) int x;
250250
// MLLVM-SAME: -Xlinker -mllvm=-pass-remarks=foo,bar
251251
// OFFLOAD-OPT-NOT: -Xlinker -mllvm=-pass-remarks=foo,bar
252252
// OFFLOAD-OPT-SAME: {{$}}
253+
254+
// Error handling when --linker-path is not provided for clang-linker-wrapper
255+
// RUN: not clang-linker-wrapper 2>&1 | FileCheck --check-prefix=LINKER-PATH-NOT-PROVIDED %s
256+
// LINKER-PATH-NOT-PROVIDED: linker path missing, must pass 'linker-path'

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ Error runLinker(ArrayRef<StringRef> Files, const ArgList &Args) {
370370
// Render the linker arguments and add the newly created image. We add it
371371
// after the output file to ensure it is linked with the correct libraries.
372372
StringRef LinkerPath = Args.getLastArgValue(OPT_linker_path_EQ);
373+
if (LinkerPath.empty())
374+
return createStringError("linker path missing, must pass 'linker-path'");
373375
ArgStringList NewLinkerArgs;
374376
for (const opt::Arg *Arg : Args) {
375377
// Do not forward arguments only intended for the linker wrapper.

0 commit comments

Comments
 (0)