diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 07846328c543d..209a19b6d1e67 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -521,6 +521,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, AddRunTimeLibs(ToolChain, D, CmdArgs, Args); + if (Args.hasArg(options::OPT_fsycl)) + CmdArgs.push_back("-lsycl"); + if (WantPthread && !isAndroid) CmdArgs.push_back("-lpthread"); diff --git a/clang/test/Driver/sycl-offload.c b/clang/test/Driver/sycl-offload.c index 8708569f7e4ef..ab92ac541ad26 100644 --- a/clang/test/Driver/sycl-offload.c +++ b/clang/test/Driver/sycl-offload.c @@ -271,3 +271,9 @@ // CHK-ADD-TARGETS-UB: 4: clang-offload-wrapper, {3}, object, (device-sycl) // CHK-ADD-TARGETS-UB: 5: offload, "host-sycl (x86_64-unknown-linux-gnu)" {2}, "device-sycl (spir64-unknown-linux-sycldevice)" {4}, image +/// ########################################################################### + +/// Check for default linking of -lsycl with -fsycl usage +// RUN: %clang -fsycl -target x86_64-unknown-linux-gnu %s -o %t -### 2>&1 | FileCheck -check-prefix=CHECK-LD-SYCL %s +// CHECK-LD-SYCL: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD-SYCL: "-lsycl"