Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

failure to build from source with Gcc 12 headers #38

Open
emollier opened this issue Jul 23, 2022 · 4 comments
Open

failure to build from source with Gcc 12 headers #38

emollier opened this issue Jul 23, 2022 · 4 comments

Comments

@emollier
Copy link

Greetings,

With the recent introduction of Gcc 12 in Debian unstable, I noticed that rocm-hipamd 5.0.0 failed to build from source when hipcc was trying to refer to Gcc 12 headers, see the log below:

-- Generating /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/directed_tests.deviceLib.hipVectorTypesDevice.dir/hip/tests/src/deviceLib/./directed_tests.deviceLib.hipVectorTypesDevice_generated_hipVectorTypesDevice.cpp.o
/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/bin/hipcc -c /<<PKGBUILDDIR>>/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp -o /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/directed_tests.deviceLib.hipVectorTypesDevice.dir/hip/tests/src/deviceLib/./directed_tests.deviceLib.hipVectorTypesDevice_generated_hipVectorTypesDevice.cpp.o --offload-arch=gfx803 -I/<<PKGBUILDDIR>>/include -I/<<PKGBUILDDIR>>/hip/tests/src -I/<<PKGBUILDDIR>>/hip/tests/unit -I/<<PKGBUILDDIR>>/hip/tests/performance -I/<<PKGBUILDDIR>>/include -I/<<PKGBUILDDIR>>/hip/tests/src
In file included from /<<PKGBUILDDIR>>/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp:34:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:77:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr.h:53:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:196:22: error: use of undeclared identifier 'noinline'; did you mean 'inline'?
      __attribute__((__noinline__))
                     ^
/<<PKGBUILDDIR>>/include/hip/amd_detail/host_defines.h:50:37: note: expanded from macro '__noinline__'
#define __noinline__ __attribute__((noinline))
                                    ^
In file included from /<<PKGBUILDDIR>>/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp:34:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:77:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr.h:53:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:196:22: error: type name does not allow function specifier to be specified
/<<PKGBUILDDIR>>/include/hip/amd_detail/host_defines.h:50:37: note: expanded from macro '__noinline__'
#define __noinline__ __attribute__((noinline))
                                    ^
In file included from /<<PKGBUILDDIR>>/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp:34:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:77:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr.h:53:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:196:22: error: expected expression
/<<PKGBUILDDIR>>/include/hip/amd_detail/host_defines.h:50:46: note: expanded from macro '__noinline__'
#define __noinline__ __attribute__((noinline))
                                             ^
3 errors generated when compiling for gfx803.

I worked around the build failure by shunting the __attribute__((noinline)) with the below patch, but it feel rather hacky and possibly wrong (but it builds okay):

--- rocm-hipamd.orig/include/hip/amd_detail/host_defines.h
+++ rocm-hipamd/include/hip/amd_detail/host_defines.h
@@ -47,7 +47,7 @@
 #define __constant__ __attribute__((constant))
 #endif // !__CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__
 
-#define __noinline__ __attribute__((noinline))
+#define __noinline__
 #define __forceinline__ inline __attribute__((always_inline))
 
 #if __HIP_NO_IMAGE_SUPPORT

Having a quick look at hipamd 5.2 source code, it may be possible the issue might be still present, but I can't tell for sure while we haven't completed the upgrade to 5.2 in unstable.

Kind Regards,
Étienne.

@JacekJagosz
Copy link

This issue has been reported some time ago already here: ROCm/HIP#2678
The fix even got into the master already.

@emollier
Copy link
Author

Hi Jacek,

Thanks for the status and the pointers to the implementations of the fix! Sorry I haven't searched cross repositories. If this is addressed, then I suppose the present issue can be closed.

Have a nice day, :)
Étienne.

@JacekJagosz
Copy link

I really think issue reporting, and release notes are a big mess, you need to search multiple repositories and even websites that should all be there for each repo.

@Oblomov
Copy link

Oblomov commented Jul 27, 2022

As a workaround for people stuck with older versions of the stack, it's possible to wrap the inclusion of system headers with a fence:

#ifdef __noinline__
#define GCC12_RESTORE_NOINLINE
#undef __noinline__
#endif

before including the system headers, followed by

#ifdef GCC12_RESTORE_NOINLINE
#undef GCC12_RESTORE_NOINLINE
#define __noinline__ __attribute__((noinline))
#endif

after.

This only actually needed around headers that end up including the system header shared_ptr_base.h.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants