HIP icon indicating copy to clipboard operation
HIP copied to clipboard

Name collision ("__noinline__") between GCC 12's libstdc++ and HIP

Open FilipVaverka opened this issue 2 years ago • 4 comments

Upgrading to GCC 12.1 and its matching libstdc++ breaks HIP code which uses libstdc++'s headers such as "". The origin of the issue seems to be in that libstdc++ started to use GCC attributes in two underscore form (such as "__attribute__((__noinline__))", in eg. shared_ptr implementation), which are also redefined by HIP. This causes invalid substitutions in cases such as:

#include <hip/hip_runtime.h> // defines #define __noinline__ __attribute__((noinline))
#include <memory> // uses "__attribute__((__noinline__))" -> __attribute__((__attribute__((noinline))))

Similar issue emerged with boost (here #2355) before, but I'm not sure if libstdc++ would implement similar fix. Otherwise I don't see any good solution except workarounds such as #undef __noinline__ when not needed or including libstdc++ headers first.

FilipVaverka avatar May 14 '22 16:05 FilipVaverka

Thanks for reporting. We introduced __noinilne__ as a keyword for HIP in clang (https://reviews.llvm.org/D124866) and will remove the __noinline__ macro from HIP headers. This should fix the issue.

yxsamliu avatar May 16 '22 14:05 yxsamliu

This issue should be closed with: https://github.com/ROCm-Developer-Tools/hipamd/commit/28009bc68faf2b4dd8fda91c99b0725e1b063a18

@yxsamliu

acxz avatar Jul 10 '22 18:07 acxz

Similar issue emerged with boost (here #2355) before, but I'm not sure if libstdc++ would implement similar fix.

No, absolutely not. That is not an option for libstdc++ because it would break this valid C++ program:

#define noinline some garbage )[ tokens 
#include <memory>

Fixing it in HIP was the right thing to do.

jwakely avatar Jul 26 '22 11:07 jwakely

still seems present in 5.2.1 on gcc-12 (Ubuntu 12-20220319-1ubuntu1)

log.txt

as seen in https://github.com/rocm-arch/rocm-arch/issues/780 and in https://github.com/xuhuisheng/rocm-build/issues/31

FCLC avatar Jul 26 '22 20:07 FCLC