@@ -144,20 +144,13 @@ const string& HipBinAmd::getHipLdFlags() const {
144
144
145
145
146
146
void HipBinAmd::initializeHipLdFlags () {
147
- string hipLibPath;
148
147
string hipLdFlags;
149
148
const string& hipClangPath = getCompilerPath ();
150
149
// If $HIPCC clang++ is not compiled, use clang instead
151
150
string hipCC = " \" " + hipClangPath + " /clang++" ;
152
151
if (!fs::exists (hipCC)) {
153
152
hipLdFlags = " --driver-mode=g++" ;
154
153
}
155
- hipLibPath = getHipLibPath ();
156
- hipLdFlags += " -L\" " + hipLibPath + " \" " ;
157
- const OsType& os = getOSInfo ();
158
- if (os == windows) {
159
- hipLdFlags += " -lamdhip64" ;
160
- }
161
154
hipLdFlags_ = hipLdFlags;
162
155
}
163
156
@@ -385,17 +378,13 @@ bool HipBinAmd::detectPlatform() {
385
378
string HipBinAmd::getHipLibPath () const {
386
379
string hipLibPath;
387
380
const EnvVariables& env = getEnvVariables ();
388
- if (env.hipLibPathEnv_ .empty ()) {
389
- const string& rocclrHomePath = getRocclrHomePath ();
390
- fs::path libPath = rocclrHomePath;
391
- libPath /= " lib" ;
392
- hipLibPath = libPath.string ();
381
+ if (!env.hipLibPathEnv_ .empty ()) {
382
+ hipLibPath = env.hipLibPathEnv_ ;
393
383
}
394
- if (hipLibPath.empty ()) {
395
- const string& hipPath = getHipPath ();
396
- fs::path libPath = hipPath;
397
- libPath /= " lib" ;
398
- hipLibPath = libPath.string ();
384
+ else if (!env.hipPathEnv_ .empty ()) {
385
+ fs::path p = env.hipLibPathEnv_ ;
386
+ p /= " lib" ;
387
+ hipLibPath = p.string ();
399
388
}
400
389
return hipLibPath;
401
390
}
@@ -500,8 +489,6 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
500
489
bool printLDFlags = 0 ; // print HIPLDFLAGS
501
490
bool runCmd = 1 ;
502
491
bool buildDeps = 0 ;
503
- bool linkType = 1 ;
504
- bool setLinkType = 0 ;
505
492
string hsacoVersion;
506
493
bool funcSupp = 0 ; // enable function support
507
494
bool rdc = 0 ; // whether -fgpu-rdc is on
@@ -616,14 +603,13 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
616
603
compileOnly = 1 ;
617
604
buildDeps = 1 ;
618
605
}
619
- if ((trimarg == " -use-staticlib" ) && (setLinkType == 0 )) {
620
- linkType = 0 ;
621
- setLinkType = 1 ;
622
- swallowArg = 1 ;
606
+ if ((trimarg == " -use-staticlib" )) {
607
+ std::cerr << " Warning: The -use-staticlib option has been deprecated and is no longer needed.\n " ;
608
+ swallowArg = true ;
623
609
}
624
- if ((trimarg == " -use-sharedlib" ) && (setLinkType == 0 ) ) {
625
- linkType = 1 ;
626
- setLinkType = 1 ;
610
+ if ((trimarg == " -use-sharedlib" )) {
611
+ std::cerr << " Warning: The -use-sharedlib option has been deprecated and is no longer needed. \n " ;
612
+ swallowArg = true ;
627
613
}
628
614
if (hipBinUtilPtr_->stringRegexMatch (arg, " ^-O.*" )) {
629
615
optArg = arg;
@@ -846,11 +832,6 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
846
832
if (buildDeps) {
847
833
HIPCXXFLAGS += " --cuda-host-only" ;
848
834
}
849
- // Add --hip-link only if it is compile only and -fgpu-rdc is on.
850
- if (rdc && !compileOnly) {
851
- HIPLDFLAGS += " --hip-link" ;
852
- HIPLDFLAGS += HIPLDARCHFLAGS;
853
- }
854
835
855
836
// hipcc currrently requires separate compilation of source files,
856
837
// ie it is not possible to pass
@@ -884,27 +865,21 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
884
865
HIPCXXFLAGS += hip_device_lib_str;
885
866
}
886
867
}
887
- if (os != windows) {
888
- HIPLDFLAGS += " -lgcc_s -lgcc -lpthread -lm -lrt" ;
889
- }
890
868
891
- if (os != windows && !compileOnly) {
892
- string hipClangVersion, toolArgTemp;
893
- if (linkType == 0 ) {
894
- toolArgTemp = " -L" + hipLibPath + " -lamdhip64 -L" +
895
- roccmPath+ " /lib -lhsa-runtime64 -ldl -lnuma " + toolArgs;
896
- toolArgs = toolArgTemp;
897
- } else {
898
- toolArgTemp = toolArgs + " -Wl,-rpath=" + hipLibPath + " :"
899
- + roccmPath+" /lib -lamdhip64 " ;
900
- toolArgs = toolArgTemp;
869
+ if (!compileOnly) {
870
+ string hip_path = getHipLibPath ();
871
+ if (!hip_path.empty ()) {
872
+ HIPLDFLAGS += " -L" + hip_path;
873
+ }
874
+ HIPLDFLAGS += " --hip-link" ;
875
+ if (rdc) {
876
+ HIPLDFLAGS += HIPLDARCHFLAGS;
877
+ }
878
+ if (!windows) {
879
+ HIPLDFLAGS += " --rtlib=compiler-rt -unwindlib=libgcc" ;
901
880
}
902
-
903
- hipClangVersion = getCompilerVersion ();
904
- // To support __fp16 and _Float16, explicitly link with compiler-rt
905
- toolArgs += " -L" + hipClangPath + " /../lib/clang/" +
906
- hipClangVersion + " /lib/linux -lclang_rt.builtins-x86_64 " ;
907
881
}
882
+
908
883
if (!var.hipccCompileFlagsAppendEnv_ .empty ()) {
909
884
HIPCXXFLAGS += " " + var.hipccCompileFlagsAppendEnv_ + " " ;
910
885
HIPCFLAGS += " " + var.hipccCompileFlagsAppendEnv_ + " " ;
0 commit comments