CopperSpice on arm target

Discuss issues related to installing or building
Post Reply
john
Posts: 2
Joined: Fri Oct 09 2020 6:48 am

CopperSpice on arm target

Post by john »

Hi,
This project is really awesome, great job everyone and thank you for all your efforts.

I'm trying to make my qt app run on my ARM target device, but using copperspice instead of qt.

So far I've noted ARM isn't yet an officially supported target, and I've worked around that by changing src/core/global/qglobal.h to #define Q_PROCESSOR_ARM instead of bailing out with an error.

What are your thoughts on this endeavor? Is ARM something you would eventually like to support or are there any major obstacles that could make it not worth while?

I guess I'm just looking for a general discussion before spending too much time on something that you've already deemed pointless.

Thanks again.
barbara
Posts: 447
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: CopperSpice on arm target

Post by barbara »

Thank you so much for your interest in CopperSpice. We are absolutely interested in supporting ARM processors and would greatly appreciate working with you to ensure this happens. Please let us know what you have found or where you might need some assistance. The team will do our very best to help out. Pull requests are more than welcome.

Can you let us know what target hardware you are using and any other relevant information.

We look forward to working with you.

Barbara
john
Posts: 2
Joined: Fri Oct 09 2020 6:48 am

Re: CopperSpice on arm target

Post by john »

My target is something that resembles a raspberry pi in that it has an arm cpu, and a gpu that's GLESv2 capable.
I will later try to make copperspice render to a framebuffer device, but for now my experiments is focused around making CsCore build.

The most important change would be to add the Q_PROCESSOR_ARM:

Code: Select all

diff --git a/src/core/global/qglobal.h b/src/core/global/qglobal.h
index 2842c30c5..f1931c03c 100755
--- a/src/core/global/qglobal.h
+++ b/src/core/global/qglobal.h
@@ -84,6 +84,8 @@
 
 #  endif
 
+#elif defined(__ARM_ARCH)
+#  define Q_PROCESSOR_ARM
 #else
 #error Unable to detect system architecture, contact CopperSpice development
 
Then there's a couple of small things for cscore:
copperspice/src/core/string/qstring8.cpp:657:29: error: conversion from ‘wchar_t’ to ‘QChar32’ is ambiguous
Same goes for qstring16.cpp:658.
I'm not too familiar with wchar_t, but it seems it's not the same size as char16_t on arm, so likely 4 bytes. Perhaps one could use the gcc define __ARM_SIZEOF_WCHAR_T?

Not sure if this one is a good idea:

Code: Select all

diff --git a/src/core/string/qstring8.cpp b/src/core/string/qstring8.cpp
index 4fd4b5266..1acc201a9 100644
--- a/src/core/string/qstring8.cpp
+++ b/src/core/string/qstring8.cpp
@@ -654,7 +654,7 @@ QString8 QString8::fromStdWString(const std::wstring &str, size_type numOfChars)
             break;
          }
 
-         retval.push_back(ch);
+         retval.push_back(static_cast<char32_t>(ch));
          --numOfChars;
       }
    }
I was able to set up cmake to only build CsCore, and then I went on to add CsGui and opengl. cmake then tried to build the rcc tool, but that one had a dependency on XML, so I had to add that too in order to make it move on to building CsGui.

To complicate matters even more, I eventually have to builds copperspice with openembedded, and I haven't quite nailed putting together a working recipe file there yet.
michkrom
Posts: 4
Joined: Sat Apr 17 2021 6:28 pm

Re: CopperSpice on arm target

Post by michkrom »

Just trying to build Cs on raspberry pi (Pi4 8GB). Looks like the build system does not like it much ;-)

[1/3890] Building CXX object src/core/CMakeFiles/CsCore.dir/animation/qpropertyanimation.cpp.o
FAILED: src/core/CMakeFiles/CsCore.dir/animation/qpropertyanimation.cpp.o
/usr/bin/c++ @src/core/CMakeFiles/CsCore.dir/animation/qpropertyanimation.cpp.o.rsp -MD -MT src/core/CMakeFiles/CsCore.dir/animation/qpropertyanimation.cpp.o -MF src/core/CMakeFiles/CsCore.dir/animation/qpropertyanimation.cpp.o.d -o src/core/CMakeFiles/CsCore.dir/animation/qpropertyanimation.cpp.o -c ../src/core/animation/qpropertyanimation.cpp
In file included from ../src/core/kernel/csobject_macro.h:29,
from ../src/core/kernel/qobject.h:27,
from ../src/core/animation/qabstractanimation.h:27,
from ../src/core/animation/qvariantanimation.h:27,
from ../src/core/animation/qpropertyanimation.h:27,
from ../src/core/animation/qpropertyanimation.cpp:24:
../src/core/global/qglobal.h:90:2: error: #error Unable to detect system architecture, contact CopperSpice development
90 | #error Unable to detect system architecture, contact CopperSpice development
michkrom
Posts: 4
Joined: Sat Apr 17 2021 6:28 pm

Re: CopperSpice on arm target

