Skip to content

Commit

Permalink
[clang-linker-wrapper] Add error handling for missing linker path (#1…
Browse files Browse the repository at this point in the history
…13613)

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]>
  • Loading branch information
asudarsa authored Oct 25, 2024
1 parent d3c29e8 commit 6e73750
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang/test/Driver/linker-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,7 @@ __attribute__((visibility("protected"), used)) int x;
// MLLVM-SAME: -Xlinker -mllvm=-pass-remarks=foo,bar
// OFFLOAD-OPT-NOT: -Xlinker -mllvm=-pass-remarks=foo,bar
// OFFLOAD-OPT-SAME: {{$}}

// Error handling when --linker-path is not provided for clang-linker-wrapper
// RUN: not clang-linker-wrapper 2>&1 | FileCheck --check-prefix=LINKER-PATH-NOT-PROVIDED %s
// LINKER-PATH-NOT-PROVIDED: linker path missing, must pass 'linker-path'
2 changes: 2 additions & 0 deletions clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ Error runLinker(ArrayRef<StringRef> Files, const ArgList &Args) {
// Render the linker arguments and add the newly created image. We add it
// after the output file to ensure it is linked with the correct libraries.
StringRef LinkerPath = Args.getLastArgValue(OPT_linker_path_EQ);
if (LinkerPath.empty())
return createStringError("linker path missing, must pass 'linker-path'");
ArgStringList NewLinkerArgs;
for (const opt::Arg *Arg : Args) {
// Do not forward arguments only intended for the linker wrapper.
Expand Down

0 comments on commit 6e73750

Please sign in to comment.