aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
276 stars 60 forks source link

Compilation fails on aarch64 platforms #41

Closed netthier closed 2 years ago

netthier commented 2 years ago

When attempting to compile Aseprite, compilation fails due to the following error:

FAILED: laf/base/CMakeFiles/laf-base.dir/platform.cpp.o 
/usr/bin/c++ -DCMARK_STATIC_DEFINE -DHAVE_CONFIG_H -DLAF_LINUX -DLAF_SKIA -DNDEBUG -DPNG_NO_MMX_CODE -I/home/lmt/Stuff/aseprite/third_party/zlib -I/home/lmt/Stuff/aseprite/build/third_party/zlib -I/home/lmt/Stuff/aseprite/third_party/libpng -I/home/lmt/Stuff/aseprite/build/third_party/libpng -I/home/lmt/Stuff/aseprite/third_party/libwebp/src -I/home/lmt/Stuff/aseprite/third_party/tinyxml -I/home/lmt/Stuff/aseprite/third_party/pixman/pixman -I/home/lmt/Stuff/aseprite/build -I/home/lmt/Stuff/aseprite/third_party/giflib -I/home/lmt/Stuff/aseprite/third_party/jpeg -I/home/lmt/Stuff/aseprite/third_party/curl/include -I/home/lmt/Stuff/aseprite/third_party/simpleini -I/home/lmt/Stuff/aseprite/laf -I/home/lmt/Stuff/aseprite/build/laf -I/home/lmt/Stuff/aseprite/src -I/home/lmt/Stuff/aseprite/laf/third_party/stringencoders/src -O2 -g -DNDEBUG -std=c++14 -MD -MT laf/base/CMakeFiles/laf-base.dir/platform.cpp.o -MF laf/base/CMakeFiles/laf-base.dir/platform.cpp.o.d -o laf/base/CMakeFiles/laf-base.dir/platform.cpp.o -c /home/lmt/Stuff/aseprite/laf/base/platform.cpp
In file included from /home/lmt/Stuff/aseprite/laf/base/platform.cpp:11:
/home/lmt/Stuff/aseprite/laf/base/platform.h:56:59: error: static assertion failed: Invalid identification of CPU architecture
   56 |   static_assert((arch == Arch::x86 && sizeof(void*) == 4) ||
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
   57 |                 ((arch == Arch::x64 ||
      |                 ~~~~~~~~~~~~~~~~~~~~~~                     
   58 |                   arch == Arch::arm64) && sizeof(void*) == 8),
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[600/1554] Building CXX object laf/base/CMakeFiles/laf-base.dir/program_options.cpp.o
ninja: build stopped: subcommand failed.

If I were to guess, this is due to my system reporting aarch64 instead of arm64.

% uname -m
aarch64

My OS is Arch Linux ARM running on the Pinebook Pro.

dacap commented 2 years ago

Hi @netthier, sorry about this. Actually the code to detect the arm64/aarch64 chip is for Apple M1 chip. We are not compiling Aseprite for Linux arm64 so probably it will need some adjustments.

netthier commented 2 years ago

Older versions of Aseprite compiled fine on aarch64. I don't really have the time to check which tag exactly introduced this breakage. Since aarch64 Linux doesn't seem to need any extra workarounds, is restoring this support planned?

EDIT: Checking my messages in your Discord server, it seems I was able to compile the latest beta on September 29th 2021.

tma02 commented 2 years ago

@netthier if you just need to get it to build for yourself, you could probably modify platform.h to force arm64, although I'm not sure what the downstream side effects would be.

ArcaneNibble commented 2 years ago

This happens because only Apple platforms define __arm64__. Linux gcc defines __aarch64__ instead. I worked around the issue with the following patch

diff -ur aseprite-orig/laf/base/platform.h aseprite/laf/base/platform.h
--- aseprite-orig/laf/base/platform.h   2022-03-18 03:49:25.129299822 -0700
+++ aseprite/laf/base/platform.h    2022-03-18 03:50:19.533186579 -0700
@@ -44,7 +44,7 @@
      ;

   static constexpr Arch arch =
-#if __arm64__
+#if __arm64__ || defined(__aarch64__)
     Arch::arm64
 #elif defined(__x86_64__) || defined(_WIN64)
     Arch::x64
dacap commented 2 years ago

Just merged a patch for this issue :+1: thanks @rqou