Skip to content

Commit 707093d

Browse files
[SYCL][Driver] Allow -gline-tables-only for the SYCL host compilation only. (#18522)
Allow `-gline-tables-only` for the SYCL host compilation only, providing a warning that `-gline-tables-only` does not apply to device compilation. Example: ``` clang++ -### -fsycl -gline-tables-only syclfile.cpp ignoring `-gline-tables-only` option as it is not currently supported for target 'spir64';only supported for SYCL host compilation ```
1 parent 281b304 commit 707093d

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ def warn_drv_unsupported_option_for_offload_arch_req_feature : Warning<
142142
"ignoring '%0' option for offload arch '%1' as it is not currently supported "
143143
"there. Use it with an offload arch containing '%2' instead">,
144144
InGroup<OptionIgnored>;
145-
def warn_drv_unsupported_option_for_target : Warning<
146-
"ignoring '%0' option as it is not currently supported for target '%1'">,
147-
InGroup<OptionIgnored>;
145+
def warn_drv_unsupported_option_for_target
146+
: Warning<"ignoring '%0' option as it is not currently supported for "
147+
"target '%1'%select{|; only supported for host compilation}2">,
148+
InGroup<OptionIgnored>;
148149
def warn_drv_unsupported_option_for_flang : Warning<
149150
"the argument '%0' is not supported for option '%1'. Mapping to '%1%2'">,
150151
InGroup<OptionIgnored>;

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
15651565
continue;
15661566
}
15671567
Diag(diag::warn_drv_unsupported_option_for_target)
1568-
<< "-fno-sycl-libspirv" << TT.getTriple();
1568+
<< "-fno-sycl-libspirv" << TT.getTriple() << 0;
15691569
}
15701570
}
15711571
// -fsycl-fp64-conv-emu is valid only for AOT compilation with an Intel GPU

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
13011301

13021302
if (!SanitizeArg.empty())
13031303
TC.getDriver().Diag(diag::warn_drv_unsupported_option_for_target)
1304-
<< SanitizeArg << TC.getTripleString();
1304+
<< SanitizeArg << TC.getTripleString() << 0;
13051305
#endif
13061306
return;
13071307
}

clang/lib/Driver/ToolChains/AMDGPU.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
164164
parseSanitizerValue(A->getValue(), /*Allow Groups*/ false);
165165
if (K != SanitizerKind::Address)
166166
Diags.Report(clang::diag::warn_drv_unsupported_option_for_target)
167-
<< A->getAsString(Args) << getTriple().str();
167+
<< A->getAsString(Args) << getTriple().str() << 0;
168168
}
169169
}
170170
};

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3859,7 +3859,7 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
38593859

38603860
if (EffectiveTriple.isBPF() && StackProtectorLevel != LangOptions::SSPOff) {
38613861
D.Diag(diag::warn_drv_unsupported_option_for_target)
3862-
<< A->getSpelling() << EffectiveTriple.getTriple();
3862+
<< A->getSpelling() << EffectiveTriple.getTriple() << 0;
38633863
StackProtectorLevel = DefaultStackProtectorLevel;
38643864
}
38653865
} else {

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ static ArrayRef<options::ID> getUnsupportedOpts() {
14721472
options::OPT_fprofile_instr_use_EQ, // -fprofile-instr-use
14731473
options::OPT_fcs_profile_generate, // -fcs-profile-generate
14741474
options::OPT_fcs_profile_generate_EQ,
1475+
options::OPT_gline_tables_only, // -gline-tables-only
14751476
};
14761477
return UnsupportedOpts;
14771478
}
@@ -1517,7 +1518,7 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
15171518
continue;
15181519
}
15191520
D.Diag(clang::diag::warn_drv_unsupported_option_for_target)
1520-
<< A->getAsString(Args) << getTriple().str();
1521+
<< A->getAsString(Args) << getTriple().str() << 1;
15211522
}
15221523
}
15231524
}

clang/test/Driver/sycl-unsupported.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 -fcf-protection -### %s 2>&1 \
1010
// RUN: | FileCheck %s -DARCH=spir64_x86_64 -DOPT=-fcf-protection
1111

12+
// Check to make sure -gline-tables-only is passed to -fsycl-is-host invocation only.
13+
// RUN: %clangxx -### -fsycl -gline-tables-only %s 2>&1 \
14+
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-gline-tables-only \
15+
// RUN: -DOPT_CC1=-debug-info-kind=line-tables-only \
16+
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
17+
// RUN: %clang_cl -### -fsycl -gline-tables-only %s 2>&1 \
18+
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-gline-tables-only \
19+
// RUN: -DOPT_CC1=-debug-info-kind=line-tables-only \
20+
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
21+
1222
// RUN: %clangxx -fsycl -fprofile-instr-generate -### %s 2>&1 \
1323
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fprofile-instr-generate \
1424
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
@@ -46,11 +56,11 @@
4656
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
4757
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
4858

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

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

0 commit comments

Comments
 (0)