Skip to content

Commit 1a50b07

Browse files
authored
[Driver][SYCL] Remove support for -fsycl-[add|link]-targets (#13834)
The -fsycl-add-targets and -fsycl-link-targets are deprecated options, remove the support for these options moving forward.
1 parent a8609a5 commit 1a50b07

File tree

5 files changed

+14
-384
lines changed

5 files changed

+14
-384
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,14 +3954,6 @@ def fno_sycl_esimd_build_host_code : Flag<["-"], "fno-sycl-esimd-build-host-cod
39543954
def fsycl_targets_EQ : CommaJoined<["-"], "fsycl-targets=">, Flags<[NoXarchOption]>,
39553955
Visibility<[ClangOption, CLOption, DXCOption, CC1Option]>,
39563956
HelpText<"Specify comma-separated list of triples SYCL offloading targets to be supported">;
3957-
def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">,
3958-
Flags<[NoXarchOption, Deprecated]>, Visibility<[ClangOption, CLOption, DXCOption]>,
3959-
HelpText<"Specify comma-separated list of triple and device binary image "
3960-
"pairs to add to the final SYCL binary (deprecated)">;
3961-
def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">,
3962-
Flags<[NoXarchOption, Deprecated]>, Visibility<[ClangOption, CLOption, DXCOption, CC1Option]>,
3963-
HelpText<"Specify comma-separated list of triples SYCL offloading targets "
3964-
"to produce linked device images (deprecated)">;
39653957
def fsycl_force_target_EQ : Joined<["-"], "fsycl-force-target=">,
39663958
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
39673959
HelpText<"Force the usage of the given triple when extracting device code "

clang/lib/Driver/Driver.cpp

Lines changed: 14 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,8 +1077,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
10771077
// SYCL
10781078
//
10791079
// We need to generate a SYCL toolchain if the user specified targets with
1080-
// the -fsycl-targets, -fsycl-add-targets or -fsycl-link-targets option.
1081-
// If -fsycl is supplied without any of these we will assume SPIR-V.
1080+
// the -fsycl-targets. If -fsycl is supplied without any of these we will
1081+
// assume SPIR-V.
10821082
// Use of -fsycl-device-only overrides -fsycl.
10831083
bool HasValidSYCLRuntime =
10841084
C.getInputArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl,
@@ -1106,10 +1106,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11061106
};
11071107

11081108
Arg *SYCLTargets = getArgRequiringSYCLRuntime(options::OPT_fsycl_targets_EQ);
1109-
Arg *SYCLLinkTargets =
1110-
getArgRequiringSYCLRuntime(options::OPT_fsycl_link_targets_EQ);
1111-
Arg *SYCLAddTargets =
1112-
getArgRequiringSYCLRuntime(options::OPT_fsycl_add_targets_EQ);
11131109
Arg *SYCLLink = getArgRequiringSYCLRuntime(options::OPT_fsycl_link_EQ);
11141110

11151111
// Check if -fsycl-host-compiler is used in conjunction with -fsycl.
@@ -1118,18 +1114,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11181114
Arg *SYCLHostCompilerOptions =
11191115
getArgRequiringSYCLRuntime(options::OPT_fsycl_host_compiler_options_EQ);
11201116

1121-
// -fsycl-targets cannot be used with -fsycl-link-targets
1122-
if (SYCLTargets && SYCLLinkTargets)
1123-
Diag(clang::diag::err_drv_option_conflict)
1124-
<< SYCLTargets->getSpelling() << SYCLLinkTargets->getSpelling();
1125-
// -fsycl-link-targets and -fsycl-add-targets cannot be used together
1126-
if (SYCLLinkTargets && SYCLAddTargets)
1127-
Diag(clang::diag::err_drv_option_conflict)
1128-
<< SYCLLinkTargets->getSpelling() << SYCLAddTargets->getSpelling();
1129-
// -fsycl-link-targets is not allowed with -fsycl-link
1130-
if (SYCLLinkTargets && SYCLLink)
1131-
Diag(clang::diag::err_drv_option_conflict)
1132-
<< SYCLLink->getSpelling() << SYCLLinkTargets->getSpelling();
11331117
// -fsycl-targets cannot be used with -fintelfpga
11341118
if (SYCLTargets && SYCLfpga)
11351119
Diag(clang::diag::err_drv_option_conflict)
@@ -1188,14 +1172,14 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11881172
if (!isValidSYCLTriple(TT))
11891173
Diag(clang::diag::err_drv_invalid_sycl_target) << Val;
11901174
}
1191-
bool HasSYCLTargetsOption = SYCLTargets || SYCLLinkTargets || SYCLAddTargets;
1175+
bool HasSYCLTargetsOption = SYCLTargets;
11921176

