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

XRT uses rapidjson-dev which does not compile on Ubuntu 24.04 #8139

Open
keryell opened this issue May 3, 2024 · 0 comments
Open

XRT uses rapidjson-dev which does not compile on Ubuntu 24.04 #8139

keryell opened this issue May 3, 2024 · 0 comments

Comments

@keryell
Copy link
Member

keryell commented May 3, 2024

XRT uses https://github.com/Tencent/rapidjson to parse JSON files but this is an archaic C++ which is mostly unchanged since 2016.
Compiling XRT leads to

In file included from /home/rkeryell/Xilinx/Projects/AIE/xdna-driver/xrt/src/runtime_src/tools/xclbinutil/RapidJsonUtilities.h:24,
                 from /home/rkeryell/Xilinx/Projects/AIE/xdna-driver/xrt/src/runtime_src/tools/xclbinutil/RapidJsonUtilities.cxx:20:
/usr/include/rapidjson/document.h: In member function ‘rapidjson::GenericStringRef<CharType>& rapidjson::GenericStringRef<CharType>::operator=(const rapidjson::GenericStringRef<CharType>&)’:
/usr/include/rapidjson/document.h:319:82: error: assignment of read-only member ‘rapidjson::GenericStringRef<CharType>::length’
  319 |     GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
      |           

which is actually Tencent/rapidjson#718 which was opened and solved in... 2016!
For some reasons Ubuntu/Debian distributes a version from 2016 from before this patch plus some Debian-specific changes.

I can see a few solutions by order of decreasing quality:

  • get rid of this obsolete library and move to a modern library as there are many of them shipped in Linux distributions;
  • ship the fixed file with XRT if the license allows it or use something like CMake/FetchContent to install our own;
  • get the library updated on Debian/Ubuntu, but it will take some time;
  • patch the library by commenting line 319 of /usr/include/rapidjson/document.h as
//    GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }

(which is what I did to have XRT running on my laptop because I am lazy).

Some background information:
https://github.com/Tencent/rapidjson
https://packages.ubuntu.com/noble/rapidjson-dev
https://packages.debian.org/sid/rapidjson-dev

In the following the members are const so obviously there cannot be an assignment operator...

template<typename CharType>
struct GenericStringRef {
    GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
    const Ch* const s; //!< plain CharType pointer
    const SizeType length; //!< length of the string (excluding the trailing NULL terminator)
@keryell keryell changed the title XRT uses rapidjson which does not compile on Ubuntu 24.04 XRT uses rapidjson-dev which does not compile on Ubuntu 24.04 May 3, 2024
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

1 participant