Copper Spice on M1 Mac

Post Reply
hhenson
Posts: 6
Joined: Fri May 28 2021 11:33 am

Copper Spice on M1 Mac

Post by hhenson »

Hi,

Was trying to compile copper spice on my M1 Mac. Got the following error:
copperspice/src/core/global/qglobal.h:90:2: error: Unable to detect system architecture, contact CopperSpice development
#error Unable to detect system architecture, contact CopperSpice development

Seems this part of the code only support dealing with Intel based processors failing if it can't find one. I see other parts of the code seem to imply that copper spice is supported on IOS so I imagine there should be a mechanism to make this work correctly on an M1 Mac.

Is there a chance of a simple fix to get this working? Not super familiar with this code base, but am willing to act as a guinea pig if that would help.

Howard

ansel
Posts: 113
Joined: Fri Apr 10 2015 8:23 am

Re: Copper Spice on M1 Mac

Post by ansel »

Thank you for your interest in CopperSpice. We appreciate your willingness to test this, it will benefit the project.

As a first step, I would recommend you insert the following block before the #else in src/core/global/qglobal.h around line 89.

Code: Select all

#elif 1
#define Q_PROCESSOR_ARM 8
This will add a fallback to assume any unknown CPU conforms to the ARM v8 instruction set. Let us know what you discover with this change in place.
Ansel Sermersheim
CopperSpice Cofounder

hhenson
Posts: 6
Joined: Fri May 28 2021 11:33 am

Re: Copper Spice on M1 Mac

Post by hhenson »

OK, so the new define helps getting the compile started, but now I have the following error:

FAILED: src/gui/CMakeFiles/CsGui.dir/painting/qdrawhelper.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ @src/gui/CMakeFiles/CsGui.dir/painting/qdrawhelper.cpp.o.rsp -MD -MT src/gui/CMakeFiles/CsGui.dir/painting/qdrawhelper.cpp.o -MF src/gui/CMakeFiles/CsGui.dir/painting/qdrawhelper.cpp.o.d -o src/gui/CMakeFiles/CsGui.dir/painting/qdrawhelper.cpp.o -c ../src/gui/painting/qdrawhelper.cpp
../src/gui/painting/qdrawhelper.cpp:6942:65: error: use of undeclared identifier 'qt_blend_rgb32_on_rgb32_neon'
blendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6943:80: error: use of undeclared identifier 'qt_blend_rgb32_on_rgb32_neon'
blendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6944:80: error: use of undeclared identifier 'qt_blend_argb32_on_argb32_neon'
blendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6945:95: error: use of undeclared identifier 'qt_blend_argb32_on_argb32_neon'
blendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6948:71: error: use of undeclared identifier 'qt_blend_rgb32_on_rgb32_neon'
blendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6949:85: error: use of undeclared identifier 'qt_blend_rgb32_on_rgb32_neon'
blendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6950:85: error: use of undeclared identifier 'qt_blend_argb32_on_argb32_neon'
blendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6951:99: error: use of undeclared identifier 'qt_blend_argb32_on_argb32_neon'
blendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon;
^
../src/gui/painting/qdrawhelper.cpp:6954:65: error: use of undeclared identifier 'qt_blend_argb32_on_argb32_scanline_neon'
qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = qt_blend_argb32_on_argb32_scanline_neon;
^
../src/gui/painting/qdrawhelper.cpp:6955:70: error: use of undeclared identifier 'comp_func_solid_SourceOver_neon'
qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_neon;
^
../src/gui/painting/qdrawhelper.cpp:6956:59: error: use of undeclared identifier 'comp_func_Plus_neon'
qt_functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_neon;

hhenson
Posts: 6
Joined: Fri May 28 2021 11:33 am

Re: Copper Spice on M1 Mac

Post by hhenson »

After a bit of investigation, I discovered that the file:
src/gui/painting/qdrawhelper_neon_p.h:28. has #ifdef QT_HAVE_NEON

but that does not appear to be found anywhere else in the source code, so I have changed that to:
#ifdef __ARM_NEON__

That seems to have gotten the code to compile, but now I seem to be stuck linking:

