CoatiSoftware / Sourcetrail

Sourcetrail - free and open-source interactive source explorer
https://www.sourcetrail.com/
GNU General Public License v3.0
14.29k stars 1.33k forks source link

Apple Silicon support #1185

Open jviotti opened 3 years ago

jviotti commented 3 years ago

Hey there! Are there plans to provide Apple Silicon Sourcetrail builds at any point soon?

jviotti commented 3 years ago

The tip of master fails at this inline assembly point:

In file included from /Users/jviotti/Projects/playground/Sourcetrail/src/test/test_main.cpp:3:
/Users/jviotti/Projects/playground/Sourcetrail/src/external/catch/catch.hpp:5767:13: error: unrecognized instruction mnemonic, did you mean: bit, cnt, hint, ins, not?
            CATCH_BREAK_INTO_DEBUGGER();
            ^
/Users/jviotti/Projects/playground/Sourcetrail/src/external/catch/catch.hpp:5485:75: note: expanded from macro 'CATCH_BREAK_INTO_DEBUGGER'
    #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }
                                                                          ^
/Users/jviotti/Projects/playground/Sourcetrail/src/external/catch/catch.hpp:5464:34: note: expanded from macro 'CATCH_TRAP'
    #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
                                 ^
<inline asm>:1:2: note: instantiated into assembly here
        int $3
        ^
1 error generated.
make[2]: *** [CMakeFiles/Sourcetrail_test.dir/src/test/test_main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Sourcetrail_test.dir/all] Error 2
make: *** [all] Error 2
jviotti commented 3 years ago

Looks like this was already fixed by Catch2 upstream: https://github.com/catchorg/Catch2/commit/a25c1a24af8bffd35727a888a307ff0280cf9387

jviotti commented 3 years ago

Not sure how the project is managing its vendored dependencies, but the build works with this patch:

diff --git a/src/external/catch/catch.hpp b/src/external/catch/catch.hpp
index 099119d4..7eece27d 100644
--- a/src/external/catch/catch.hpp
+++ b/src/external/catch/catch.hpp
@@ -5461,7 +5461,11 @@ namespace Catch {

 #ifdef CATCH_PLATFORM_MAC

-    #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
+    #if defined(__i386__) || defined(__x86_64__)
+        #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
+    #elif defined(__aarch64__)
+        #define CATCH_TRAP()  __asm__(".inst 0xd4200000")
+    #endif

 #elif defined(CATCH_PLATFORM_LINUX)
     // If we can use inline assembler, do it because this allows us to break

The app then opens up fine, but it looks like there is something weird with the colors and the UI?

Screen Shot 2021-06-10 at 17 43 26