I’m cross-compiling my audio plugin for Windows via a Linux Docker container, mstorsjo/llvm-mingw
.
I think this has exposed me to an obscure combination (Clang on Windows). It fails to compile juce_MathsFunctions.h
(using the macros in juce_PlatformDefs.h
).
Because, juce_MathsFunctions.h
has the first usage of jassert()
, which ultimately expands the JUCE_BREAK_IN_DEBUGGER
macro, { __asm int 3 }
.
We can see in Godbolt that Clang 13 cannot compile __asm int 3
.
Verbose build output is as follows:
[ 2%] Building CXX object CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj
/opt/llvm-mingw/bin/x86_64-w64-mingw32-clang++ -DDEBUG=1 -DDONT_SET_USING_JUCE_NAMESPACE=1 -DJUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 -DJUCE_MODULE_AVAILABLE_juce_audio_basics=1 -DJUCE_MODULE_AVAILABLE_juce_audio_devices=1 -DJUCE_MODULE_AVAILABLE_juce_audio_formats=1 -DJUCE_MODULE_AVAILABLE_juce_audio_plugin_client=1 -DJUCE_MODULE_AVAILABLE_juce_audio_processors=1 -DJUCE_MODULE_AVAILABLE_juce_audio_utils=1 -DJUCE_MODULE_AVAILABLE_juce_core=1 -DJUCE_MODULE_AVAILABLE_juce_data_structures=1 -DJUCE_MODULE_AVAILABLE_juce_events=1 -DJUCE_MODULE_AVAILABLE_juce_graphics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_basics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_extra=1 -DJUCE_SHARED_CODE=1 -DJUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone -DJUCE_USE_CURL=0 -DJUCE_VST3_CAN_REPLACE_VST2=1 -DJUCE_WEB_BROWSER=0 -DJucePlugin_AAXCategory=2048 -DJucePlugin_AAXDisableBypass=0 -DJucePlugin_AAXDisableMultiMono=0 -DJucePlugin_AAXIdentifier=com.Birchlabs.JuicySFPlugin -DJucePlugin_AAXManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AAXProductId=JucePlugin_PluginCode -DJucePlugin_AUExportPrefix=juicysfpluginAU -DJucePlugin_AUExportPrefixQuoted=\"juicysfpluginAU\" -DJucePlugin_AUMainType="'aumu'" -DJucePlugin_AUManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AUSubType=JucePlugin_PluginCode -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_Standalone=1 -DJucePlugin_Build_Unity=0 -DJucePlugin_Build_VST3=1 -DJucePlugin_Build_VST=1 -DJucePlugin_CFBundleIdentifier=com.Birchlabs.JuicySFPlugin -DJucePlugin_Desc="\"Audio plugin to play soundfonts\"" -DJucePlugin_EditorRequiresKeyboardFocus=1 -DJucePlugin_IsMidiEffect=0 -DJucePlugin_IsSynth=1 -DJucePlugin_Manufacturer=\"Birchlabs\" -DJucePlugin_ManufacturerCode=0x426c6273 -DJucePlugin_ManufacturerEmail=\"\" -DJucePlugin_ManufacturerWebsite=\"https://birchlabs.co.uk\" -DJucePlugin_Name=\"juicysfplugin\" -DJucePlugin_PluginCode=0x4a736670 -DJucePlugin_ProducesMidiOutput=0 -DJucePlugin_VSTCategory=kPlugCategSynth -DJucePlugin_VSTNumMidiInputs=16 -DJucePlugin_VSTNumMidiOutputs=16 -DJucePlugin_VSTUniqueID=JucePlugin_PluginCode -DJucePlugin_Version=3.0.0 -DJucePlugin_VersionCode=0x30000 -DJucePlugin_VersionString=\"3.0.0\" -DJucePlugin_Vst3Category="\"Instrument|Synth\"" -DJucePlugin_WantsMidiInput=1 -D_DEBUG=1 @CMakeFiles/JuicySFPlugin.dir/includes_CXX.rsp -g -fvisibility=hidden -fvisibility-inlines-hidden -Wa,-mbig-obj -pthread -mms-bitfields -g -O0 -Wall -Wshadow-all -Wshorten-64-to-32 -Wstrict-aliasing -Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion -Wsign-conversion -Wbool-conversion -Wextra-semi -Wunreachable-code -Wcast-align -Wshift-sign-overflow -Wno-missing-field-initializers -Wnullable-to-nonnull-conversion -Wno-ignored-qualifiers -Wswitch-enum -Wpedantic -Wzero-as-null-pointer-constant -Wunused-private-field -Woverloaded-virtual -Wreorder -Winconsistent-missing-destructor-override -std=gnu++17 -MD -MT CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj -MF CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj.d -o CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj -c /build/juicysfplugin/Source/FilePicker.cpp
In file included from /build/juicysfplugin/Source/FilePicker.cpp:5:
In file included from /build/juicysfplugin/Source/FilePicker.h:7:
In file included from /build/juicysfplugin/Source/../JuceLibraryCode/JuceHeader.h:14:
In file included from /linux_native/include/JUCE-6.1.4/modules/juce_audio_basics/juce_audio_basics.h:54:
In file included from /linux_native/include/JUCE-6.1.4/modules/juce_core/juce_core.h:223:
/linux_native/include/JUCE-6.1.4/modules/juce_core/maths/juce_MathsFunctions.h:129:5: error: expected 'volatile', 'inline', 'goto', or '('
jassert (sourceRangeMax != sourceRangeMin); // mapping from a range of zero will produce NaN!
^
/linux_native/include/JUCE-6.1.4/modules/juce_core/system/juce_PlatformDefs.h:162:95: note: expanded from macro 'jassert'
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
^
/linux_native/include/JUCE-6.1.4/modules/juce_core/system/juce_PlatformDefs.h:152:144: note: expanded from macro 'jassertfalse'
#define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION; if (juce::juce_isRunningUnderDebugger()) JUCE_BREAK_IN_DEBUGGER; JUCE_ANALYZER_NORETURN)
^
/linux_native/include/JUCE-6.1.4/modules/juce_core/system/juce_PlatformDefs.h:85:49: note: expanded from macro 'JUCE_BREAK_IN_DEBUGGER'
#define JUCE_BREAK_IN_DEBUGGER { __asm int 3 }
Full context here:
Birch-san:master
← Birch-san:win32-cross-compile
opened 10:55PM - 03 Jan 22 UTC
Failing to compile inline assembly in Clang
I think the fix would be something like:
+ #elif JUCE_CLANG
+ // inline ASM not supported
+ #define JUCE_BREAK_IN_DEBUGGER { }
#else
#define JUCE_BREAK_IN_DEBUGGER { __asm int 3 }
#endif
working around it for now by passing cmake option: -DCMAKE_CXX_FLAGS='-DJUCE_DISABLE_ASSERTIONS'
I’ve moved this over to a GitHub issue:
opened 09:20AM - 05 Jan 22 UTC
I'm cross-compiling my audio plugin for Windows via a Linux Docker container, `m… storsjo/llvm-mingw`.
I think this has exposed me to an obscure combination (Clang on Windows). It fails to compile `juce_MathsFunctions.h` (using the macros in `juce_PlatformDefs.h`).
Because, `juce_MathsFunctions.h` has the first usage of `jassert()`, which ultimately expands the `JUCE_BREAK_IN_DEBUGGER` macro, `{ __asm int 3 }`.
We can see in Godbolt that Clang 13 [cannot compile `__asm int 3`](https://godbolt.org/z/YvjahqT4M).
Verbose build output is as follows:
```
[ 2%] Building CXX object CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj
/opt/llvm-mingw/bin/x86_64-w64-mingw32-clang++ -DDEBUG=1 -DDONT_SET_USING_JUCE_NAMESPACE=1 -DJUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 -DJUCE_MODULE_AVAILABLE_juce_audio_basics=1 -DJUCE_MODULE_AVAILABLE_juce_audio_devices=1 -DJUCE_MODULE_AVAILABLE_juce_audio_formats=1 -DJUCE_MODULE_AVAILABLE_juce_audio_plugin_client=1 -DJUCE_MODULE_AVAILABLE_juce_audio_processors=1 -DJUCE_MODULE_AVAILABLE_juce_audio_utils=1 -DJUCE_MODULE_AVAILABLE_juce_core=1 -DJUCE_MODULE_AVAILABLE_juce_data_structures=1 -DJUCE_MODULE_AVAILABLE_juce_events=1 -DJUCE_MODULE_AVAILABLE_juce_graphics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_basics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_extra=1 -DJUCE_SHARED_CODE=1 -DJUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone -DJUCE_USE_CURL=0 -DJUCE_VST3_CAN_REPLACE_VST2=1 -DJUCE_WEB_BROWSER=0 -DJucePlugin_AAXCategory=2048 -DJucePlugin_AAXDisableBypass=0 -DJucePlugin_AAXDisableMultiMono=0 -DJucePlugin_AAXIdentifier=com.Birchlabs.JuicySFPlugin -DJucePlugin_AAXManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AAXProductId=JucePlugin_PluginCode -DJucePlugin_AUExportPrefix=juicysfpluginAU -DJucePlugin_AUExportPrefixQuoted=\"juicysfpluginAU\" -DJucePlugin_AUMainType="'aumu'" -DJucePlugin_AUManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AUSubType=JucePlugin_PluginCode -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_Standalone=1 -DJucePlugin_Build_Unity=0 -DJucePlugin_Build_VST3=1 -DJucePlugin_Build_VST=1 -DJucePlugin_CFBundleIdentifier=com.Birchlabs.JuicySFPlugin -DJucePlugin_Desc="\"Audio plugin to play soundfonts\"" -DJucePlugin_EditorRequiresKeyboardFocus=1 -DJucePlugin_IsMidiEffect=0 -DJucePlugin_IsSynth=1 -DJucePlugin_Manufacturer=\"Birchlabs\" -DJucePlugin_ManufacturerCode=0x426c6273 -DJucePlugin_ManufacturerEmail=\"\" -DJucePlugin_ManufacturerWebsite=\"https://birchlabs.co.uk\" -DJucePlugin_Name=\"juicysfplugin\" -DJucePlugin_PluginCode=0x4a736670 -DJucePlugin_ProducesMidiOutput=0 -DJucePlugin_VSTCategory=kPlugCategSynth -DJucePlugin_VSTNumMidiInputs=16 -DJucePlugin_VSTNumMidiOutputs=16 -DJucePlugin_VSTUniqueID=JucePlugin_PluginCode -DJucePlugin_Version=3.0.0 -DJucePlugin_VersionCode=0x30000 -DJucePlugin_VersionString=\"3.0.0\" -DJucePlugin_Vst3Category="\"Instrument|Synth\"" -DJucePlugin_WantsMidiInput=1 -D_DEBUG=1 @CMakeFiles/JuicySFPlugin.dir/includes_CXX.rsp -g -fvisibility=hidden -fvisibility-inlines-hidden -Wa,-mbig-obj -pthread -mms-bitfields -g -O0 -Wall -Wshadow-all -Wshorten-64-to-32 -Wstrict-aliasing -Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion -Wsign-conversion -Wbool-conversion -Wextra-semi -Wunreachable-code -Wcast-align -Wshift-sign-overflow -Wno-missing-field-initializers -Wnullable-to-nonnull-conversion -Wno-ignored-qualifiers -Wswitch-enum -Wpedantic -Wzero-as-null-pointer-constant -Wunused-private-field -Woverloaded-virtual -Wreorder -Winconsistent-missing-destructor-override -std=gnu++17 -MD -MT CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj -MF CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj.d -o CMakeFiles/JuicySFPlugin.dir/Source/FilePicker.cpp.obj -c /build/juicysfplugin/Source/FilePicker.cpp
In file included from /build/juicysfplugin/Source/FilePicker.cpp:5:
In file included from /build/juicysfplugin/Source/FilePicker.h:7:
In file included from /build/juicysfplugin/Source/../JuceLibraryCode/JuceHeader.h:14:
In file included from /linux_native/include/JUCE-6.1.4/modules/juce_audio_basics/juce_audio_basics.h:54:
In file included from /linux_native/include/JUCE-6.1.4/modules/juce_core/juce_core.h:223:
/linux_native/include/JUCE-6.1.4/modules/juce_core/maths/juce_MathsFunctions.h:129:5: error: expected 'volatile', 'inline', 'goto', or '('
jassert (sourceRangeMax != sourceRangeMin); // mapping from a range of zero will produce NaN!
^
/linux_native/include/JUCE-6.1.4/modules/juce_core/system/juce_PlatformDefs.h:162:95: note: expanded from macro 'jassert'
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
^
/linux_native/include/JUCE-6.1.4/modules/juce_core/system/juce_PlatformDefs.h:152:144: note: expanded from macro 'jassertfalse'
#define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION; if (juce::juce_isRunningUnderDebugger()) JUCE_BREAK_IN_DEBUGGER; JUCE_ANALYZER_NORETURN)
^
/linux_native/include/JUCE-6.1.4/modules/juce_core/system/juce_PlatformDefs.h:85:49: note: expanded from macro 'JUCE_BREAK_IN_DEBUGGER'
#define JUCE_BREAK_IN_DEBUGGER { __asm int 3 }
```
Full context here:
https://github.com/Birch-san/juicysfplugin/pull/33
One (bad) workaround would be to **not** tell the debugger to break, if you're under clang:
https://github.com/juce-framework/JUCE/blob/master/modules/juce_core/system/juce_PlatformDefs.h#L85
```diff
+ #elif JUCE_CLANG
+ // inline ASM not supported
+ #define JUCE_BREAK_IN_DEBUGGER { }
#else
#define JUCE_BREAK_IN_DEBUGGER { __asm int 3 }
#endif
```
For now I'm working around it by passing cmake option: `-DCMAKE_CXX_FLAGS='-DJUCE_DISABLE_ASSERTIONS'`.
What arch are you targeting? Intel targets support __asm int 3
just fine, so I’m guessing you’re configured for ARM (which I believe is untested with JUCE on Windows/ARM)…
A compatibility list for the debug trap for various archs and toolchains can be found here: c++ - Is there a portable equivalent to DebugBreak()/__debugbreak? - Stack Overflow
I don’t think leaving the debug trap blank is the right solution.
1 Like
The first compile failure I’m experiencing occurs on x86_64. Here’s a minimal repro on Godbolt .
From the StackOverflow that you’ve linked , it sounds like the syntax Clang is expecting is:
// https://github.com/nemequ/portable-snippets/blob/84abba93ff3d52c87e08ba81de1cc6615a42b72e/debug-trap/debug-trap.h
__asm__ __volatile__("int3");
this does indeed look like it compiles on Clang x86_64 .
Interesting. Then again, Godbolt + clang + x86_64 provides the int3
via __builtin_debugtrap()
(as provided by Clang). That would probably be more well-rounded from the toolchain’s POV - it should work with ARM devices.
You can see an example of this working with Clang as far as back as 3.3: Compiler Explorer
1 Like
reuk
January 18, 2022, 4:03pm
7
I’ve recently spent some time fixing JUCE builds for MinGW-W64 8.1.0+ (that’s the version that ships in the most recent CodeBlocks).
The relevant changes are
committed 07:57PM - 05 Jan 22 UTC
committed 03:30PM - 10 Jan 22 UTC
With this patch applied, the DemoRunner should build under MinGW, and be
(nearly… ) feature-complete compared to the MSVC build.
Specifically, when building with MinGW:
- Adds support for accessibility
- Fixes build issues in the juce_video module
- Fixes a link issue in the VST3 wrapper when VST3_CAN_REPLACE_VST2 is
defined
- Adds support for the new-style native FileChooser
- Tidies up some other low-severity warnings
Known issues:
- Direct2D rendering is still not supported when building with MinGW due
to ABI compatibilities.
Please try building with JUCE from the most recent develop
branch and let us know if you run into any further issues.
Hey, I’ve tried upgrading to JUCE 6.1.5 but still getting uuidof() errors:
opened 09:00AM - 09 Feb 22 UTC
### Detailed steps on how to reproduce the bug
Use llvm-mingw toolchain to co… mpile JUCE's "audio plugin" example:
```bash
git clone https://github.com/Birch-san/juce-repro.git
cd juce-repro
docker build --tag=juce-repro .
```
Source code available in https://github.com/Birch-san/juce-repro.
Compilation of audio plugin will fail with:
```
In file included from /linux_native/include/JUCE-6.1.5/modules/juce_core/juce_core.h:351:
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:178:22: error: use of undeclared identifier '__mingw_uuidof'
if (refId == __uuidof (IUnknown))
^
/opt/llvm-mingw/x86_64-w64-mingw32/include/_mingw.h:564:24: note: expanded from macro '__uuidof'
#define __uuidof(type) __mingw_uuidof<__typeof(type)>()
```
This looks related to the `__uuidof(x)` problem I reported previously (presumed introduced with JUCE 6.1.3):
https://github.com/juce-framework/JUCE/issues/985
I **have** [previously succeeded](https://github.com/Birch-san/juicysfplugin/blob/master/win32.Dockerfile) in cross-compiling (on JUCE 6.1.2 with a [minor tweak](https://github.com/Birch-san/JUCE/commit/7182e6e11a2dea40ae450548da7aaa0375e3f518)), so this can be thought of as a regression for llvm-mingw consumers.
### What is the expected behaviour?
Compilation should succeed without error.
### Operating systems
Linux
### What versions of the operating systems?
Ubuntu 22.04 aarch64 cross-compiling for Windows 7 x86_64
### Architectures
x86_64
### Stacktrace
```shell
In file included from /linux_native/include/JUCE-6.1.5/modules/juce_core/juce_core.h:351:
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:178:22: error: use of undeclared identifier '__mingw_uuidof'
if (refId == __uuidof (IUnknown))
^
/opt/llvm-mingw/x86_64-w64-mingw32/include/_mingw.h:564:24: note: expanded from macro '__uuidof'
#define __uuidof(type) __mingw_uuidof<__typeof(type)>()
```
### Plug-in formats (if applicable)
Standalone
### Plug-in host applications (DAWs) (if applicable)
_No response_
### Testing on the `develop` branch
I have not tested against the `develop` branch
### Code of Conduct
- [X] I agree to follow the Code of Conduct
and now cross-compilation is even harder, since a new dependency has been introduced on the Windows SDK:
opened 09:15AM - 09 Feb 22 UTC
### Detailed steps on how to reproduce the bug
I use llvm-mingw toolchain to cr… oss-compile JUCE (on Linux, for Windows).
This [worked](https://github.com/Birch-san/juicysfplugin/blob/master/win32.Dockerfile) in JUCE 6.1.2 (with [minor tweaks](https://github.com/Birch-san/JUCE/commit/7182e6e11a2dea40ae450548da7aaa0375e3f518)).
I'm trying to upgrade to JUCE 6.1.5; new build steps are as follows ([source code](https://github.com/Birch-san/juicysfplugin/blob/update-deps/win32.arm.Dockerfile) here):
```bash
git clone https://github.com/Birch-san/juicysfplugin.git
cd juicysfplugin
git checkout update-deps
docker build . -f win32.arm.Dockerfile --tag=llvm-mingw-arm
```
As of 6.1.5: JUCE attempts `#include <UIAutomation.h>` regardless of tooclhain:
https://github.com/juce-framework/JUCE/blob/53b04877c6ebc7ef3cb42e84cb11a48e0cf809b5/modules/juce_gui_basics/juce_gui_basics.cpp#L70
This has introduced for the first time a dependency on the Windows SDK, which has serious difficulties compiling in clang:
https://gist.github.com/Birch-san/d54e6e64be4e954b59a5156f76472a0a
```
/xwin/sdk/include/um/winnt.h:8145:47: error: invalid operands to binary expression ('LONGLONG' (aka 'double') and 'LONGLONG')
Old | Value,
~~~ ^ ~~~~~
/xwin/sdk/include/um/winnt.h:8183:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^
/xwin/sdk/include/um/winnt.h:8205:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
```
So there are at least two problems here (which prevent Clang compiling the Windows SDK):
- `long long` is defined as a `double` (hence we're failing to do binary arithmetic on floats)
- `_InterlockedCompareExchange64` compiler intrinsic is not implemented
My ideal solution would be "find a way to compile the Windows SDK headers on llvm-mingw toolchain", but failing that it'd at be good to have some way to fall back to the JUCE 6.1.2 behaviour (compile without a dependency on Windows SDK).
### What is the expected behaviour?
Compiles juce_gui_basics.cpp without error.
### Operating systems
Linux
### What versions of the operating systems?
Ubuntu 22.04 aarch64 cross-compiling for Windows 7 x86_64
### Architectures
x86_64
### Stacktrace
```shell
/xwin/sdk/include/um/winnt.h:8145:47: error: invalid operands to binary expression ('LONGLONG' (aka 'double') and 'LONGLONG')
Old | Value,
~~~ ^ ~~~~~
/xwin/sdk/include/um/winnt.h:8183:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^
/xwin/sdk/include/um/winnt.h:8205:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
```
### Plug-in formats (if applicable)
Standalone
### Plug-in host applications (DAWs) (if applicable)
_No response_
### Testing on the `develop` branch
I have not tested against the `develop` branch
### Code of Conduct
- [X] I agree to follow the Code of Conduct
how do I compile the Windows SDK headers with Clang on Linux?
okay, looks like MinGW does come with Windows SDK headers, but the filename is lowercase so it wasn’t discovered.
opened 09:15AM - 09 Feb 22 UTC
closed 11:16PM - 13 Feb 22 UTC
### Detailed steps on how to reproduce the bug
I use llvm-mingw toolchain to cr… oss-compile JUCE (on Linux, for Windows).
This [worked](https://github.com/Birch-san/juicysfplugin/blob/master/win32.Dockerfile) in JUCE 6.1.2 (with [minor tweaks](https://github.com/Birch-san/JUCE/commit/7182e6e11a2dea40ae450548da7aaa0375e3f518)).
I'm trying to upgrade to JUCE 6.1.5; new build steps are as follows ([source code](https://github.com/Birch-san/juicysfplugin/blob/update-deps/win32.arm.Dockerfile) here):
```bash
git clone https://github.com/Birch-san/juicysfplugin.git
cd juicysfplugin
git checkout update-deps
docker build . -f win32.arm.Dockerfile --tag=llvm-mingw-arm
```
As of 6.1.5: JUCE attempts `#include <UIAutomation.h>` regardless of tooclhain:
https://github.com/juce-framework/JUCE/blob/53b04877c6ebc7ef3cb42e84cb11a48e0cf809b5/modules/juce_gui_basics/juce_gui_basics.cpp#L70
This has introduced for the first time a dependency on the Windows SDK, which has serious difficulties compiling in clang:
https://gist.github.com/Birch-san/d54e6e64be4e954b59a5156f76472a0a
```
/xwin/sdk/include/um/winnt.h:8145:47: error: invalid operands to binary expression ('LONGLONG' (aka 'double') and 'LONGLONG')
Old | Value,
~~~ ^ ~~~~~
/xwin/sdk/include/um/winnt.h:8183:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^
/xwin/sdk/include/um/winnt.h:8205:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
```
So there are at least two problems here (which prevent Clang compiling the Windows SDK):
- `long long` is defined as a `double` (hence we're failing to do binary arithmetic on floats)
- `_InterlockedCompareExchange64` compiler intrinsic is not implemented
My ideal solution would be "find a way to compile the Windows SDK headers on llvm-mingw toolchain", but failing that it'd at be good to have some way to fall back to the JUCE 6.1.2 behaviour (compile without a dependency on Windows SDK).
### What is the expected behaviour?
Compiles juce_gui_basics.cpp without error.
### Operating systems
Linux
### What versions of the operating systems?
Ubuntu 22.04 aarch64 cross-compiling for Windows 7 x86_64
### Architectures
x86_64
### Stacktrace
```shell
/xwin/sdk/include/um/winnt.h:8145:47: error: invalid operands to binary expression ('LONGLONG' (aka 'double') and 'LONGLONG')
Old | Value,
~~~ ^ ~~~~~
/xwin/sdk/include/um/winnt.h:8183:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^
/xwin/sdk/include/um/winnt.h:8205:14: error: no matching function for call to '_InterlockedCompareExchange64'
} while (InterlockedCompareExchange64(Addend,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:8057:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/xwin/sdk/include/um/winnt.h:7763:1: note: candidate function not viable: no known conversion from 'volatile LONGLONG *' (aka 'volatile double *') to 'volatile LONG64 *' (aka 'volatile long long *') for 1st argument
InterlockedCompareExchange64 (
^
/xwin/sdk/include/um/winnt.h:7740:38: note: expanded from macro 'InterlockedCompareExchange64'
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
```
### Plug-in formats (if applicable)
Standalone
### Plug-in host applications (DAWs) (if applicable)
_No response_
### Testing on the `develop` branch
I have not tested against the `develop` branch
### Code of Conduct
- [X] I agree to follow the Code of Conduct
I do have some new Clang 14 related compile errors, and x86 audio plugins no longer compile at all. will raise tickets for those.