Build issue on macOS / iOS + JUCE 7.0.2

Hi,

I’m currently working on a tracktion+JUCE based app with other 3rd party dependencies. Tracktion develop branch has been updated to use JUCE 7.0.2. I’d like to follow the update as some bugs have been fixed.

As a result, I’m having a nasty build issue. I rely on CMake for generating Xcode projects on macOS and iOS.

During the build phase, in juce_gui_basics.mm (juce_gui_basics.cpp), I get this error in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/simd/vector.h:49:

[...]/MacOSX12.3.sdk/usr/include/simd/geometry.h:780:80: error: use of undeclared identifier 'simd_reduce_add'
static float  SIMD_CFUNC simd_dot(simd_float2  __x, simd_float2  __y) { return simd_reduce_add(__x*__y); }

The error comes down to the MetalKit include in juce_gui_basics.cpp:

#if JUCE_MAC
 #import <WebKit/WebKit.h>
 #import <IOKit/pwr_mgt/IOPMLib.h>
 #import <MetalKit/MetalKit.h>
[...]

Digging into the various Accelerate simd headers, this simd_reduce_add function is declared in [...]/usr/include/simd/common.h, but guarded by this preprocessor directive:

#if SIMD_COMPILER_HAS_REQUIRED_FEATURES

This macro is set to 1 in [...]/usr/include/simd/base.h when the compiler has the ext_vector_type and overloadable extensions. After some reseach, these are clang extensions.

# if __has_attribute(__ext_vector_type__) && __has_attribute(__overloadable__)
#  define SIMD_COMPILER_HAS_REQUIRED_FEATURES 1
# else
/*  Your compiler is missing one or more features that are hard requirements
 *  for any <simd/simd.h> support. None of the types or functions defined by
 *  the simd headers will be available.                                       */
#  define SIMD_COMPILER_HAS_REQUIRED_FEATURES 0
# endif

I checked the command line invocation for juce_gui_basics.mm and it is definitely using clang.

I’m on Xcode 14.0.1 / macOS 12.6 / M1 mac mini.

I tried with Xcode 13.4.1 with the same results; same for enforcing x86_64 (Rosetta).

My CMakeLists.txt file is pretty generic. I tried removing as much options as necessary but to no avail.

Calling all CMake & clang gurus!

Thanks in advance for any help/pointers you can provide.

E.

OK this one was really tricky!

I have a 3rd party library that contains a simd/Common.h file (note the upper case ‘C’).

The system Accelerate simd library also contains a simd/common.h (lowercase ‘c’) file which includes that simd_reduce_add function. It was mistakenly including my other 3rd party library simd/Common.h file. This might be because the macOS filesystem is case insensitive by default (unless your format your drive especially with the case sensitive function). Jeez!

I guess I’ll have to rename the 3rd party library Common.h file, but there might be a better alternative? Open to hear your ideas !

Thanks in advance,
E.