Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -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<SyclNativeCPUTargets>;
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<
Expand Down Expand Up @@ -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<UnusedCommandLineArgument>;
def err_drv_sycl_missing_amdgpu_arch : Error<
Expand Down
29 changes: 14 additions & 15 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 =
Expand All @@ -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.
Expand All @@ -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"});

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
22 changes: 10 additions & 12 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -6725,16 +6722,17 @@ 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
"-previewd");
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");
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-MD-default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-offload-old-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down