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

[Issue]: ROCdbgapi-rocm-6.3.0 fails to compile with libc++ (>=LLVM-18) #18

Closed
AngryLoki opened this issue Dec 9, 2024 · 2 comments
Closed

Comments

@AngryLoki
Copy link

Problem Description

Hi,

This code fails to compile with clang >= 18 on libc++ systems:

ROCdbgapi/src/os_driver.cpp

Lines 998 to 1040 in defc3d5

class note_builder
{
public:
note_builder ()
: m_stream (std::stringstream::out | std::stringstream::binary)
{
}
template <typename T, std::enable_if_t<!std::is_pointer_v<T>, int> = 0>
void write (const T &v)
{
m_stream.write (reinterpret_cast<const std::byte *> (&v), sizeof (T));
}
void write (const std::vector<std::byte> &v)
{
m_stream.write (reinterpret_cast<const std::byte *> (v.data ()),
v.size ());
}
size_t size () const { return m_stream.str ().size (); }
amd_dbgapi_core_state_data_t note () const
{
amd_dbgapi_core_state_data_t note;
note.endianness
= (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ? AMD_DBGAPI_ENDIAN_LITTLE
: AMD_DBGAPI_ENDIAN_BIG);
auto str = m_stream.str ();
note.size = str.size ();
auto buffer = amd::dbgapi::allocate_memory<std::byte> (note.size);
std::copy (str.begin (), str.end (), buffer.get ());
note.data = buffer.release ();
return note;
}
private:
std::basic_ostringstream<std::byte> m_stream;
};
}; /* anonymous namespace. */

with

/usr/include/c++/v1/ios:561:20: error: implicit instantiation of undefined template 'std::char_traits<std::byte>'
  561 |   typedef typename traits_type::int_type int_type;
      |                    ^
/usr/include/c++/v1/__ostream/basic_ostream.h:40:59: note: in instantiation of template class 'std::basic_ios<std::byte>' requested here

The problem is that libc++ follows C++ standard and does not define std::char_traits<std::byte> (see jtv/libpqxx#726 for more discussions).

The problem can be fixed by replacing std::byte with char in this class everywhere (might be not the most beautiful solution, but it follows the standard).

Could you fix it please?

Operating System

Gentoo

CPU

GPU

ROCm Version

ROCm 6.3.0

ROCm Component

No response

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

@lancesix
Copy link
Collaborator

lancesix commented Dec 9, 2024

Hi @AngryLoki , Thanks for reporting that issue. I'll try to look at this shortly.

rocm-ci pushed a commit that referenced this issue Jan 8, 2025
It is not correct to use a std::basic_ostringstream<std::byte> since it
would require std::char_traits to be defined for std::byte.  Such trait
is not defined for std::byte.

This issue causes build problem when against libc++-18 or above, as it
does not provide an implementation for std::char_traits<std::byte>.

This patch proposes to not rely on basic_ostringstream, but instead a
plain vector of std::byte.

Bug: #18
Bug: SWDEV-503716
Change-Id: I3deb0273ffdc6ba9977a6c29f25e41c12ffa7c64
@lancesix
Copy link
Collaborator

lancesix commented Jan 9, 2025

Hi, that issue should have been fixed by a08fe3d. I expect this will become part of next major release.
Please let me know if you face more issues.

@lancesix lancesix closed this as completed Jan 9, 2025
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

No branches or pull requests

2 participants