Linking CXX shared library lib/libCsGui1.7.dylib
FAILED: lib/libCsGui1.7.dylib
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -dynamiclib -Wl,-headerpad_max_install_names -Wl,-undefined,error -framework AppKit -framework Carbon -framework OpenGL -o lib/libCsGui1.7.dylib -install_name @rpath/libCsGui1.7.dylib @CMakeFiles/CsGui.rsp && :
Undefined symbols for architecture arm64:
"qt_memfill32(unsigned int*, unsigned int, int)", referenced from:
QImage::fill(unsigned int) in qimage.cpp.o
comp_func_solid_Clear(unsigned int*, int, unsigned int, unsigned int) in qcompositionfunctions.cpp.o
comp_func_Clear(unsigned int*, unsigned int const*, int, unsigned int) in qcompositionfunctions.cpp.o
comp_func_solid_Source(unsigned int*, int, unsigned int, unsigned int) in qcompositionfunctions.cpp.o
comp_func_solid_SourceOver(unsigned int*, int, unsigned int, unsigned int) in qcompositionfunctions.cpp.o
rasterop_solid_NotSource(unsigned int*, int, unsigned int, unsigned int) in qcompositionfunctions.cpp.o
rasterop_ClearDestination(unsigned int*, unsigned int const*, int, unsigned int) in qcompositionfunctions.cpp.o
...
"comp_func_Plus_neon(unsigned int*, unsigned int const*, int, unsigned int)", referenced from:
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::instance() in qdrawhelper.cpp.o
"convert_RGB888_to_RGB32_neon(QImageData*, QImageData const*, QFlags<Qt::ImageConversionFlag>)", referenced from:
QImageConversions::QImageConversions() in qimage_conversions.cpp.o
QImageConversions::QImageConversions() in qimage_conversions.cpp.o
QImageConversions::instance() in qimage_conversions.cpp.o
"qt_blend_rgb32_on_rgb32_neon(unsigned char*, int, unsigned char const*, int, int, int, int)", referenced from:
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::instance() in qdrawhelper.cpp.o
"qt_fetch_radial_gradient_neon(unsigned int*, Operator const*, QSpanData const*, int, int, int)", referenced from:
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::instance() in qdrawhelper.cpp.o
"qt_blend_argb32_on_argb32_neon(unsigned char*, int, unsigned char const*, int, int, int, int)", referenced from:
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::instance() in qdrawhelper.cpp.o
"comp_func_solid_SourceOver_neon(unsigned int*, int, unsigned int, unsigned int)", referenced from:
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::instance() in qdrawhelper.cpp.o
"qt_convert_rgb888_to_rgb32_neon(unsigned int*, unsigned char const*, int)", referenced from:
QJpegHandler::QJpegHandler() in qjpeghandler.cpp.o
"qt_blend_argb32_on_argb32_scanline_neon(unsigned int*, unsigned int const*, int, unsigned int)", referenced from:
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::QDrawHelperFunctions() in qdrawhelper.cpp.o
QDrawHelperFunctions::instance() in qdrawhelper.cpp.o
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in pngrutil.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

hhenson
Posts: 6
Joined: Fri May 28 2021 11:33 am

Re: Copper Spice on M1 Mac

Post by hhenson »

Have been trying to chase the last errors down.

There are the changes I have needed to make so far:

The suggestion you made plus a bit more in qglobal.h:
# elif 1
#define Q_PROCESSOR_ARM 8
#define Q_PROCESSOR_ARM_64
#define QT_HAVE_NEON

in painting.cmake

${CMAKE_CURRENT_SOURCE_DIR}/painting/qdrawhelper_neon.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qdrawhelper_neon_asm.S

In image.cmake

${CMAKE_CURRENT_SOURCE_DIR}/image/qimage_neon.cpp

I have undone the change to the define I previously mentioned by adding the defines above.

I have now run into this now:
Linking CXX shared library lib/libCsGui1.7.dylib
FAILED: lib/libCsGui1.7.dylib
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -dynamiclib -Wl,-headerpad_max_install_names -Wl,-undefined,error -framework AppKit -framework Carbon -framework OpenGL -o lib/libCsGui1.7.dylib -install_name @rpath/libCsGui1.7.dylib @CMakeFiles/CsGui.rsp && :
Undefined symbols for architecture arm64:
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in pngrutil.c.o
ld: symbol(s) not found for architecture arm64

The problem looks similar to the ones before, but this is in a submodule.

hhenson
Posts: 6
Joined: Fri May 28 2021 11:33 am

Re: Copper Spice on M1 Mac

Post by hhenson »

Last change to image.cmake

${CMAKE_SOURCE_DIR}/src/3rdparty/libpng/arm/arm_init.c
${CMAKE_SOURCE_DIR}/src/3rdparty/libpng/arm/filter_neon.S
${CMAKE_SOURCE_DIR}/src/3rdparty/libpng/arm/filter_neon_intrinsics.c

This seems to let me compile the code.

barbara
Posts: 272
Joined: Sat Apr 04 2015 2:32 am

Re: Copper Spice on M1 Mac

Post by barbara »

Thanks for all your work.

We are looking at setting up something with a client to test building on an M1. These changes will help a lot.

Barbara

hhenson
Posts: 6
Joined: Fri May 28 2021 11:33 am

Re: Copper Spice on M1 Mac

Post by hhenson »

No problem, there is still one problem with the scripting (if I remember correctly) where it is not correctly picking out the fact that the processor is 64 bit and as such is trying to cast pointers to 32 bit handles. I have not had a chance to figure out where to correct this exactly. I may have some time on the weekend to try again.

Post Reply