Author: Arvind Sudarsanam Date: 2024-10-25T12:27:42-05:00 New Revision: 6e7375031a1a3172d5e369cf2c108da2bcf65c8a
URL: https://github.com/llvm/llvm-project/commit/6e7375031a1a3172d5e369cf2c108da2bcf65c8a DIFF: https://github.com/llvm/llvm-project/commit/6e7375031a1a3172d5e369cf2c108da2bcf65c8a.diff LOG: [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 <arvind.sudarsa...@intel.com> Added: Modified: clang/test/Driver/linker-wrapper.c clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Removed: ################################################################################ diff --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c index 068ea2d7d3c663..470af4d5d70cac 100644 --- a/clang/test/Driver/linker-wrapper.c +++ b/clang/test/Driver/linker-wrapper.c @@ -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' diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 9fea1fdcd5fb46..9fcecaee318a79 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits