diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9566fac31f6b4..59557455cae9c 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4144,8 +4144,10 @@ class OffloadingActionBuilder final { } } - SmallString<128> LibLoc(TC->getDriver().Dir); - llvm::sys::path::append(LibLoc, "/../lib"); + const toolchains::SYCLToolChain *SYCLTC = + static_cast(TC); + SmallVector, 4> LibLocCandidates; + SYCLTC->SYCLInstallation.getSYCLDeviceLibPath(LibLocCandidates); StringRef LibSuffix = isMSVCEnv ? ".obj" : ".o"; SmallVector sycl_device_wrapper_libs = { {"libsycl-crt", "libc"}, @@ -4165,23 +4167,30 @@ class OffloadingActionBuilder final { auto sycl_libs = (t == sycl_devicelib_wrapper) ? sycl_device_wrapper_libs : sycl_device_fallback_libs; - for (const DeviceLibOptInfo &Lib : sycl_libs) { - if (!devicelib_link_info[Lib.devicelib_option]) - continue; - SmallString<128> LibName(LibLoc); - llvm::sys::path::append(LibName, Lib.devicelib_name); - llvm::sys::path::replace_extension(LibName, LibSuffix); - if (llvm::sys::fs::exists(LibName)) { - ++NumOfDeviceLibLinked; - Arg *InputArg = MakeInputArg(Args, C.getDriver().getOpts(), - Args.MakeArgString(LibName)); - auto *SYCLDeviceLibsInputAction = - C.MakeAction(*InputArg, types::TY_Object); - auto *SYCLDeviceLibsUnbundleAction = - C.MakeAction( - SYCLDeviceLibsInputAction); - addDeviceDepences(SYCLDeviceLibsUnbundleAction); - DeviceLinkObjects.push_back(SYCLDeviceLibsUnbundleAction); + bool LibLocSelected = false; + for (const auto &LLCandidate : LibLocCandidates) { + if (LibLocSelected) + break; + for (const DeviceLibOptInfo &Lib : sycl_libs) { + if (!devicelib_link_info[Lib.devicelib_option]) + continue; + SmallString<128> LibName(LLCandidate); + llvm::sys::path::append(LibName, Lib.devicelib_name); + llvm::sys::path::replace_extension(LibName, LibSuffix); + if (llvm::sys::fs::exists(LibName)) { + ++NumOfDeviceLibLinked; + Arg *InputArg = MakeInputArg(Args, C.getDriver().getOpts(), + Args.MakeArgString(LibName)); + auto *SYCLDeviceLibsInputAction = + C.MakeAction(*InputArg, types::TY_Object); + auto *SYCLDeviceLibsUnbundleAction = + C.MakeAction( + SYCLDeviceLibsInputAction); + addDeviceDepences(SYCLDeviceLibsUnbundleAction); + DeviceLinkObjects.push_back(SYCLDeviceLibsUnbundleAction); + if (!LibLocSelected) + LibLocSelected = !LibLocSelected; + } } } }; diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index f11499590d518..d7880e8c95010 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -22,6 +22,31 @@ using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; +SYCLInstallationDetector::SYCLInstallationDetector(const Driver &D) + : D(D), InstallationCandidates() { + InstallationCandidates.emplace_back(D.Dir + "/.."); +} + +void SYCLInstallationDetector::getSYCLDeviceLibPath( + llvm::SmallVector, 4> &DeviceLibPaths) const { + for (const auto &IC : InstallationCandidates) { + llvm::SmallString<128> InstallLibPath(IC.str()); + InstallLibPath.append("/lib"); + DeviceLibPaths.emplace_back(InstallLibPath); + } + + DeviceLibPaths.emplace_back(D.SysRoot + "/lib"); +} + +void SYCLInstallationDetector::print(llvm::raw_ostream &OS) const { + if (!InstallationCandidates.size()) + return; + OS << "SYCL Installation Candidates: \n"; + for (const auto &IC : InstallationCandidates) { + OS << IC << "\n"; + } +} + const char *SYCL::Linker::constructLLVMSpirvCommand( Compilation &C, const JobAction &JA, const InputInfo &Output, StringRef OutputFilePrefix, bool ToBc, const char *InputFileName) const { @@ -577,7 +602,7 @@ void SYCL::x86_64::BackendCompiler::ConstructJob( SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const ArgList &Args) - : ToolChain(D, Triple, Args), HostTC(HostTC) { + : ToolChain(D, Triple, Args), HostTC(HostTC), SYCLInstallation(D) { // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); diff --git a/clang/lib/Driver/ToolChains/SYCL.h b/clang/lib/Driver/ToolChains/SYCL.h index 36e3fc5d80f35..79cb46a2b63d6 100644 --- a/clang/lib/Driver/ToolChains/SYCL.h +++ b/clang/lib/Driver/ToolChains/SYCL.h @@ -15,6 +15,18 @@ namespace clang { namespace driver { +class SYCLInstallationDetector { +public: + SYCLInstallationDetector(const Driver &D); + void getSYCLDeviceLibPath( + llvm::SmallVector, 4> &DeviceLibPaths) const; + void print(llvm::raw_ostream &OS) const; + +private: + const Driver &D; + llvm::SmallVector, 4> InstallationCandidates; +}; + class Command; namespace tools { @@ -162,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY SYCLToolChain : public ToolChain { const ToolChain &HostTC; + const SYCLInstallationDetector SYCLInstallation; protected: Tool *buildBackendCompiler() const override; diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-cmath-fp64.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-cmath-fp64.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-cmath.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-cmath.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-complex-fp64.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-complex-fp64.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-complex.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-complex.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-crt.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-crt.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cassert.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cassert.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cmath-fp64.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cmath-fp64.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cmath.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cmath.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-complex-fp64.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-complex-fp64.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-complex.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-complex.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-itt-compiler-wrappers.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-itt-compiler-wrappers.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-itt-stubs.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-itt-stubs.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-itt-user-wrappers.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-itt-user-wrappers.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-cmath-fp64.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-cmath-fp64.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-cmath.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-cmath.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-complex-fp64.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-complex-fp64.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-complex.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-complex.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cassert.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cassert.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cmath-fp64.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cmath-fp64.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cmath.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cmath.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-complex-fp64.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-complex-fp64.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-complex.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-complex.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-itt-compiler-wrappers.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-itt-compiler-wrappers.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-itt-stubs.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-itt-stubs.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-itt-user-wrappers.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-itt-user-wrappers.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/sycl-device-lib-win.cpp b/clang/test/Driver/sycl-device-lib-win.cpp index 31b7dd1e59a34..6ef0d435037cf 100644 --- a/clang/test/Driver/sycl-device-lib-win.cpp +++ b/clang/test/Driver/sycl-device-lib-win.cpp @@ -7,13 +7,13 @@ /// ########################################################################### /// test behavior of device library default link -// RUN: %clangxx -fsycl %s -### 2>&1 \ +// RUN: %clangxx -fsycl %s --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp32 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.obj" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.obj" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" @@ -28,15 +28,15 @@ /// ########################################################################### /// test behavior of device library link with libm-fp64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp64 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp64 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=all --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32,libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32,libm-fp64 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,all --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 // SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.obj" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.obj" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" @@ -52,7 +52,7 @@ /// ########################################################################### /// test behavior of -fno-sycl-device-lib=libc -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.obj" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex-fp64.obj" "-outputs={{.*}}libsycl-complex-fp64-{{.*}}.o" "-unbundle" @@ -65,7 +65,7 @@ /// ########################################################################### /// test behavior of -fno-sycl-device-lib=libm-fp32,libm-fp64 -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,libm-fp64 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.obj" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.obj" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" @@ -73,17 +73,17 @@ /// ########################################################################### /// test behavior of disabling all device libraries -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,libm-fp32 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=all --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,all --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64,all --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all,libm-fp64,libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all,libm-fp64,libm-fp32 --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB // SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB: {{.*}}clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" // SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB-NEXT: {{.*}}llvm-link{{.*}} {{.*}} "--suppress-warnings" @@ -100,7 +100,7 @@ /// ########################################################################### /// test llvm-link behavior for linking device libraries -// RUN: %clangxx -fsycl %s -### 2>&1 \ +// RUN: %clangxx -fsycl %s --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_DEVICE_LIB // SYCL_LLVM_LINK_DEVICE_LIB: llvm-link{{.*}} "{{.*}}.bc" "-o" "{{.*}}.bc" "--suppress-warnings" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.obj" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" @@ -117,7 +117,7 @@ /// ########################################################################### /// test llvm-link behavior for fno-sycl-device-lib -// RUN: %clangxx -fsycl -fno-sycl-device-lib=all %s -### 2>&1 \ +// RUN: %clangxx -fsycl -fno-sycl-device-lib=all %s --sysroot=%S/Inputs/SYCL-windows -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_NO_DEVICE_LIB // SYCL_LLVM_LINK_NO_DEVICE_LIB: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device" // SYCL_LLVM_LINK_NO_DEVICE_LIB-NOT: llvm-link{{.*}} "-only-needed" diff --git a/clang/test/Driver/sycl-device-lib.cpp b/clang/test/Driver/sycl-device-lib.cpp index 49093ae36cee2..5d66e337bd832 100644 --- a/clang/test/Driver/sycl-device-lib.cpp +++ b/clang/test/Driver/sycl-device-lib.cpp @@ -7,13 +7,13 @@ /// ########################################################################### /// test behavior of device library default link -// RUN: %clangxx -fsycl %s -### 2>&1 \ +// RUN: %clangxx -fsycl %s --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp32 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.o" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" @@ -28,15 +28,15 @@ /// ########################################################################### /// test behavior of device library link with libm-fp64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp64 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp64 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=all --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32,libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32,libm-fp64 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 -// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,all --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 // SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.o" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" @@ -52,7 +52,7 @@ /// ########################################################################### /// test behavior of -fno-sycl-device-lib=libc -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex-fp64.o" "-outputs={{.*}}libsycl-complex-fp64-{{.*}}.o" "-unbundle" @@ -65,7 +65,7 @@ /// ########################################################################### /// test behavior of -fno-sycl-device-lib=libm-fp32,libm-fp64 -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,libm-fp64 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,libm-fp64 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.o" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" @@ -73,17 +73,17 @@ /// ########################################################################### /// test behavior of disabling all device libraries -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,libm-fp32 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=all --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,all --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64,all -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64,all --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB -// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all,libm-fp64,libm-fp32 -### 2>&1 \ +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all,libm-fp64,libm-fp32 --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB // SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB: {{.*}}clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" // SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB-NEXT: {{.*}}llvm-link{{.*}} {{.*}} "--suppress-warnings" @@ -100,7 +100,7 @@ /// ########################################################################### /// test llvm-link behavior for linking device libraries -// RUN: %clangxx -fsycl %s -### 2>&1 \ +// RUN: %clangxx -fsycl %s --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_DEVICE_LIB // SYCL_LLVM_LINK_DEVICE_LIB: llvm-link{{.*}} "{{.*}}.bc" "-o" "{{.*}}.bc" "--suppress-warnings" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.o" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" @@ -126,7 +126,7 @@ /// ########################################################################### /// test llvm-link behavior for special user input whose filename resembles SYCL device library // RUN: touch libsycl-crt.o -// RUN: %clangxx -fsycl libsycl-crt.o -### 2>&1 \ +// RUN: %clangxx -fsycl libsycl-crt.o --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_USER_ONLY_NEEDED // SYCL_LLVM_LINK_USER_ONLY_NEEDED: llvm-link{{.*}} "{{.*}}.o" "-o" "{{.*}}.bc" "--suppress-warnings" // SYCL_LLVM_LINK_USER_ONLY_NEEDED: llvm-link{{.*}} "-only-needed" "{{.*}}" "-o" "{{.*}}.bc" "--suppress-warnings"