Post by michkrom »

This modification moved it forward

Code: Select all

diff --git a/src/core/global/qglobal.h b/src/core/global/qglobal.h
index 3e576b0..ba602e0 100755
--- a/src/core/global/qglobal.h
+++ b/src/core/global/qglobal.h
@@ -85,7 +85,8 @@
 #    define Q_PROCESSOR_X86     3

 #  endif
-
+#elif defined(__ARM_ARCH)
+#    define Q_PROCESSOR_ARM 1
 #else
 #error Unable to detect system architecture, contact CopperSpice development
But now getting

Code: Select all

[138/3874] Building CXX object src/core/CMakeFiles/CsCore.dir/string/qstring8.cpp.o
FAILED: src/core/CMakeFiles/CsCore.dir/string/qstring8.cpp.o
/usr/bin/c++ @src/core/CMakeFiles/CsCore.dir/string/qstring8.cpp.o.rsp -MD -MT src/core/CMakeFiles/CsCore.dir/string/qstring8.cpp.o -MF src/core/CMakeFiles/CsCore.dir/string/qstring8.cpp.o.d -o src/core/CMakeFiles/CsCore.dir/string/qstring8.cpp.o -c ../src/core/string/qstring8.cpp
../src/core/string/qstring8.cpp: In static member function ‘static QString8 QString8::fromStdWString(const wstring&, QString8::size_type)’:
../src/core/string/qstring8.cpp:648:29: error: conversion from ‘wchar_t’ to ‘QChar32’ is ambiguous
  648 |          retval.push_back(ch);
      |                             ^
In file included from include/QtCore/qstring8.h:33,
                 from ../src/core/string/qstring8.cpp:26:
include/QtCore/qchar32.h:378:7: note: candidate: ‘QChar32::QChar32(int)’
  378 |       QChar32(int c)
      |       ^~~~~~~
include/QtCore/qchar32.h:374:7: note: candidate: ‘QChar32::QChar32(char16_t)’
  374 |       QChar32(char16_t c)
      |       ^~~~~~~
include/QtCore/qchar32.h:370:7: note: candidate: ‘QChar32::QChar32(char32_t)’
  370 |       QChar32(char32_t c)
      |       ^~~~~~~
In file included from ../src/core/string/qstring8.cpp:26:
include/QtCore/qstring8.h:661:30: note:   initializing argument 1 of ‘void QString8::push_back(QChar32)’
  661 |       void push_back(QChar32 c) {
      |                      ~~~~~~~~^
michkrom
Posts: 4
Joined: Sat Apr 17 2021 6:28 pm

Re: CopperSpice on arm target

Post by michkrom »

Apparently, wchar_t is 4 bytes by default on ARM64 and likely Cs was never complied as such.

I could:

1) patch it in qstring8 to directly cast to (char32_t)ch (or even to char16_t)
2) make explicit constructor QChar32(wchar_t)
3) change the default size of wchar_t via compile option -fshort-wchar

Any preferences?
barbara
Posts: 447
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: CopperSpice on arm target

Post by barbara »

Just trying to build Cs on raspberry pi (Pi4 8GB). Looks like the build system does not like it much
As per our CS Overview Documentation, raspberry pi is not currently a supported platform. The following is a link to the list of what we support and test in our CI.

https://www.copperspice.com/docs/cs_overview/supported-platforms.html

I know this is a bit odd to say, but we have nothing against raspberry pi and this is not about the build system not liking a particular platform. If this is a platform you or anyone would like supported please supply the necessary suggested changes and we will add this to our road map.
ansel
Posts: 152
Joined: Fri Apr 10 2015 8:23 am

Re: CopperSpice on arm target

Post by ansel »

michkrom wrote: Sat Apr 17 2021 9:30 pm This modification moved it forward

Code: Select all

...
#elif defined(__ARM_ARCH)
#    define Q_PROCESSOR_ARM 1
...
Thanks for looking at this and proposing a solution. The code you added assumes there is only one version of ARM, whereas there are many variants and they will all have to be accounted for. Based on the hardware you said you are using, it is very likely you are running a 32-bit version of Linux. However, that is a guess at this point. Setting up a new platform requires changing multiple items and setting up more than simply the processor detection. You will need to review everything in the global folder to see what may need to be adjusted.
michkrom wrote: Sat Apr 17 2021 10:41 pm Apparently, wchar_t is 4 bytes by default on ARM64 and likely Cs was never complied as such.
...
The wchar_t data type is 4 bytes on all Linux platforms, including ARM32, ARM64, and x86_64. I develop primarily on Debian x86_64, and wchar_t is 4 bytes on this machine so yes, we have tested this. Not sure why you are seeing different results on your build. Did you make any other changes we are not aware of?

Can you provide the following information about your build environment?
  1. Compiler and version
  2. OS Image being used
  3. 32-bit LPAE or 64-bit kernel
  4. 32-bit or 64-bit userspace
  5. Exact CMake command line
Ansel Sermersheim
CopperSpice Cofounder
Post Reply