@@ -8148,11 +8148,25 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
8148
8148
const InputInfoList &Inputs,
8149
8149
const ArgList &Args,
8150
8150
const char *LinkingOutput) const {
8151
+ const Driver &D = getToolChain ().getDriver ();
8152
+ const llvm::Triple TheTriple = getToolChain ().getTriple ();
8153
+ auto OpenMPTCRange = C.getOffloadToolChains <Action::OFK_OpenMP>();
8151
8154
ArgStringList CmdArgs;
8152
8155
8153
- if (getToolChain ().getDriver ().isUsingLTO (/* IsOffload */ true )) {
8156
+ // Pass the CUDA path to the linker wrapper tool.
8157
+ for (auto &I : llvm::make_range (OpenMPTCRange.first , OpenMPTCRange.second )) {
8158
+ const ToolChain *TC = I.second ;
8159
+ if (TC->getTriple ().isNVPTX ()) {
8160
+ CudaInstallationDetector CudaInstallation (D, TheTriple, Args);
8161
+ if (CudaInstallation.isValid ())
8162
+ CmdArgs.push_back (Args.MakeArgString (
8163
+ " --cuda-path=" + CudaInstallation.getInstallPath ()));
8164
+ break ;
8165
+ }
8166
+ }
8167
+
8168
+ if (D.isUsingLTO (/* IsOffload */ true )) {
8154
8169
// Pass in target features for each toolchain.
8155
- auto OpenMPTCRange = C.getOffloadToolChains <Action::OFK_OpenMP>();
8156
8170
for (auto &I :
8157
8171
llvm::make_range (OpenMPTCRange.first , OpenMPTCRange.second )) {
8158
8172
const ToolChain *TC = I.second ;
@@ -8165,9 +8179,10 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
8165
8179
}
8166
8180
8167
8181
// Pass in the bitcode library to be linked during LTO.
8168
- for (auto &I : llvm::make_range (OpenMPTCRange.first , OpenMPTCRange.second )) {
8182
+ for (auto &I :
8183
+ llvm::make_range (OpenMPTCRange.first , OpenMPTCRange.second )) {
8169
8184
const ToolChain *TC = I.second ;
8170
- const Driver &D = TC->getDriver ();
8185
+ const Driver &TCDriver = TC->getDriver ();
8171
8186
const ArgList &TCArgs = C.getArgsForToolChain (TC, " " , Action::OFK_OpenMP);
8172
8187
StringRef Arch = TCArgs.getLastArgValue (options::OPT_march_EQ);
8173
8188
@@ -8182,7 +8197,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
8182
8197
BitcodeSuffix += Arch;
8183
8198
8184
8199
ArgStringList BitcodeLibrary;
8185
- addOpenMPDeviceRTL (D , TCArgs, BitcodeLibrary, BitcodeSuffix,
8200
+ addOpenMPDeviceRTL (TCDriver , TCArgs, BitcodeLibrary, BitcodeSuffix,
8186
8201
TC->getTriple ());
8187
8202
8188
8203
if (!BitcodeLibrary.empty ())
@@ -8210,12 +8225,8 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
8210
8225
}
8211
8226
}
8212
8227
8213
- // Construct the link job so we can wrap around it.
8214
- Linker->ConstructJob (C, JA, Output, Inputs, Args, LinkingOutput);
8215
- const auto &LinkCommand = C.getJobs ().getJobs ().back ();
8216
-
8217
8228
CmdArgs.push_back (" -host-triple" );
8218
- CmdArgs.push_back (Args.MakeArgString (getToolChain (). getTripleString ()));
8229
+ CmdArgs.push_back (Args.MakeArgString (TheTriple. getTriple ()));
8219
8230
if (Args.hasArg (options::OPT_v))
8220
8231
CmdArgs.push_back (" -v" );
8221
8232
@@ -8246,6 +8257,10 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
8246
8257
if (Args.getLastArg (options::OPT_save_temps_EQ))
8247
8258
CmdArgs.push_back (" -save-temps" );
8248
8259
8260
+ // Construct the link job so we can wrap around it.
8261
+ Linker->ConstructJob (C, JA, Output, Inputs, Args, LinkingOutput);
8262
+ const auto &LinkCommand = C.getJobs ().getJobs ().back ();
8263
+
8249
8264
// Add the linker arguments to be forwarded by the wrapper.
8250
8265
CmdArgs.push_back (" -linker-path" );
8251
8266
CmdArgs.push_back (LinkCommand->getExecutable ());
0 commit comments