diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index fe950ec834d2f..b04bf2d4bca04 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -217,7 +217,8 @@ def warn_drv_mismatch_fpga_archive : Warning< def warn_drv_sycl_native_cpu_and_targets: Warning< "-fsycl-targets=native_cpu overrides SYCL targets option">, InGroup; -def err_drv_unsupported_opt_dpcpp : Error<"option '%0' unsupported with DPC++">; +def err_drv_unsupported_opt_sycl : Error< + "option '%0' not supported with SYCL compilation">; def err_drv_argument_only_allowed_with : Error< "invalid argument '%0' only allowed with '%1'">; def err_drv_opt_unsupported_input_type : Error< @@ -389,8 +390,6 @@ def err_drv_fsycl_with_c_type : Error< "'%0' must not be used in conjunction with '-fsycl', which expects C++ source">; def err_drv_fsycl_with_pch : Error< "precompiled header generation is not supported with '-fsycl'">; -def err_drv_fsycl_unsupported_with_opt - : Error<"'%0' is not supported with '-fsycl'">; def warn_drv_opt_requires_opt : Warning<"'%0' should be used only in conjunction with '%1'">, InGroup; def err_drv_sycl_missing_amdgpu_arch : Error< diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index f8f2ff94e2a2c..043e7c06ed2d9 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -841,17 +841,16 @@ static bool addSYCLDefaultTriple(Compilation &C, return false; if (C.getInputArgs().hasArg(options::OPT_fsycl_force_target_EQ)) return false; + llvm::Triple DefaultTriple = + C.getDriver().MakeSYCLDeviceTriple(getDefaultSYCLArch(C)); for (const auto &SYCLTriple : SYCLTriples) { - if (SYCLTriple.getSubArch() == llvm::Triple::NoSubArch && - SYCLTriple.isSPIROrSPIRV()) + if (SYCLTriple == DefaultTriple) return false; // If we encounter a known non-spir* target, do not add the default triple. if (SYCLTriple.isNVPTX() || SYCLTriple.isAMDGCN()) return false; } // Add the default triple as it was not found. - llvm::Triple DefaultTriple = - C.getDriver().MakeSYCLDeviceTriple(getDefaultSYCLArch(C)); SYCLTriples.insert(SYCLTriples.begin(), DefaultTriple); return true; } @@ -1069,9 +1068,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // // SYCL // - // We need to generate a SYCL toolchain if the user specified targets with - // the -fsycl-targets. If -fsycl is supplied without any of these we will - // assume SPIR-V. + // We need to generate a SYCL toolchain if the user specified -fsycl. + // If -fsycl is supplied without any of these we will assume SPIR-V. // Use of -fsycl-device-only overrides -fsycl. bool HasValidSYCLRuntime = C.getInputArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, @@ -1099,7 +1097,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, }; Arg *SYCLTargets = getArgRequiringSYCLRuntime(options::OPT_fsycl_targets_EQ); - Arg *SYCLLink = getArgRequiringSYCLRuntime(options::OPT_fsycl_link_EQ); // Check if -fsycl-host-compiler is used in conjunction with -fsycl. Arg *SYCLHostCompiler = @@ -1121,7 +1118,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, if (!HasValidSYCLRuntime) return; if (Arg *IncompatArg = C.getInputArgs().getLastArg(OptId)) - Diag(clang::diag::err_drv_fsycl_unsupported_with_opt) + Diag(clang::diag::err_drv_unsupported_opt_sycl) << IncompatArg->getSpelling(); }; // -static-libstdc++ is not compatible with -fsycl. @@ -1147,9 +1144,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, Diag(clang::diag::err_drv_invalid_argument_to_option) << ArgValue << A->getOption().getName(); }; + + Arg *SYCLLink = getArgRequiringSYCLRuntime(options::OPT_fsycl_link_EQ); + checkSingleArgValidity(SYCLLink, {"early", "image"}); + Arg *DeviceCodeSplit = C.getInputArgs().getLastArg(options::OPT_fsycl_device_code_split_EQ); - checkSingleArgValidity(SYCLLink, {"early", "image"}); checkSingleArgValidity(DeviceCodeSplit, {"per_kernel", "per_source", "auto", "off"}); @@ -1276,8 +1276,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, << SYCLTargetsValues->getAsString(C.getInputArgs()); } } else { - // If -fsycl is supplied without -fsycl-*targets we will assume SPIR-V - // unless -fintelfpga is supplied, which uses SPIR-V with fpga AOT. + // If -fsycl is supplied without -fsycl-targets we will assume SPIR-V. // For -fsycl-device-only, we also setup the implied triple as needed. if (HasValidSYCLRuntime) { StringRef SYCLTargetArch = getDefaultSYCLArch(C); @@ -1295,10 +1294,10 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, for (auto &TT : UniqueSYCLTriplesVec) { if (TT.isNVPTX() || TT.isAMDGCN()) { Diag(diag::warn_flag_no_sycl_libspirv) << TT.getTriple(); - } else { - Diag(diag::warn_drv_unsupported_option_for_target) - << "-fno-sycl-libspirv" << TT.getTriple(); + continue; } + Diag(diag::warn_drv_unsupported_option_for_target) + << "-fno-sycl-libspirv" << TT.getTriple(); } } // -fsycl-fp64-conv-emu is valid only for AOT compilation with an Intel GPU diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 8df597de8f5ff..54c19e4a86b5b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5117,7 +5117,7 @@ static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, (RTOptionID == options::OPT__SLASH_MT || RTOptionID == options::OPT__SLASH_MTd)) // Use of /MT or /MTd is not supported for SYCL. - TC.getDriver().Diag(diag::err_drv_unsupported_opt_dpcpp) + TC.getDriver().Diag(diag::err_drv_unsupported_opt_sycl) << SetArg->getOption().getName(); enum { addDEBUG = 0x1, addMT = 0x2, addDLL = 0x4 }; @@ -5427,8 +5427,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_fno_sycl_dead_args_optimization, isSYCLOptimizationO2orHigher(Args))) CmdArgs.push_back("-fenable-sycl-dae"); - bool IsMSVC = AuxT.isWindowsMSVCEnvironment(); - if (IsMSVC) { + if (IsWindowsMSVC) { CmdArgs.push_back("-fms-extensions"); CmdArgs.push_back("-fms-compatibility"); CmdArgs.push_back("-fdelayed-template-parsing"); @@ -5634,14 +5633,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // doing the host pass. CmdArgs.push_back("-fsycl-is-host"); - if (!D.IsCLMode()) { + if (!D.IsCLMode() && IsWindowsMSVC && + !Args.hasArg(options::OPT_fms_runtime_lib_EQ)) { // SYCL library is guaranteed to work correctly only with dynamic // MSVC runtime. - llvm::Triple AuxT = C.getDefaultToolChain().getTriple(); - if (AuxT.isWindowsMSVCEnvironment()) { - CmdArgs.push_back("-D_MT"); - CmdArgs.push_back("-D_DLL"); - } + CmdArgs.push_back("-D_MT"); + CmdArgs.push_back("-D_DLL"); } } // Add any predefined macros associated with intel_gpu* type targets @@ -6725,8 +6722,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // the command line. This is to allow for CMake based builds using the // Linux based driver on Windows to correctly pull in the expected debug // library. - if (Args.hasArg(options::OPT_fsycl) && !Args.hasArg(options::OPT_nolibsycl)) { - if (!D.IsCLMode() && TC.getTriple().isWindowsMSVCEnvironment()) { + if (Args.hasArg(options::OPT_fsycl) && !Args.hasArg(options::OPT_nolibsycl) && + !D.IsCLMode()) { + if (TC.getTriple().isWindowsMSVCEnvironment()) { if (isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION @@ -6734,7 +6732,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } - } else if (!D.IsCLMode() && TC.getTriple().isWindowsGNUEnvironment()) { + } else if (TC.getTriple().isWindowsGNUEnvironment()) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "-preview.dll"); diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 37589f00c4140..84c7b1cd885e3 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -1798,8 +1798,10 @@ SYCLToolChain::GetCXXStdlibType(const ArgList &Args) const { void SYCLToolChain::AddSYCLIncludeArgs(const clang::driver::Driver &Driver, const ArgList &DriverArgs, ArgStringList &CC1Args) { - // Add ../include/sycl, ../include/sycl/stl_wrappers and ../include (in that - // order). + // Add the SYCL header search locations in the specified order. + // ../include/sycl + // ../include/sycl/stl_wrappers + // ../include SmallString<128> IncludePath(Driver.Dir); llvm::sys::path::append(IncludePath, ".."); llvm::sys::path::append(IncludePath, "include"); diff --git a/clang/test/Driver/sycl-MD-default.cpp b/clang/test/Driver/sycl-MD-default.cpp index a12cb59868a8a..c9c24934cd531 100644 --- a/clang/test/Driver/sycl-MD-default.cpp +++ b/clang/test/Driver/sycl-MD-default.cpp @@ -20,4 +20,4 @@ // RUN: | FileCheck -check-prefix=CHK-ERROR %s // RUN: not %clang_cl -### -MTd -fsycl -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ERROR %s -// CHK-ERROR: option 'MT{{d*}}' unsupported with DPC++ +// CHK-ERROR: option 'MT{{d*}}' not supported with SYCL compilation diff --git a/clang/test/Driver/sycl-offload-old-model.c b/clang/test/Driver/sycl-offload-old-model.c index af20b9eca7169..5a0e5e62c0cf4 100644 --- a/clang/test/Driver/sycl-offload-old-model.c +++ b/clang/test/Driver/sycl-offload-old-model.c @@ -799,7 +799,7 @@ // RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-ffreestanding // RUN: not %clang -### -fsycl --no-offload-new-driver -static-libstdc++ %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-static-libstdc++ -// CHK-INCOMPATIBILITY: error: '[[INCOMPATOPT]]' is not supported with '-fsycl' +// CHK-INCOMPATIBILITY: error: option '[[INCOMPATOPT]]' not supported with SYCL compilation /// Using -fsyntax-only with -fsycl --no-offload-new-driver should not emit IR // RUN: %clang -### -fsycl --no-offload-new-driver -fsyntax-only %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload.c b/clang/test/Driver/sycl-offload.c index ba671d042f1cc..5d67283494ea3 100644 --- a/clang/test/Driver/sycl-offload.c +++ b/clang/test/Driver/sycl-offload.c @@ -507,7 +507,7 @@ // RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-ffreestanding // RUN: not %clang -### -fsycl --offload-new-driver -static-libstdc++ %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-static-libstdc++ -// CHK-INCOMPATIBILITY: error: '[[INCOMPATOPT]]' is not supported with '-fsycl' +// CHK-INCOMPATIBILITY: error: option '[[INCOMPATOPT]]' not supported with SYCL compilation /// Using -fsyntax-only with -fsycl --offload-new-driver should not emit IR // RUN: %clang -### -fsycl --offload-new-driver -fsyntax-only %s 2>&1 \