@@ -1138,6 +1138,16 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1138
1138
else
1139
1139
ArgM = ArgMD;
1140
1140
1141
+ auto createFPGATempDepFile = [&](const char *&DepFile) {
1142
+ // Generate dependency files as temporary. These will be used for the
1143
+ // aoc call/bundled during fat object creation
1144
+ std::string BaseName (Clang::getBaseInputName (Args, Inputs[0 ]));
1145
+ std::string DepTmpName =
1146
+ C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseName), " d" );
1147
+ DepFile = C.addTempFile (C.getArgs ().MakeArgString (DepTmpName));
1148
+ C.getDriver ().addFPGATempDepFile (DepFile, BaseName);
1149
+ };
1150
+
1141
1151
if (ArgM) {
1142
1152
// Determine the output location.
1143
1153
const char *DepFile;
@@ -1148,16 +1158,9 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1148
1158
DepFile = Output.getFilename ();
1149
1159
} else if (!ArgMD) {
1150
1160
DepFile = " -" ;
1151
- } else if (ArgMD->getOption ().matches (options::OPT_MMD) &&
1152
- Args.hasArg (options::OPT_fintelfpga) &&
1161
+ } else if (Args.hasArg (options::OPT_fintelfpga) &&
1153
1162
JA.isDeviceOffloading (Action::OFK_SYCL)) {
1154
- // Generate dependency files as temporary. These will be used for the
1155
- // aoc call/bundled during fat object creation
1156
- std::string BaseName (Clang::getBaseInputName (Args, Inputs[0 ]));
1157
- std::string DepTmpName =
1158
- C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseName), " d" );
1159
- DepFile = C.addTempFile (C.getArgs ().MakeArgString (DepTmpName));
1160
- C.getDriver ().addFPGATempDepFile (DepFile, BaseName);
1163
+ createFPGATempDepFile (DepFile);
1161
1164
} else {
1162
1165
DepFile = getDependencyFileName (Args, Inputs);
1163
1166
C.addFailureResultFile (DepFile, &JA);
@@ -1212,6 +1215,22 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1212
1215
CmdArgs.push_back (" -module-file-deps" );
1213
1216
}
1214
1217
1218
+ if (!ArgM && Args.hasArg (options::OPT_fintelfpga) &&
1219
+ JA.isDeviceOffloading (Action::OFK_SYCL)) {
1220
+ // No dep generation option was provided, add all of the needed options
1221
+ // to ensure a successful dep generation.
1222
+ const char *DepFile;
1223
+ createFPGATempDepFile (DepFile);
1224
+ CmdArgs.push_back (" -dependency-file" );
1225
+ CmdArgs.push_back (DepFile);
1226
+ CmdArgs.push_back (" -MT" );
1227
+ SmallString<128 > P (Inputs[0 ].getBaseInput ());
1228
+ llvm::sys::path::replace_extension (P, " o" );
1229
+ SmallString<128 > Quoted;
1230
+ QuoteTarget (llvm::sys::path::filename (P), Quoted);
1231
+ CmdArgs.push_back (Args.MakeArgString (Quoted));
1232
+ }
1233
+
1215
1234
if (Args.hasArg (options::OPT_MG)) {
1216
1235
if (!ArgM || ArgM->getOption ().matches (options::OPT_MD) ||
1217
1236
ArgM->getOption ().matches (options::OPT_MMD))
0 commit comments