From afb4152a7b8b92639c2a6bf719060417792686b1 Mon Sep 17 00:00:00 2001 From: Michael D Toguchi Date: Tue, 19 Mar 2019 13:57:51 +0300 Subject: [PATCH] [SYCL] link in with -lsycl when -fsycl is used Signed-off-by: Vladimir Lazarev Signed-off-by: Michael D Toguchi --- clang/lib/Driver/ToolChains/Gnu.cpp | 3 +++ clang/test/Driver/sycl-offload.c | 6 ++++++ 2 files changed, 9 insertions(+) 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"