From f0935e6d4f424c82f065c0c22ca5b48e6ed2099a Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 13 Jun 2018 10:01:14 -0400 Subject: [PATCH 1/3] 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"; From 2b32dbd414226adcac8c8b31211031128fffd6a8 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Sun, 17 Jun 2018 12:18:37 -0400 Subject: [PATCH 2/3] Fix handling of static library in hipcc for hip-clang --- bin/hipcc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index ca504fae4e..4c526bd2c7 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -391,17 +391,20 @@ foreach $arg (@ARGV) my $isObj = ($fileType =~ m/ELF/ or $fileType =~ m/COFF/); $allIsObj = ($allIsObj and $isObj); if ($isObj) { - $realObjs = $realObjs . " " . $obj; + $realObjs = ($realObjs . " " . $obj); } else { push (@inputs, $obj); $new_arg = "$new_arg $obj"; } } + chomp $realObjs; if ($allIsObj) { print $out "$line\n"; - } else { - system("cd $tmpdir; ar c $libFile $realObjs"); - print $out "$tmpdir/$libFile\n"; + } elsif ($realObjs) { + my $libBaseName = basename($libFile, ".a"); + $libBaseName = mktemp($libBaseName . "XXXX") . ".a"; + system("cd $tmpdir; ar c $libBaseName $realObjs"); + print $out "$tmpdir/$libBaseName\n"; } } else { print $out "$line\n"; From 46d3c1d51e26f6e464e32872504d4219c3c5dec8 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Mon, 18 Jun 2018 21:43:24 -0400 Subject: [PATCH 3/3] Let hipcc handle library with extension lo for hip-clang --- bin/hipcc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index 4c526bd2c7..f5fe4249ca 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -376,7 +376,7 @@ 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`); @@ -401,8 +401,8 @@ foreach $arg (@ARGV) if ($allIsObj) { print $out "$line\n"; } elsif ($realObjs) { - my $libBaseName = basename($libFile, ".a"); - $libBaseName = mktemp($libBaseName . "XXXX") . ".a"; + my($libBaseName, $libDir, $libExt) = fileparse($libFile); + $libBaseName = mktemp($libBaseName . "XXXX") . $libExt; system("cd $tmpdir; ar c $libBaseName $realObjs"); print $out "$tmpdir/$libBaseName\n"; }