diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 487aef881456..ab551005b5b8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4289,8 +4289,8 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, // Unbundler only handles objects. if (auto *IA = dyn_cast(LI)) { std::string FileName = IA->getInputArg().getAsString(Args); - if (IA->getType() == types::TY_Object && - !isObjectFile(FileName)) + if ((IA->getType() == types::TY_Object && !isObjectFile(FileName)) || + IA->getInputArg().getOption().hasFlag(options::LinkerInput)) // Pass the Input along to linker. TempLinkerInputs.push_back(LI); else diff --git a/clang/test/Driver/sycl-offload.c b/clang/test/Driver/sycl-offload.c index 702495667600..7063027c58d6 100644 --- a/clang/test/Driver/sycl-offload.c +++ b/clang/test/Driver/sycl-offload.c @@ -585,6 +585,16 @@ /// ########################################################################### +// RUN: touch %t.a +// RUN: %clang -fsycl -foffload-static-lib=%t.a -o output_name -lstdc++ -z relro -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=FOFFLOAD_STATIC_LIB_SRC4 +// FOFFLOAD_STATIC_LIB_SRC4: ld{{(.exe)?}}" "-r" "-o" {{.*}} "[[INPUT:.+\.a]]" +// FOFFLOAD_STATIC_LIB_SRC4: clang-offload-bundler{{.*}} "-type=oo" +// FOFFLOAD_STATIC_LIB_SRC4: llvm-link{{.*}} "@{{.*}}" +// FOFFLOAD_STATIC_LIB_SRC4: ld{{(.exe)?}}" {{.*}} "-o" "output_name" {{.*}} "-lstdc++" "-z" "relro" + +/// ########################################################################### + /// Check -Xsycl-target-backend triggers error when multiple triples are used. // RUN: %clang -### -fsycl -fsycl-targets=spir64_fpga-unknown-linux-sycldevice,spir_fpga-unknown-linux-sycldevice -Xsycl-target-backend -DFOO %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-FSYCL-TARGET-AMBIGUOUS-ERROR %s