11931177
llvm::StringMap<StringRef> FoundNormalizedTriples;
11941178
llvm::SmallVector<llvm::Triple, 4> UniqueSYCLTriplesVec;
11951179
if (HasSYCLTargetsOption) {
11961180
// At this point, we know we have a valid combination
11971181
// of -fsycl*target options passed
1198-
Arg *SYCLTargetsValues = SYCLTargets ? SYCLTargets : SYCLLinkTargets;
1182+
Arg *SYCLTargetsValues = SYCLTargets;
11991183
if (SYCLTargetsValues) {
12001184
if (SYCLTargetsValues->getNumValues()) {
12011185

@@ -1259,47 +1243,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
12591243
Diag(clang::diag::warn_drv_empty_joined_argument)
12601244
<< SYCLTargetsValues->getAsString(C.getInputArgs());
12611245
}
1262-
// -fsycl-add-targets is a list of paired items (Triple and file) which are
1263-
// gathered and used to be linked into the final device binary. This can
1264-
// be used with -fsycl-targets to put together the final conglomerate binary
1265-
if (SYCLAddTargets) {
1266-
if (SYCLAddTargets->getNumValues()) {
1267-
// Use of -fsycl-add-targets adds additional files to the SYCL device
1268-
// link step. Regular offload processing occurs below
1269-
for (StringRef Val : SYCLAddTargets->getValues()) {
1270-
// Parse out the Triple and Input (triple:binary) and create a
1271-
// ToolChain for each entry.
1272-
// The expected format is 'triple:file', any other format will
1273-
// not be accepted.
1274-
std::pair<StringRef, StringRef> I = Val.split(':');
1275-
if (!I.first.empty() && !I.second.empty()) {
1276-
llvm::Triple TT(I.first);
1277-
if (!isValidSYCLTriple(TT)) {
1278-
Diag(clang::diag::err_drv_invalid_sycl_target) << I.first;
1279-
continue;
1280-
}
1281-
std::string NormalizedName = TT.normalize();
1282-
1283-
// Make sure we don't have a duplicate triple.
1284-
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
1285-
if (Duplicate != FoundNormalizedTriples.end())
1286-
// The toolchain for this triple was already created
1287-
continue;
1288-
1289-
// Store the current triple so that we can check for duplicates in
1290-
// the following iterations.
1291-
FoundNormalizedTriples[NormalizedName] = Val;
1292-
UniqueSYCLTriplesVec.push_back(TT);
1293-
} else {
1294-
// No colon found, do not use the input
1295-
C.getDriver().Diag(diag::err_drv_unsupported_option_argument)
1296-
<< SYCLAddTargets->getSpelling() << Val;
1297-
}
1298-
}
1299-
} else
1300-
Diag(clang::diag::warn_drv_empty_joined_argument)
1301-
<< SYCLAddTargets->getAsString(C.getInputArgs());
1302-
}
13031246
} else {
13041247
// If -fsycl is supplied without -fsycl-*targets we will assume SPIR-V
13051248
// unless -fintelfpga is supplied, which uses SPIR-V with fpga AOT.
@@ -5040,9 +4983,6 @@ class OffloadingActionBuilder final {
50404983
ExternalCudaAction = nullptr;
50414984
}
50424985

5043-
// With -fsycl-link-targets, we will take the unbundled binaries
5044-
// for each device and link them together to a single binary that will
5045-
// be used in a split compilation step.
50464986
if (CompileDeviceOnly && !SYCLDeviceActions.empty()) {
50474987
for (auto SDA : SYCLDeviceActions)
50484988
SYCLLinkBinaryList.push_back(SDA);
@@ -6369,8 +6309,6 @@ class OffloadingActionBuilder final {
63696309
if (ToolChains.empty())
63706310
return false;
63716311

6372-
Arg *SYCLLinkTargets =
6373-
Args.getLastArg(options::OPT_fsycl_link_targets_EQ);
63746312
auto *DeviceCodeSplitArg =
63756313
Args.getLastArg(options::OPT_fsycl_device_code_split_EQ);
63766314
// -fsycl-device-code-split is an alias to
@@ -6380,24 +6318,22 @@ class OffloadingActionBuilder final {
63806318
// Gather information about the SYCL Ahead of Time targets. The targets
63816319
// are determined on the SubArch values passed along in the triple.
63826320
Arg *SYCLTargets =
6383-
C.getInputArgs().getLastArg(options::OPT_fsycl_targets_EQ);
6384-
Arg *SYCLAddTargets = Args.getLastArg(options::OPT_fsycl_add_targets_EQ);
6321+
C.getInputArgs().getLastArg(options::OPT_fsycl_targets_EQ);
63856322
Arg *SYCLfpga = C.getInputArgs().getLastArg(options::OPT_fintelfpga);
63866323
bool HasValidSYCLRuntime = C.getInputArgs().hasFlag(
63876324
options::OPT_fsycl, options::OPT_fno_sycl, false);
63886325
bool SYCLfpgaTriple = false;
63896326
bool ShouldAddDefaultTriple = true;
63906327
bool GpuInitHasErrors = false;
6391-
bool HasSYCLTargetsOption =
6392-
SYCLAddTargets || SYCLTargets || SYCLLinkTargets;
6328+
bool HasSYCLTargetsOption = SYCLTargets;
63936329

63946330
// Make -fintelfpga flag imply -fsycl.
63956331
if (SYCLfpga && !HasValidSYCLRuntime)
63966332
HasValidSYCLRuntime = true;
63976333

63986334
if (HasSYCLTargetsOption) {
6399-
if (SYCLTargets || SYCLLinkTargets) {
6400-
Arg *SYCLTargetsValues = SYCLTargets ? SYCLTargets : SYCLLinkTargets;
6335+
if (SYCLTargets) {
6336+
Arg *SYCLTargetsValues = SYCLTargets;
64016337
// Fill SYCLTripleList
64026338
llvm::StringMap<StringRef> FoundNormalizedTriples;
64036339
for (StringRef Val : SYCLTargetsValues->getValues()) {
@@ -6498,29 +6434,6 @@ class OffloadingActionBuilder final {
64986434
}
64996435
}
65006436
}
6501-
if (SYCLAddTargets) {
6502-
for (StringRef Val : SYCLAddTargets->getValues()) {
6503-
// Parse out the Triple and Input (triple:binary). At this point,
6504-
// the format has already been validated at the Driver level.
6505-
// Populate the pairs. Each of these will be wrapped and fed
6506-
// into the final binary.
6507-
std::pair<StringRef, StringRef> I = Val.split(':');
6508-
llvm::Triple TT(I.first);
6509-
6510-
auto TCIt = llvm::find_if(
6511-
ToolChains, [&](auto &TC) { return TT == TC->getTriple(); });
6512-
assert(TCIt != ToolChains.end() &&
6513-
"Toolchain was not created for this platform");
6514-
6515-
const char *TF = C.getArgs().MakeArgString(I.second);
6516-
// populate the AOT binary inputs vector.
6517-
SYCLAOTInputs.push_back(std::make_pair(TT, TF));
6518-
ShouldAddDefaultTriple = false;
6519-
// Add an empty entry to the Device list
6520-
if (TT.getSubArch() == llvm::Triple::SPIRSubArch_gen)
6521-
GpuArchList.emplace_back(TT, nullptr);
6522-
}
6523-
}
65246437
} else if (HasValidSYCLRuntime) {
65256438
// -fsycl is provided without -fsycl-*targets.
65266439
bool SYCLfpga = C.getInputArgs().hasArg(options::OPT_fintelfpga);
@@ -6540,9 +6453,8 @@ class OffloadingActionBuilder final {
65406453

65416454
WrapDeviceOnlyBinary =
65426455
Args.hasArg(options::OPT_fsycl_link_EQ) && !SYCLfpgaTriple;
6543-
// Device only compilation for -fsycl-link (no FPGA) and
6544-
// -fsycl-link-targets
6545-
CompileDeviceOnly = (SYCLLinkTargets || WrapDeviceOnlyBinary);
6456+
// Device only compilation for -fsycl-link (no FPGA)
6457+
CompileDeviceOnly = WrapDeviceOnlyBinary;
65466458

65476459
// Set the FPGA output type based on command line (-fsycl-link).
65486460
if (auto *A = C.getInputArgs().getLastArg(options::OPT_fsycl_link_EQ)) {
@@ -7599,12 +7511,9 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
75997511
}
76007512

76017513
// Add a link action if necessary.
7602-
// When offloading with -fsycl-link-targets, no link action is processed
7603-
// as we stop at the spirv-translation step.
76047514
Arg *FinalPhaseArg;
76057515
if (!UseNewOffloadingDriver &&
7606-
getFinalPhase(Args, &FinalPhaseArg) == phases::Link &&
7607-
!Args.hasArg(options::OPT_fsycl_link_targets_EQ)) {
7516+
getFinalPhase(Args, &FinalPhaseArg) == phases::Link) {
76087517
if (Args.hasArg(options::OPT_fsycl_link_EQ) &&
76097518
!Args.hasArg(options::OPT_fintelfpga)) {
76107519
ActionList LAList;
@@ -9296,12 +9205,10 @@ InputInfoList Driver::BuildJobsForActionNoCache(
92969205
Result = {InputInfo(A, BaseInput)};
92979206
else {
92989207
std::string OffloadingPrefix;
9299-
// When generating binaries with -fsycl-link-target or -fsycl-link, the
9300-
// output file prefix is the triple arch only. Do not add the arch when
9301-
// compiling for host.
9208+
// When generating binaries with -fsycl-link, the output file prefix is the
9209+
// triple arch only. Do not add the arch when compiling for host.
93029210
if (!A->getOffloadingHostActiveKinds() &&
9303-
(Args.getLastArg(options::OPT_fsycl_link_targets_EQ) ||
9304-
Args.hasArg(options::OPT_fsycl_link_EQ))) {
9211+
Args.hasArg(options::OPT_fsycl_link_EQ)) {
93059212
OffloadingPrefix = "-";
93069213
OffloadingPrefix += TC->getTriple().getArchName();
93079214
} else {

0 commit comments

Comments
 (0)