Skip to content

[Driver][SYCL] use of -fsycl and -static-libstc++ not supported #5297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2022
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
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ def err_drv_expecting_fsycl_with_sycl_opt : Error<
"'%0' must be used in conjunction with '-fsycl' to enable offloading">;
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_unsupported_with_opt
: Error<"'%0' is not supported with '-fsycl'">;
def err_drv_sycl_missing_amdgpu_arch : Error<
"missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch'">;
def warn_drv_sycl_offload_target_duplicate : Warning<
Expand Down
16 changes: 11 additions & 5 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,18 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
if (SYCLTargets && SYCLfpga)
Diag(clang::diag::err_drv_option_conflict)
<< SYCLTargets->getSpelling() << SYCLfpga->getSpelling();

auto argSYCLIncompatible = [&](OptSpecifier OptId) {
if (!HasValidSYCLRuntime)
return;
if (Arg *IncompatArg = C.getInputArgs().getLastArg(OptId))
Diag(clang::diag::err_drv_fsycl_unsupported_with_opt)
<< IncompatArg->getSpelling();
};
// -static-libstdc++ is not compatible with -fsycl.
argSYCLIncompatible(options::OPT_static_libstdcxx);
// -ffreestanding cannot be used with -fsycl
if (HasValidSYCLRuntime &&
C.getInputArgs().hasArg(options::OPT_ffreestanding)) {
Diag(clang::diag::err_drv_option_conflict) << "-fsycl"
<< "-ffreestanding";
}
argSYCLIncompatible(options::OPT_ffreestanding);

// Diagnose incorrect inputs to SYCL options.
// FIXME: Since the option definition includes the list of possible values,
Expand Down
8 changes: 5 additions & 3 deletions clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,10 +1137,12 @@
// CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
// CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-host"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"{{.*}}

/// Check for an incompatibility error when -fsycl and -ffreestanding used
/// Check for option incompatibility with -fsycl
// RUN: %clang -### -fsycl -ffreestanding %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s
// CHK-INCOMPATIBILITY: error: The option -fsycl conflicts with -ffreestanding
// RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-ffreestanding
// RUN: %clang -### -fsycl -static-libstdc++ %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-static-libstdc++
// CHK-INCOMPATIBILITY: error: '[[INCOMPATOPT]]' is not supported with '-fsycl'

/// Using -fsyntax-only with -fsycl should not emit IR
// RUN: %clang -### -fsycl -fsyntax-only %s 2>&1 \
Expand Down