@@ -76,6 +76,7 @@ class HipBinAmd : public HipBinBase {
76
76
// non virtual functions
77
77
const string& getHsaPath () const ;
78
78
const string& getRocclrHomePath () const ;
79
+ const bool isWindows () const ;
79
80
};
80
81
81
82
HipBinAmd::HipBinAmd () {
@@ -196,26 +197,25 @@ void HipBinAmd::initializeHipCXXFlags() {
196
197
197
198
// populates clang path.
198
199
void HipBinAmd::constructCompilerPath () {
199
- string complierPath ;
200
+ string compilerPath ;
200
201
const EnvVariables& envVariables = getEnvVariables ();
201
202
if (envVariables.hipClangPathEnv_ .empty ()) {
202
203
fs::path hipClangPath;
203
- const OsType& osInfo = getOSInfo ();
204
- if (osInfo == windows) {
205
- complierPath = getHipPath () ;
206
- hipClangPath = complierPath ;
204
+ if ( isWindows ()) {
205
+ compilerPath = getHipPath ();
206
+ hipClangPath = compilerPath ;
207
+ hipClangPath /= " bin " ;
207
208
} else {
208
- complierPath = getRoccmPath ();
209
- hipClangPath = complierPath;
209
+ compilerPath = getRoccmPath ();
210
+ hipClangPath = compilerPath;
211
+ hipClangPath /= " llvm/bin" ;
210
212
}
211
213
212
- hipClangPath /= " llvm/bin" ;
213
-
214
- complierPath = hipClangPath.string ();
214
+ compilerPath = hipClangPath.string ();
215
215
} else {
216
- complierPath = envVariables.hipClangPathEnv_ ;
216
+ compilerPath = envVariables.hipClangPathEnv_ ;
217
217
}
218
- hipClangPath_ = complierPath ;
218
+ hipClangPath_ = compilerPath ;
219
219
}
220
220
221
221
// returns clang path.
@@ -224,10 +224,9 @@ const string& HipBinAmd::getCompilerPath() const {
224
224
}
225
225
226
226
void HipBinAmd::printCompilerInfo () const {
227
- const OsType& os = getOSInfo ();
228
227
const string& hipClangPath = getCompilerPath ();
229
228
const string& hipPath = getHipPath ();
230
- if (os == windows ) {
229
+ if (isWindows () ) {
231
230
string cmd = hipClangPath + " /clang++ --print-resource-dir" ;
232
231
system (cmd.c_str ()); // hipclang version
233
232
cout << " llc-version :" << endl;
@@ -256,7 +255,7 @@ void HipBinAmd::printCompilerInfo() const {
256
255
}
257
256
258
257
string HipBinAmd::getCompilerVersion () {
259
- string out, complierVersion ;
258
+ string out, compilerVersion ;
260
259
const string& hipClangPath = getCompilerPath ();
261
260
fs::path cmdAmd = hipClangPath;
262
261
cmdAmd /= " clang++" ;
@@ -267,13 +266,13 @@ string HipBinAmd::getCompilerVersion() {
267
266
if (m.size () > 1 ) {
268
267
// get the index =1 match, 0=whole match we ignore
269
268
std::ssub_match sub_match = m[1 ];
270
- complierVersion = sub_match.str ();
269
+ compilerVersion = sub_match.str ();
271
270
}
272
271
}
273
272
} else {
274
273
std::cerr << " Hip Clang Compiler not found" << endl;
275
274
}
276
- return complierVersion ;
275
+ return compilerVersion ;
277
276
}
278
277
279
278
@@ -293,8 +292,7 @@ string HipBinAmd::getCppConfig() {
293
292
const string& hipPath = getHipPath ();
294
293
hipPathInclude = hipPath;
295
294
hipPathInclude /= " include" ;
296
- const OsType& osInfo = getOSInfo ();
297
- if (osInfo == windows) {
295
+ if (isWindows ()) {
298
296
cppConfig += " -I" + hipPathInclude.string ();
299
297
cppConfigFs = cppConfig;
300
298
cppConfigFs /= " /" ;
@@ -359,12 +357,19 @@ string HipBinAmd::getHipCC() const {
359
357
string hipCC;
360
358
const string& hipClangPath = getCompilerPath ();
361
359
fs::path compiler = hipClangPath;
362
- compiler /= " clang++" ;
360
+ if (isWindows ())
361
+ compiler /= " clang.exe" ;
362
+ else
363
+ compiler /= " clang++" ;
364
+
363
365
if (!fs::exists (compiler)) {
364
366
fs::path compiler = hipClangPath;
365
367
compiler /= " clang" ;
366
368
}
367
369
hipCC = compiler.string ();
370
+
371
+ if (isWindows ()) // wrap hipcc (clang) command in escaped double quotes.
372
+ hipCC = " \" " + hipCC + " \" " ;
368
373
return hipCC;
369
374
}
370
375
@@ -423,6 +428,10 @@ void HipBinAmd::printFull() {
423
428
cout << endl;
424
429
}
425
430
431
+ const bool HipBinAmd::isWindows () const {
432
+ const OsType& osInfo = getOSInfo ();
433
+ return (osInfo == windows);
434
+ }
426
435
427
436
void HipBinAmd::executeHipCCCmd (vector<string> argv) {
428
437
if (argv.size () < 2 ) {
@@ -668,6 +677,9 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
668
677
} else if (hasCXX || hasHIP) {
669
678
needCXXFLAGS = 1 ;
670
679
}
680
+ if (isWindows ())
681
+ arg = " \" " + arg + " \" " ;
682
+
671
683
inputs.push_back (arg);
672
684
// print "I: <$arg>\n";
673
685
}
@@ -677,7 +689,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
677
689
// Do the quoting here because sometimes the $arg is changed in the loop
678
690
// Important to have all of '-Xlinker' in the set of unquoted characters.
679
691
// Windows needs different quoting, ignore for now
680
- if (os != windows && escapeArg) {
692
+ if (! isWindows () && escapeArg) {
681
693
regex reg (" [^-a-zA-Z0-9_=+,.\\ /]" );
682
694
arg = regex_replace (arg, reg, " \\ $&" );
683
695
}
@@ -885,12 +897,15 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
885
897
cout << HIPLDFLAGS;
886
898
}
887
899
if (runCmd) {
900
+ if (isWindows ())
901
+ CMD = " \" " + CMD + " \" " ;
902
+
888
903
SystemCmdOut sysOut;
889
904
sysOut = hipBinUtilPtr_->exec (CMD.c_str (), true );
890
905
string cmdOut = sysOut.out ;
891
906
int CMD_EXIT_CODE = sysOut.exitCode ;
892
907
if (CMD_EXIT_CODE !=0 ) {
893
- std::cerr << " failed to execute:" << CMD << std::endl;
908
+ std::cerr << " failed to execute:" << CMD << std::endl;
894
909
}
895
910
exit (CMD_EXIT_CODE);
896
911
} // end of runCmd section
0 commit comments