https://bugzilla.redhat.com/show_bug.cgi?id=2209759
--- Comment #5 from Philipp K. philipp-dev@knechtges.com --- With the device libs stuff out of the way, I used to and with your new version still have problems with <math.h> not being found. This is mostly due to hipcc doing -isystem /usr/include to early, which breaks the #include_next logic of libstdc++. There are also a lot of paths to fix in hipcc and hipconfig.
A modernized patch of these issues would look sth like this
From ba9778102dc7d3ae6268b3ad0c4e8c165d44e153 Mon Sep 17 00:00:00 2001 From: Philipp Knechtges philipp-dev@knechtges.com Date: Mon, 29 May 2023 07:50:05 +0200 Subject: [PATCH] fixing some paths and avoid math.h not being found
--- bin/hipcc.pl | 22 ++++++++++++---------- bin/hipvars.pm | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/bin/hipcc.pl b/bin/hipcc.pl index 2cd37529..49a5755f 100644 --- a/bin/hipcc.pl +++ b/bin/hipcc.pl @@ -131,6 +131,9 @@ $ROCM_PATH = $hipvars::ROCM_PATH; $HIP_VERSION = $hipvars::HIP_VERSION; $HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;
+$CLANG_RESOURCE_DIR = `$HIP_CLANG_PATH/$HIP_COMPILER --print-resource-dir`; +chomp($CLANG_RESOURCE_DIR); + if ($HIP_PLATFORM eq "amd") { # If using ROCclr runtime, need to find HIP_ROCCLR_HOME if (!defined $DEVICE_LIB_PATH and -e "$HIP_ROCCLR_HOME/lib/bitcode") { @@ -138,7 +141,7 @@ if ($HIP_PLATFORM eq "amd") { } $HIP_INCLUDE_PATH = "$HIP_ROCCLR_HOME/include"; if (!defined $HIP_LIB_PATH) { - $HIP_LIB_PATH = "$HIP_ROCCLR_HOME/lib"; + $HIP_LIB_PATH = "$HIP_ROCCLR_HOME/lib64"; }
if (!defined $DEVICE_LIB_PATH) { @@ -146,9 +149,7 @@ if ($HIP_PLATFORM eq "amd") { $DEVICE_LIB_PATH = "$ROCM_PATH/amdgcn/bitcode"; } else { - # This path is to support an older build of the device library - # TODO: To be removed in the future. - $DEVICE_LIB_PATH = "$ROCM_PATH/lib"; + $DEVICE_LIB_PATH = "$CLANG_RESOURCE_DIR/amdgcn/bitcode"; } } } @@ -194,7 +195,7 @@ if ($HIP_PLATFORM eq "amd") { $HIP_INCLUDE_PATH = "$HIP_PATH/include"; } if (! defined $HIP_LIB_PATH) { - $HIP_LIB_PATH = "$HIP_PATH/lib"; + $HIP_LIB_PATH = "$HIP_PATH/lib64"; } if ($verbose & 0x2) { print ("ROCM_PATH=$ROCM_PATH\n"); @@ -231,9 +232,10 @@ if ($HIP_PLATFORM eq "amd") { exit (-1); }
-# Add paths to common HIP includes: -$HIPCXXFLAGS .= " -isystem "$HIP_INCLUDE_PATH"" ; -$HIPCFLAGS .= " -isystem "$HIP_INCLUDE_PATH"" ; +# Including /usr/include too early breaks the #include_next logic of libstdc++ +# and one gets these nice errors "'math.h' file not found" +#$HIPCXXFLAGS .= " -isystem "$HIP_INCLUDE_PATH"" ; +#$HIPCFLAGS .= " -isystem "$HIP_INCLUDE_PATH"" ;
my $compileOnly = 0; my $needCXXFLAGS = 0; # need to add CXX flags to compile step @@ -583,8 +585,8 @@ if ($HIP_PLATFORM eq "amd") { }
if ($hasHIP) { - if ($DEVICE_LIB_PATH ne "$ROCM_PATH/amdgcn/bitcode") { - $HIPCXXFLAGS .= " --hip-device-lib-path="$DEVICE_LIB_PATH""; + if ($DEVICE_LIB_PATH ne "$CLANG_RESOURCE_DIR/amdgcn/bitcode") { + $HIPCXXFLAGS .= " --rocm-device-lib-path="$DEVICE_LIB_PATH""; } }
diff --git a/bin/hipvars.pm b/bin/hipvars.pm index c0c2eaa3..c93fd469 100644 --- a/bin/hipvars.pm +++ b/bin/hipvars.pm @@ -79,7 +79,7 @@ if (-e "$HIP_PATH/bin/rocm_agent_enumerator") { }elsif (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { # case for backward compatibility $ROCM_PATH=$ENV{'ROCM_PATH'} // dirname("$HIP_PATH"); # use parent directory of HIP_PATH } else { - $ROCM_PATH=$ENV{'ROCM_PATH'} // "/opt/rocm"; + $ROCM_PATH=$ENV{'ROCM_PATH'} // "/usr"; } $CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda';
@@ -87,7 +87,7 @@ $CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda'; if ($isWindows) { $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$HIP_PATH/bin"; } else { - $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$ROCM_PATH/llvm/bin"; + $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$ROCM_PATH/bin"; } # HIP_ROCCLR_HOME is used by Windows builds $HIP_ROCCLR_HOME=$ENV{'HIP_ROCCLR_HOME'};