Coirt / Bark

VCVrack Modules
Other
27 stars 4 forks source link

Plugin fails to compile on macOS arm64 platform #39

Open cschol opened 1 year ago

cschol commented 1 year ago

Lots of issues related to simde instructions:

_ARM64 -march=armv8-a+fp+simd -DARCH_MAC -mmacosx-version-min=10.9  -c -o build/src/QuadLogic.cpp.o src/QuadLogic.cpp                                      
In file included from src/PolyMix.cpp:3:                                                                                                                                                                                                                                                                               
In file included from src/dependancies/dsp/cpPan.h:2:                                                                                                      
In file included from src/dependancies/dsp/../utility/fasttrigo.h:46:                                                                                      
/home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/xmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"                                                                                                                                                    
#error "This header is only meant to be used on x86 and x64 architecture"
 ^                                                                                                                                                         
In file included from src/PolyMix.cpp:3:                                                                                                                   
In file included from src/dependancies/dsp/cpPan.h:2:          
In file included from src/dependancies/dsp/../utility/fasttrigo.h:46:                                                                                      
In file included from /home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/xmmintrin.h:17:                                              
/home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/mmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"                                                                                                                                                     
#error "This header is only meant to be used on x86 and x64 architecture"                                                                                  
 ^                                                                                                                                                         
/home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/mmintrin.h:17:19: error: typedef redefinition with different types ('__attribute__((__vector_size__(1 * sizeof(long long)))) long long' (vector of 1 'long long' value) vs 'simde__m64' (aka 'int32x2_t'))                                     
typedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));                                                                               
                  ^                                                                                                                                        
/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64/dep/include/simde/x86/mmx.h:121:22: note: previous definition is here                                 
  typedef simde__m64 __m64;                        
                     ^                                                                                                                                     
In file included from src/PolyMix.cpp:3:                                                                                                                   
In file included from src/dependancies/dsp/cpPan.h:2:
In file included from src/dependancies/dsp/../utility/fasttrigo.h:46:                                                                                      
In file included from /home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/xmmintrin.h:17:                                              
/home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/mmintrin.h:35:11: error: too many arguments provided to function-like macro invocation                                                                                                                                                         
_mm_empty(void)                                                                                                                                            
          ^                                                                                                                                                                                                                                                                                                            
/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64/dep/include/simde/x86/mmx.h:768:11: note: macro '_mm_empty' defined here                              
#  define _mm_empty() simde_mm_empty()                                                                                                                                                                                                                                                                                 
          ^                                                                                                                                                
In file included from src/PolyMix.cpp:3:                                                                                                                                                                                                                                                                               
In file included from src/dependancies/dsp/cpPan.h:2:                                                                                                      
In file included from src/dependancies/dsp/../utility/fasttrigo.h:46:                                                                                                                                                                                                                                                  
In file included from /home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/xmmintrin.h:17:                                              
/home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/mmintrin.h:34:72: error: '__target__' attribute only applies to functions                                                                                                                                                                      
static __inline__ void  __attribute__((__always_inline__, __nodebug__, __target__("mmx")))                                                                 
                                                                       ^                                                                                                                                                                                                                                               
/home/build/rack-plugin-toolchain/local/bin/../lib/clang/15.0.7/include/mmintrin.h:35:1: error: variable has incomplete type 'void'                        
_mm_empty(void)                                                                                                                                                                                                                                                                                                        
^  

[...]                                                                                                                                           
baconpaul commented 10 months ago

@cschol - @pgatt had asked me about this in the fall. The following diff will fix this package and make it build on ARM.

@Coirt lemme know if you would prefer this as a PR.

diff --git a/src/dependancies/utility/fasttrigo.h b/src/dependancies/utility/fasttrigo.h
index 136be52..64cf4fd 100644
--- a/src/dependancies/utility/fasttrigo.h
+++ b/src/dependancies/utility/fasttrigo.h
@@ -43,8 +43,18 @@
 #include <QtGui>
 #endif
 //#include <intrin.h>
+#if defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) ||                                   \^M
+    (defined(_M_IX86_FP) && _M_IX86_FP >= 2)^M
 #include <xmmintrin.h>
 #include <pmmintrin.h>
+#else^M
+#if defined(__arm__) || defined(__aarch64__) || defined(__riscv)^M
+#define SIMDE_ENABLE_NATIVE_ALIASES^M
+#include "simde/x86/sse2.h"^M
+#else^M
+#error Bark requires either X86/SSE2 or ARM architectures.^M
+#endif^M
+#endif^M

 //Default accuracy
 namespace FT {
baconpaul commented 10 months ago

Added as a PR in #40 if that's easier for you.