From f0935e6d4f424c82f065c0c22ca5b48e6ed2099a Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 13 Jun 2018 10:01:14 -0400 Subject: [PATCH] Let hipcc handle static library for hip-clang only if it contains bundles --- bin/hipcc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index 03f35b27fc..ca504fae4e 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -377,14 +377,31 @@ foreach $arg (@ARGV) while (my $line = <$in>) { chomp $line; if ($line =~ m/\.a$/) { + 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"; + } + } + if ($allIsObj) { + print $out "$line\n"; + } else { + system("cd $tmpdir; ar c $libFile $realObjs"); + print $out "$tmpdir/$libFile\n"; } } else { print $out "$line\n";