Cross compiling JUCE 6.1.6 results in juceaide being compiled with target toolchain

Thanks for the advice but, in the meantime, I’ve succeeded to set up a relatively clean cross-compile environment using extsdk. I’m posting it here in case it’s useful for people in the future:

Hardware setup

Flash the Raspberry Pi 4B with Elk OS: Release Elk Audio OS Image & Update 0.11.0 (RPi4) · elk-audio/elk-pi · GitHub
Set up communication with the raspberry pi: Working with Elk Board — Elk DevKit documentation
Set up HifiBerry DAC+ ADC Pro (in target): sudo elk_system_utils --set-audio-hat hifiberry-dac-plus-adc-pro

Install Docker

SDK setup

Create a directory to be shared as a volume with the container: mkdir workdir && cd workdir
Clone the patched JUCE in the volume directory: git clone git@github.com:valentinlageard/JUCE.git
Download the SDK in the volume directory: https://github.com/elk-audio/elkpi-sdk/releases/download/0.11.0/elk-glibc-x86_64-elkpi-audio-os-image-cortexa72-raspberrypi4-64-toolchain-0.11.0.sh
The first time, run the container with the sdk passed as a parameter: docker run --rm -it -v /home/valentin/Squarp/x-compile-test/workdir:/workdir crops/extsdk-container --url=/workdir/elk-glibc-x86_64-elkpi-audio-os-image-cortexa72-raspberrypi4-64-toolchain-0.11.0.sh
In subsequent runs you won’t need to pass the sdk: docker run --rm -it -v /home/valentin/Squarp/x-compile-test/workdir:/workdir crops/extsdk-container

JUCE project setup

Create a JUCE project using CMake in the volume directory.
In addition to your project specific configurations, modify your project CMakeList:

  • Add add_subdirectory("../JUCE" JUCE)
  • Check that VST3 is configured as an output target.
  • Comment out juce_generate_juce_header(YourPluginName)
  • Comment out juce::juce_recommended_lto_flags

Cross compilation

From inside the container, the first time, prepare to cross compile by creating a x-build subdirectory and initializing cmake:

  • mkdir x-build && cd x-build
  • cmake ../ -DCMAKE_BUILD_TYPE=Release
    From inside the container, in the x-build subdirectory of your JUCE project:
  • (Optional) Add compilation optimization flags: export CXXFLAGS="-O3 -pipe -ffast-math -feliminate-unused-debug-types -funroll-loops"
  • Build the plugin: AR=aarch64-elk-linux-ar make -j (enter number of cores) CONFIG=Release CFLAGS="-Wno-psabi" TARGET_ARCH="-mcpu=cortex-a72 -mtune=cortex-a72"

Upload and run

scp -r x-build/YourPluginName_artefacts/Release/VST3/ mind@your.raspberry.pi.ip:/udata
Start sushi with a proper sushi config !

Profit !

2 Likes