Improve shared and static library support

hipcc accepts new parameter -use-staticlib and -use-sharedlib to
control linking behavior. Default is still static library.

Change-Id: I28fb9a939f8177c75abefd8b77d8118a6666d1f4


[ROCm/hip commit: ef046c7098]
This commit is contained in:
Maneesh Gupta
2016-12-01 15:33:12 +05:30
parent dead181892
commit eaf16d02f2
3 ha cambiato i file con 27 aggiunte e 47 eliminazioni
+14 -9
Vedi File
@@ -193,7 +193,8 @@ my $needHipHcc = ($HIP_PLATFORM eq 'hcc'); # set if we need to link hip_hcc
my $printHipVersion = 0; # print HIP version
my $runCmd = 1;
my $buildDeps = 0;
my $linkType = 0;
my $setLinkType = 0;
my @options = ();
my @inputs = ();
@@ -275,11 +276,20 @@ foreach $arg (@ARGV)
$compileOnly = 1;
$buildDeps = 1;
}
if($arg eq '-use_fast_math') {
print "In fast Math";
$HIPCXXFLAGS .= " -DHIP_FAST_MATH ";
}
if(($arg eq '-use-staticlib') and ($setLinkType eq 0))
{
$linkType = 0;
$setLinkType = 1;
}
if(($arg eq '-use-sharedlib') and ($setLinkType eq 0))
{
$linkType = 1;
$setLinkType = 1;
}
if ($arg =~ m/^-/) {
# options start with -
@@ -328,13 +338,8 @@ if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc')
}
if ($needHipHcc) {
$HIP_LIB_TYPE = $hipConfig{'HIP_LIB_TYPE'} // 1;
# TODO - remove the old sea-of-objects solution:
if ($HIP_LIB_TYPE eq 0) {
substr($HIPLDFLAGS,0,0) = " $HIP_PATH/lib/device_util.cpp.o $HIP_PATH/lib/hip_device.cpp.o $HIP_PATH/lib/hip_error.cpp.o $HIP_PATH/lib/hip_event.cpp.o $HIP_PATH/lib/hip_hcc.cpp.o $HIP_PATH/lib/hip_memory.cpp.o $HIP_PATH/lib/hip_peer.cpp.o $HIP_PATH/lib/hip_stream.cpp.o $HIP_PATH/lib/hip_ldg.cpp.o $HIP_PATH/lib/hip_fp16.cpp.o $HIP_PATH/lib/hip_context.cpp.o $HIP_PATH/lib/hip_module.cpp.o ";
} elsif ($HIP_LIB_TYPE eq 1) {
substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -lhip_hcc " ;
if ($linkType eq 0) {
substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -lhip_hcc_static -lhip_device " ;
} else {
substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -Wl,--rpath=$HIP_PATH/lib -lhip_hcc -lhip_device ";
}