From 86a0af8a0437d8d64e669e67145b51c0c187286d Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary <51944368+cjatin@users.noreply.github.com> Date: Fri, 24 Sep 2021 16:28:25 +0530 Subject: [PATCH] SWDEV-294226 - Add -x c++ if openmp targets are mentioned (#2363) Change-Id: Ie15d63eebe2b0b86487ac59845b4fc7f5e5a9e86 [ROCm/hip commit: 63dfe6e8a1271f555b6bca1a1b211a74580b5f7f] --- projects/hip/bin/hipcc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index c72badcf69..840aaafd41 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -229,6 +229,7 @@ my $needCXXFLAGS = 0; # need to add CXX flags to compile step my $needCFLAGS = 0; # need to add C flags to compile step my $needLDFLAGS = 1; # need to add LDFLAGS to compile step. my $fileTypeFlag = 0; # to see if -x flag is mentioned +my $hasOMPTargets = 0; # If OMP targets is mentioned my $hasC = 0; # options contain a c-style file my $hasCXX = 0; # options contain a cpp-style file (NVCC must force recognition as GPU file) my $hasCU = 0; # options contain a cu-style file (HCC must force recognition as GPU file) @@ -517,6 +518,8 @@ foreach $arg (@ARGV) $hasC = 0; $hasCXX = 0; $hasHIP = 1; + } elsif ($arg =~ '-fopenmp-targets=') { + $hasOMPTargets = 1; } elsif ($arg =~ m/^-/) { # options start with - if ($arg eq '-fgpu-rdc') { @@ -555,7 +558,7 @@ foreach $arg (@ARGV) $toolArgs .= " -x c"; } elsif (($arg =~ /\.cpp$/) or ($arg =~ /\.cxx$/) or ($arg =~ /\.cc$/) or ($arg =~ /\.C$/)) { $needCXXFLAGS = 1; - if ($HIP_COMPILE_CXX_AS_HIP eq '0' or $HIP_PLATFORM ne "amd") { + if ($HIP_COMPILE_CXX_AS_HIP eq '0' or $HIP_PLATFORM ne "amd" or $hasOMPTargets eq 1) { $hasCXX = 1; } elsif ($HIP_PLATFORM eq "amd") { $hasHIP = 1;