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

Build issue with LLVM 18.1.1 on msys2 #39

Closed
1 task done
rtiangha opened this issue Mar 21, 2024 · 5 comments · Fixed by #41
Closed
1 task done

Build issue with LLVM 18.1.1 on msys2 #39

rtiangha opened this issue Mar 21, 2024 · 5 comments · Fixed by #41

Comments

@rtiangha
Copy link
Contributor

rtiangha commented Mar 21, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Affected Build(s)

HEAD

Description of Issue

Building Citra with Clang 18.1.1 on msys2 now yields this error:

In file included from C:/msys64/home/Default/github/bravely-offline-citra/src/citra_qt/util/graphics_device_info.cpp:5:
In file included from C:/msys64/home/Default/github/bravely-offline-citra/src/./citra_qt/util/graphics_device_info.h:8:
In file included from C:/msys64/clang64/include/qt6/QtCore/QString:1:
In file included from C:/msys64/clang64/include/qt6/QtCore/qstring.h:14:
In file included from C:/msys64/clang64/include/qt6/QtCore/qchar.h:656:
In file included from C:/msys64/clang64/include/qt6/QtCore/qstringview.h:8:
In file included from C:/msys64/clang64/include/qt6/QtCore/qbytearray.h:14:
C:/msys64/clang64/include/qt6/QtCore/qbytearrayview.h:69:27: error: 'char_traits<unsigned char>' is deprecated: char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t i
s non-standard and is provided for a temporary period. It will be removed in LLVM 19, so please migrate off of it. [-Werror,-Wdeprecated-declarations]
   69 |     return qsizetype(std::char_traits<Char>::length(data));
      |                           ^
C:/msys64/clang64/include/qt6/QtCore/qbytearrayview.h:151:39: note: in instantiation of function template specialization 'QtPrivate::lengthHelperPointer<unsigned char>' requested here
  151 |               data, data ? QtPrivate::lengthHelperPointer(data) : 0) {}
      |                                       ^
C:/msys64/home/Default/github/bravely-offline-citra/src/citra_qt/util/graphics_device_info.cpp:25:34: note: in instantiation of function template specialization 'QByteArrayView::QByteArrayView
<const unsigned char *, true>' requested here
   25 |         return QString::fromUtf8(context.functions()->glGetString(GL_RENDERER));
      |                                  ^
C:/msys64/clang64/include/c++/v1/__string/char_traits.h:81:8: note: 'char_traits<unsigned char>' has been explicitly marked deprecated here
   81 | struct _LIBCPP_DEPRECATED_(
      |        ^
C:/msys64/clang64/include/c++/v1/__config:975:53: note: expanded from macro '_LIBCPP_DEPRECATED_'
  975 | #      define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
      |                                                     ^
1 error generated.
ninja: build stopped: subcommand failed.

And the compiler seems to now be enforcing this deprecation.

I'm not a strong coder, but I was able to get something that compiled with the assistance of Copilot AI, but it breaks Vulkan (so more investigation needed, but I get better performance on OpenGL on this set up anyway so I can live with it).

That said, as far as I can tell, at least these files need to be modified:

src/citra_qt/main.cpp
src/citra_qt/util/graphics_device_info.cpp
src/citra_qt/util/graphics_device_info.h

to rework the QString stuff. I'm not very familiar with the code to know if there are other places as well.

Expected Behavior

Successful compilation.

Reproduction Steps

Build Citra with Clang 18.1.1 (on msys2, but maybe on other OSes as well).

Log File

No logs; this is a compile issue.

System Configuration

CPU: Intel Kaby Lake
GPU/Driver: Integrated Intel HD Graphics 620
RAM: 8GB
OS: Windows 10 64-bit

@Miguel-hrvs
Copy link
Contributor

These guys had the same problem: jtv/libpqxx#738

@Miguel-hrvs
Copy link
Contributor

Miguel-hrvs commented Mar 21, 2024

You could try modifying the C:/msys64/clang64/include/qt6/QtCore/qbytearrayview.h file this way:
replace the line 69 with this: return qsizetype(uchar_traits::length(reinterpret_cast<const char*>(data)));
And include this before template typename Char:

struct uchar_traits : std::char_traits {
static void assign(char& r, const char& a) {
r = a;
}

static bool eq(const char& c1, const char& c2) {
    return c1 == c2;
}

static bool lt(const char& c1, const char& c2) {
    return c1 < c2;
}

static int compare(const char* s1, const char* s2, size_t n) {
    while (n-- != 0) {
        if (*s1 < *s2) return -1;
        if (*s1 > *s2) return 1;
        ++s1; ++s2;
    }
    return 0;
}

static const char* find(const char* s, int n, const char& a) {
    auto const ua(a);
    while (n-- != 0) {
        if (*s == ua) return s;
        s++;
    }
    return nullptr;
}

static char* move(char* s1, const char* s2, int n) {
    return (char*)memmove(s1, s2, n);
}

static char* copy(char* s1, const char* s2, int n) {
    return (char*)memcpy(s1, s2, n);
}

static char* assign(char* s, int n, char a) {
    return (char*)memset(s, a, n);
}

static char to_char_type(const char& c) {
    return c;
}

static char to_int_type(const char& c) {
    return c;
}

static bool eq_int_type(const char& c1, const char& c2) {
    return c1 == c2;
}

static char eof() {
    return EOF;
}

static char not_eof(const char& c) {
    return !(eq_int_type(c, eof())) ? c : 0;
}

};

Here's my modified file:
qbytearrayview.h.zip

@Miguel-hrvs
Copy link
Contributor

Miguel-hrvs commented Mar 21, 2024

It compiled but gave me an error at loading

@rtiangha
Copy link
Contributor Author

rtiangha commented Mar 21, 2024

OK, I gave Copilot AI another chance and reworked my request. It suggested replacing line 25 in src/citra_qt/util/graphics_device_info.cpp which is this:

return QString::fromUtf8(context.functions()->glGetString(GL_RENDERER));

with this:

return QString::fromUtf8(reinterpret_cast<const char*>(context.functions()->glGetString(GL_RENDERER)));

I tried it; it compiles and games seem to work in both OpenGL and Vulkan. Not sure if I trust it though, so hopefully someone stronger with C++ can either verify or write something that's correct.

@Miguel-hrvs
Copy link
Contributor

Miguel-hrvs commented Mar 21, 2024

My problem was using old dll libraries. Both methods seem to work. Good work, we need more people like you trying to improve the emu, this repo feels a little alone.

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

Successfully merging a pull request may close this issue.

2 participants