Skip to content

[SYCL][Driver] Allow -gline-tables-only for the SYCL host compilation only. #18522

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 2 commits into from
May 21, 2025
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
7 changes: 4 additions & 3 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ def warn_drv_unsupported_option_for_offload_arch_req_feature : Warning<
"ignoring '%0' option for offload arch '%1' as it is not currently supported "
"there. Use it with an offload arch containing '%2' instead">,
InGroup<OptionIgnored>;
def warn_drv_unsupported_option_for_target : Warning<
"ignoring '%0' option as it is not currently supported for target '%1'">,
InGroup<OptionIgnored>;
def warn_drv_unsupported_option_for_target
: Warning<"ignoring '%0' option as it is not currently supported for "
"target '%1'%select{|; only supported for host compilation}2">,
InGroup<OptionIgnored>;
def warn_drv_unsupported_option_for_flang : Warning<
"the argument '%0' is not supported for option '%1'. Mapping to '%1%2'">,
InGroup<OptionIgnored>;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
continue;
}
Diag(diag::warn_drv_unsupported_option_for_target)
<< "-fno-sycl-libspirv" << TT.getTriple();
<< "-fno-sycl-libspirv" << TT.getTriple() << 0;
}
}
// -fsycl-fp64-conv-emu is valid only for AOT compilation with an Intel GPU
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/SanitizerArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,

if (!SanitizeArg.empty())
TC.getDriver().Diag(diag::warn_drv_unsupported_option_for_target)
<< SanitizeArg << TC.getTripleString();
<< SanitizeArg << TC.getTripleString() << 0;
#endif
return;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/AMDGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
parseSanitizerValue(A->getValue(), /*Allow Groups*/ false);
if (K != SanitizerKind::Address)
Diags.Report(clang::diag::warn_drv_unsupported_option_for_target)
<< A->getAsString(Args) << getTriple().str();
<< A->getAsString(Args) << getTriple().str() << 0;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3858,7 +3858,7 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,

if (EffectiveTriple.isBPF() && StackProtectorLevel != LangOptions::SSPOff) {
D.Diag(diag::warn_drv_unsupported_option_for_target)
<< A->getSpelling() << EffectiveTriple.getTriple();
<< A->getSpelling() << EffectiveTriple.getTriple() << 0;
StackProtectorLevel = DefaultStackProtectorLevel;
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ static ArrayRef<options::ID> getUnsupportedOpts() {
options::OPT_fprofile_instr_use_EQ, // -fprofile-instr-use
options::OPT_fcs_profile_generate, // -fcs-profile-generate
options::OPT_fcs_profile_generate_EQ,
options::OPT_gline_tables_only, // -gline-tables-only
};
return UnsupportedOpts;
}
Expand Down Expand Up @@ -1517,7 +1518,7 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
continue;
}
D.Diag(clang::diag::warn_drv_unsupported_option_for_target)
<< A->getAsString(Args) << getTriple().str();
<< A->getAsString(Args) << getTriple().str() << 1;
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions clang/test/Driver/sycl-unsupported.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 -fcf-protection -### %s 2>&1 \
// RUN: | FileCheck %s -DARCH=spir64_x86_64 -DOPT=-fcf-protection

// Check to make sure -gline-tables-only is passed to -fsycl-is-host invocation only.
// RUN: %clangxx -### -fsycl -gline-tables-only %s 2>&1 \
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-gline-tables-only \
// RUN: -DOPT_CC1=-debug-info-kind=line-tables-only \
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
// RUN: %clang_cl -### -fsycl -gline-tables-only %s 2>&1 \
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-gline-tables-only \
// RUN: -DOPT_CC1=-debug-info-kind=line-tables-only \
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT

// RUN: %clangxx -fsycl -fprofile-instr-generate -### %s 2>&1 \
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fprofile-instr-generate \
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
Expand Down Expand Up @@ -46,11 +56,11 @@
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT

// CHECK: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}' [-Woption-ignored]
// CHECK: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}'; only supported for host compilation [-Woption-ignored]
// CHECK-NOT: clang{{.*}} "-fsycl-is-device"{{.*}} "[[OPT]]{{.*}}"
// CHECK: clang{{.*}} "-fsycl-is-host"{{.*}} "[[OPT]]{{.*}}"

// UNSUPPORTED_OPT_DIAG: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}' [-Woption-ignored]
// UNSUPPORTED_OPT_DIAG: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}'; only supported for host compilation [-Woption-ignored]
// UNSUPPORTED_OPT-NOT: clang{{.*}} "-fsycl-is-device"{{.*}} "[[OPT_CC1]]{{.*}}"
// UNSUPPORTED_OPT: clang{{.*}} "-fsycl-is-host"{{.*}} "[[OPT_CC1]]{{.*}}"

Expand Down