Merge pull request #517 from ROCm-Developer-Tools/fix-hipcc-link
Let hipcc handle static library for hip-clang only if it contains bun…
This commit is contained in:
@@ -381,15 +381,35 @@ foreach $arg (@ARGV)
|
||||
open my $out, ">", $new_file or die "$new_file: $!";
|
||||
while (my $line = <$in>) {
|
||||
chomp $line;
|
||||
if ($line =~ m/\.a$/) {
|
||||
if ($line =~ m/\.a$/ || $line =~ m/\.lo$/) {
|
||||
my $libFile = $line;
|
||||
my $path = abs_path($line);
|
||||
my @objs = split ('\n', `cd $tmpdir; ar xv $path`);
|
||||
## Check if all files in .a are object files.
|
||||
my $allIsObj = 1;
|
||||
my $realObjs = "";
|
||||
foreach my $obj (@objs) {
|
||||
chomp $obj;
|
||||
$obj =~ s/^x - //;
|
||||
$obj = "$tmpdir/$obj";
|
||||
push (@inputs, $obj);
|
||||
$new_arg = "$new_arg $obj";
|
||||
my $fileType = `file $obj`;
|
||||
my $isObj = ($fileType =~ m/ELF/ or $fileType =~ m/COFF/);
|
||||
$allIsObj = ($allIsObj and $isObj);
|
||||
if ($isObj) {
|
||||
$realObjs = ($realObjs . " " . $obj);
|
||||
} else {
|
||||
push (@inputs, $obj);
|
||||
$new_arg = "$new_arg $obj";
|
||||
}
|
||||
}
|
||||
chomp $realObjs;
|
||||
if ($allIsObj) {
|
||||
print $out "$line\n";
|
||||
} elsif ($realObjs) {
|
||||
my($libBaseName, $libDir, $libExt) = fileparse($libFile);
|
||||
$libBaseName = mktemp($libBaseName . "XXXX") . $libExt;
|
||||
system("cd $tmpdir; ar c $libBaseName $realObjs");
|
||||
print $out "$tmpdir/$libBaseName\n";
|
||||
}
|
||||
} else {
|
||||
print $out "$line\n";
|
||||
|
||||
Reference in New Issue
Block a user