Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between BOOST_NOINLINE and HIP compiler #392

Closed
markdewing opened this issue Aug 6, 2021 · 6 comments · Fixed by #393
Closed

Conflict between BOOST_NOINLINE and HIP compiler #392

markdewing opened this issue Aug 6, 2021 · 6 comments · Fixed by #393

Comments

@markdewing
Copy link

The hipcc compiler (tested on rocm 4.3) defines __noinline__ as __atribute__((noinline)) (in /opt/rocm-4.3.0/hip/include/hip/amd_detail/host_defines.h)
This definition mixes with the boost definition to create an incorrect __attribute__ statement
Shows up when including stacktrace.hpp

Reproducer

// Workaround
//#define BOOST_NOINLINE __attribute__((noinline))__

#define BOOST_STACKTRACE_USE_BACKTRACE
#include <stacktrace.hpp>

#include <hip/hip_runtime.h>

int main()
{
    return 0;
}

BOOST_NOINLINE void stuff()
{
    int i = 1;
}

Compile with hipcc and get the following output

boost_test.cpp:13:1: error: use of undeclared identifier 'noinline'; did you mean 'inline'?
BOOST_NOINLINE void stuff()
^
/usr/include/boost/config/detail/suffix.hpp:623:46: note: expanded from macro 'BOOST_NOINLINE'
#      define BOOST_NOINLINE __attribute__ ((__noinline__))
                                             ^
/opt/rocm-4.3.0/hip/include/hip/amd_detail/host_defines.h:50:37: note: expanded from macro '__noinline__'
#define __noinline__ __attribute__((noinline))
                                    ^
boost_test.cpp:13:1: error: type name does not allow function specifier to be specified
/usr/include/boost/config/detail/suffix.hpp:623:46: note: expanded from macro 'BOOST_NOINLINE'
#      define BOOST_NOINLINE __attribute__ ((__noinline__))
                                             ^
/opt/rocm-4.3.0/hip/include/hip/amd_detail/host_defines.h:50:37: note: expanded from macro '__noinline__'
#define __noinline__ __attribute__((noinline))
                                    ^
boost_test.cpp:13:1: error: expected expression
/usr/include/boost/config/detail/suffix.hpp:623:46: note: expanded from macro 'BOOST_NOINLINE'
#      define BOOST_NOINLINE __attribute__ ((__noinline__))
                                             ^
/opt/rocm-4.3.0/hip/include/hip/amd_detail/host_defines.h:50:46: note: expanded from macro '__noinline__'
#define __noinline__ __attribute__((noinline))
                                             ^
3 errors generated when compiling for gfx900.

The fix in boost is likely to be a check similar to the check for __CUDACC__ already in the BOOST_NOINLINE definition. I don't know the correct preprocessor symbol to use for checking for HIP compilation.

@jzmaddock
Copy link
Collaborator

Can you please verify that #393 fixes this for you?

@markdewing
Copy link
Author

Yes, #393 fixes this issue for me.

fwyzard pushed a commit to cms-patatrack/pixeltrack-standalone that referenced this issue Aug 13, 2021
See boostorg/config#392 for the bug report and discussion, and boostorg/config#393 for the upstream fix.
sstsai added a commit to sstsai/sonda that referenced this issue Dec 15, 2021
e108255ff Merge branch 'develop'
fc4e48a91 Merge pull request #411 from boostorg/msvc_2022
0c21be040 Correct two phase lookup config for msvc-14.3.
77df5deb6 Configuration update for msvc-2022.
ad40eb581 Merge pull request #410 from sdarwin/meta
e12a9c522 Update metadata
0b62f7d5a Merge branch 'develop'
037a9b4d2 Merge pull request #409 from boostorg/vs2022_ci
1aa177da0 Change VS cxxstd=20 to cxxstd=latest
64bf41929 Add Visual Studio 2022 runner.
57f06834e Merge pull request #405 from ohhmm/develop
528db2c58 Merge pull request #408 from boostorg/atomic_macros
7cc7f9400 Update for present, but broken <concepts> on latest MacOS clang.
35c4a13e6 Print out <atomic> macros.
b12d44fc7 Disable __int128 on CUDA device code.
1e5f50939 Add first nvcc github action. (#407)
2fdfd43e2 Fix for clang CUDA generation, fixes boostorg/config#297
f34bcff86 Add VC143 toolset
8f05b6457 Merge branch 'develop'
85292621e Add emscripten testing and support. (#403)
0d95a7405 Merge pull request #398 from boostorg/issue336
163599973 Update nodiscard attribute: It's not supported on functions pre-c++11 even if __has_cpp_attribute indicates it is supported. Also update test case. Fixes boostorg/config#336.
fac8ba93c Merge pull request #397 from boostorg/codecvt
88866861d MSVC update that handled deprecation of <codecvt> and availability of <stop_token>. See also boostorg/config#391.
f1b2746fb Merge pull request #395 from boostorg/mclow-patch-3
8df65862c Fix typo
01f00de73 Bump version to 1.78.0
47614564e Merge pull request #393 from boostorg/issue392
76d4eaf4b Patch for noinline attribute on the HIP compiler. Fixes boostorg/config#392.
c3de80c2e Merge pull request #387 from boostorg/issue382
a8bdf6ae2 Merge pull request #388 from boostorg/gcc4-4-fixes
42cff9687 Try and fix gcc-4.4 -fno-rtti failure.
73557f776 Correct boost_no_ctype_functions.ipp for C++20. See boostorg/config#382.
cfc6545ce Merge pull request #385 from boostorg/pr/boost-clang-version
eb3a0a98a Merge pull request #380 from xantares/mingw_tls
b80c25f47 Print __apple_build_version__ in config_info
8595667b3 Fix spelling of __APPLE__
a5b2dbdcf Merge pull request #384 from boostorg/pr/detail-workaround-guard
f1b4a51ce Merge pull request #383 from boostorg/pr/clang-major-workaround
098ca4a3c Document BOOST_CLANG_VERSION
0148ea5ea Print BOOST_CLANG, BOOST_CLANG_VERSION in config_info
1e63c7729 Define BOOST_CLANG_VERSION_WORKAROUND_GUARD
f6fdfb929 Define BOOST_CLANG_VERSION
e52aa5865 Update detail/workaround.hpp include guard
9e8099384 Define __clang_major___WORKAROUND_GUARD
98c3ac815 Allow thread_local on mingw with gcc>=11

git-subtree-dir: extern/boost/config
git-subtree-split: e108255ffb5d2557ed3398b3fc575a2e9fd434cc
@atamazov
Copy link

@markdewing

I don't know the correct preprocessor symbol to use for checking for HIP compilation.

Please look at https://github.com/ROCm-Developer-Tools/HIP/blob/develop/docs/markdown/hip_porting_guide.md#compiler-defines-summary. __HIP__ is defined for HIP-Clang only and should work fine in this case.

@atamazov
Copy link

atamazov commented Apr 26, 2022

@jzmaddock @markdewing HIP_VERSION is not defined in the HIP-clang but defined in HIP headers. Therefore the usage of HIP_VERSION creates dependence on the order of inclusion of BOOST and HIP headers (for example, please see ROCm/MIOpen#1490 (comment)). I highly recommend reopening the issue and re-implementing the fix (please see previous comment for advice).

@jzmaddock
Copy link
Collaborator

So is simply changing HIP_VERSION to __HIP__ the correct fix?

@atamazov
Copy link

@jzmaddock Yes. If there is any doubt, then I think we can ask @markdewing to check if this works ;)

jzmaddock added a commit that referenced this issue Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants