Tracktion / tracktion_engine

Tracktion Engine module
Other
1.2k stars 152 forks source link

[Bug]: "Bad CPU type in executable" building for ARM64 on Intel #227

Closed JelleBakker closed 2 months ago

JelleBakker commented 2 months ago

Detailed steps on how to reproduce the bug

git clone --recurse-submodules https://github.com/Tracktion/tracktion_engine.git
cd tracktion_engine
git checkout develop
cd ..
mkdir build
cd build
cmake ../tracktion_engine -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build . --config Release --parallel 8 --target EngineInPluginDemo_VST3

What is the expected behaviour?

I expect it to build without errors

Unit test to reproduce the error?

No response

Operating systems

macOS

What versions of the operating systems?

Tested with an Azure macos-13 image: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md

Architectures

x86_64

Stacktrace

2024-08-05T15:01:13.6492630Z ##[section]Starting: CmdLine
2024-08-05T15:01:13.6498170Z ==============================================================================
2024-08-05T15:01:13.6498370Z Task         : Command line
2024-08-05T15:01:13.6498470Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2024-08-05T15:01:13.6498650Z Version      : 2.237.1
2024-08-05T15:01:13.6498740Z Author       : Microsoft Corporation
2024-08-05T15:01:13.6498850Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2024-08-05T15:01:13.6499030Z ==============================================================================
2024-08-05T15:01:13.8515710Z Generating script.
2024-08-05T15:01:13.8526420Z ========================== Starting Command Output ===========================
2024-08-05T15:01:13.8548390Z [command]/bin/bash --noprofile --norc /Users/runner/work/_temp/cbf94b20-12f2-4fd8-b371-bd714b725af7.sh
2024-08-05T15:01:13.8680050Z Cloning into 'tracktion_engine'...
2024-08-05T15:03:12.4101400Z Updating files:  94% (1351/1431)
2024-08-05T15:03:12.4319350Z Updating files:  95% (1360/1431)
2024-08-05T15:03:12.4582530Z Updating files:  96% (1374/1431)
2024-08-05T15:03:12.4954120Z Updating files:  97% (1389/1431)
2024-08-05T15:03:12.5112990Z Updating files:  98% (1403/1431)
2024-08-05T15:03:12.5436650Z Updating files:  99% (1417/1431)
2024-08-05T15:03:12.5493830Z Updating files: 100% (1431/1431)
2024-08-05T15:03:12.5586650Z Updating files: 100% (1431/1431), done.
2024-08-05T15:03:12.6864610Z Submodule 'modules/juce' (git@github.com:juce-framework/JUCE.git) registered for path 'modules/juce'
2024-08-05T15:03:12.7054070Z Cloning into '/Users/runner/work/1/s/tracktion_engine/modules/juce'...
2024-08-05T15:04:01.3288900Z Submodule path 'modules/juce': checked out '46c2a95905abffe41a7aa002c70fb30bd3b626ef'
2024-08-05T15:04:01.6258080Z Already on 'develop'
2024-08-05T15:04:01.6265460Z Your branch is up to date with 'origin/develop'.
2024-08-05T15:04:05.1910480Z -- The C compiler identification is AppleClang 15.0.0.15000100
2024-08-05T15:04:05.3556620Z -- The CXX compiler identification is AppleClang 15.0.0.15000100
2024-08-05T15:04:05.3869210Z -- Detecting C compiler ABI info
2024-08-05T15:04:06.5946960Z -- Detecting C compiler ABI info - done
2024-08-05T15:04:06.6236180Z -- Check for working C compiler: /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
2024-08-05T15:04:06.6248610Z -- Detecting C compile features
2024-08-05T15:04:06.6262120Z -- Detecting C compile features - done
2024-08-05T15:04:06.6376610Z -- Detecting CXX compiler ABI info
2024-08-05T15:04:06.8800880Z -- Detecting CXX compiler ABI info - done
2024-08-05T15:04:06.9040720Z -- Check for working CXX compiler: /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
2024-08-05T15:04:06.9044010Z -- Detecting CXX compile features
2024-08-05T15:04:06.9050650Z -- Detecting CXX compile features - done
2024-08-05T15:04:07.1528620Z -- Configuring juceaide
2024-08-05T15:04:08.2843640Z -- Building juceaide
2024-08-05T15:05:49.6498820Z -- Exporting juceaide
2024-08-05T15:05:49.6502080Z -- Testing juceaide
2024-08-05T15:05:49.9847990Z -- Finished setting up juceaide
2024-08-05T15:05:50.0500950Z Adding Benchmarks to the tracktion project
2024-08-05T15:05:50.0501660Z -- Not building with VST2
2024-08-05T15:05:50.2811170Z Adding TestRunner to the tracktion project
2024-08-05T15:05:50.3019600Z -- Not building with VST2
2024-08-05T15:05:50.3021580Z Adding DemoRunner to the tracktion project
2024-08-05T15:05:50.3023100Z -- Not building with VST2
2024-08-05T15:05:50.8856140Z Adding EngineInPluginDemo to the tracktion project
2024-08-05T15:05:50.8857400Z -- Not building with VST2
2024-08-05T15:05:52.0620200Z CMake Warning at modules/juce/extras/Build/CMake/JUCEUtils.cmake:1300 (message):
2024-08-05T15:05:52.0623920Z   LV2URI should be well-formed with an 'http' or 'urn' prefix.  Check the
2024-08-05T15:05:52.0630460Z   LV2URI argument to juce_add_plugin.
2024-08-05T15:05:52.0634020Z Call Stack (most recent call first):
2024-08-05T15:05:52.0635810Z   modules/juce/extras/Build/CMake/JUCEUtils.cmake:1414 (_juce_set_plugin_target_properties)
2024-08-05T15:05:52.0638150Z   modules/juce/extras/Build/CMake/JUCEUtils.cmake:1551 (_juce_link_plugin_wrapper)
2024-08-05T15:05:52.0640330Z   modules/juce/extras/Build/CMake/JUCEUtils.cmake:2112 (_juce_configure_plugin_targets)
2024-08-05T15:05:52.0641950Z   modules/juce/extras/Build/CMake/JUCEUtils.cmake:2244 (juce_add_plugin)
2024-08-05T15:05:52.0643490Z   examples/EngineInPluginDemo/CMakeLists.txt:34 (juce_add_pip)
2024-08-05T15:05:52.0644660Z 
2024-08-05T15:05:52.0652450Z 
2024-08-05T15:05:52.0654230Z -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
2024-08-05T15:05:52.3333290Z -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
2024-08-05T15:05:52.3363480Z -- Found Threads: TRUE
2024-08-05T15:05:54.0926190Z -- Configuring done (112.4s)
2024-08-05T15:05:54.4211350Z -- Generating done (0.3s)
2024-08-05T15:05:54.4233610Z -- Build files have been written to: /Users/runner/work/1/s/build
2024-08-05T15:05:55.1748450Z [  0%] Generating EngineInPluginDemo_artefacts/JuceLibraryCode/JuceHeader.h
2024-08-05T15:05:55.2008400Z [  0%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/juce_vst3_helper.dir/__/__/modules/juce/modules/juce_audio_plugin_client/VST3/juce_VST3ManifestHelper.mm.o
2024-08-05T15:05:55.5348780Z [  4%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_processors/juce_audio_processors_lv2_libs.cpp.o
2024-08-05T15:05:55.6407560Z [  9%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/EngineInPluginDemo_artefacts/JuceLibraryCode/Main.cpp.o
2024-08-05T15:05:55.7260540Z [  9%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_processors/juce_audio_processors_ara.cpp.o
2024-08-05T15:05:55.8420410Z [  9%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_processors/juce_audio_processors.mm.o
2024-08-05T15:05:55.9450630Z [ 14%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_gui_basics/juce_gui_basics.mm.o
2024-08-05T15:05:56.0855040Z [ 14%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_gui_extra/juce_gui_extra.mm.o
2024-08-05T15:05:56.1859480Z [ 14%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_graphics/juce_graphics_Harfbuzz.cpp.o
2024-08-05T15:05:56.2871050Z [ 19%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_graphics/juce_graphics.mm.o
2024-08-05T15:05:56.3709050Z [ 19%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_events/juce_events.mm.o
2024-08-05T15:06:21.3274670Z [ 23%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_core/juce_core_CompilationTime.cpp.o
2024-08-05T15:06:21.5166820Z [ 23%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_core/juce_core.mm.o
2024-08-05T15:06:24.2178690Z [ 28%] Linking CXX executable juce_vst3_helper
2024-08-05T15:06:24.9597300Z [ 28%] Built target juce_vst3_helper
2024-08-05T15:06:25.0599860Z [ 33%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_data_structures/juce_data_structures.mm.o
2024-08-05T15:06:40.1683720Z [ 33%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_basics/juce_audio_basics.mm.o
2024-08-05T15:06:40.9679550Z [ 38%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_devices/juce_audio_devices.mm.o
2024-08-05T15:06:49.1351150Z [ 38%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_formats/juce_audio_formats.mm.o
2024-08-05T15:07:14.7952950Z [ 42%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_audio_utils/juce_audio_utils.mm.o
2024-08-05T15:07:18.9028870Z [ 42%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_dsp/juce_dsp.mm.o
2024-08-05T15:07:52.6855370Z [ 42%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/juce/modules/juce_osc/juce_osc.cpp.o
2024-08-05T15:07:53.9890120Z [ 47%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_airwindows_1.cpp.o
2024-08-05T15:08:03.6646700Z [ 47%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_airwindows_2.cpp.o
2024-08-05T15:08:05.1131950Z [ 52%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_airwindows_3.cpp.o
2024-08-05T15:08:05.4990380Z [ 52%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_audio_files.cpp.o
2024-08-05T15:08:08.1890270Z [ 57%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_model_1.cpp.o
2024-08-05T15:08:15.1642440Z [ 57%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_model_2.cpp.o
2024-08-05T15:08:26.3808870Z [ 61%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_playback.cpp.o
2024-08-05T15:08:35.9358620Z [ 61%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_plugins.cpp.o
2024-08-05T15:08:36.6185500Z [ 66%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_timestretch.cpp.o
2024-08-05T15:09:15.1928260Z [ 66%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_engine/tracktion_engine_utils.cpp.o
2024-08-05T15:09:20.6019290Z [ 71%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_graph/tracktion_graph.cpp.o
2024-08-05T15:09:58.1689920Z [ 71%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo.dir/__/__/modules/tracktion_core/tracktion_core.cpp.o
2024-08-05T15:10:49.2068500Z [ 71%] Linking CXX static library EngineInPluginDemo_artefacts/Release/libEngineInPluginDemo_SharedCode.a
2024-08-05T15:10:50.0631570Z [ 71%] Built target EngineInPluginDemo
2024-08-05T15:10:50.1975200Z [ 71%] Generating EngineInPluginDemo_artefacts/JuceLibraryCode/EngineInPluginDemo_VST3/PkgInfo
2024-08-05T15:10:50.5362080Z [ 71%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_ARA.cpp.o
2024-08-05T15:10:50.5626980Z [ 76%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX_utils.cpp.o
2024-08-05T15:10:50.5630670Z [ 80%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp.o
2024-08-05T15:10:50.5647330Z [ 80%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp.o
2024-08-05T15:10:50.5649330Z [ 85%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.mm.o
2024-08-05T15:10:50.5650030Z [ 85%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm.o
2024-08-05T15:10:50.5650650Z [ 90%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_2.mm.o
2024-08-05T15:10:50.5653570Z [ 90%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm.o
2024-08-05T15:10:50.6922350Z [ 95%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_LV2.mm.o
2024-08-05T15:10:50.6925770Z [ 95%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.mm.o
2024-08-05T15:10:50.6927130Z [ 95%] Building CXX object examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/__/__/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.mm.o
2024-08-05T15:10:58.5941620Z [100%] Linking CXX CFBundle shared module EngineInPluginDemo_artefacts/Release/VST3/EngineInPluginDemo.vst3/Contents/MacOS/EngineInPluginDemo
2024-08-05T15:11:01.5918820Z /Users/runner/work/1/s/build/examples/EngineInPluginDemo/EngineInPluginDemo_artefacts/Release/VST3/EngineInPluginDemo.vst3: code has no resources but signature indicates they must be present
2024-08-05T15:11:01.5924560Z -- Replacing invalid signature with ad-hoc signature
2024-08-05T15:11:01.6114080Z /Users/runner/work/1/s/build/examples/EngineInPluginDemo/EngineInPluginDemo_artefacts/Release/VST3/EngineInPluginDemo.vst3: replacing existing signature
2024-08-05T15:11:01.7423690Z removing moduleinfo.json
2024-08-05T15:11:01.7916990Z /bin/sh: ./juce_vst3_helper: Bad CPU type in executable
2024-08-05T15:11:01.7922300Z make[3]: *** [examples/EngineInPluginDemo/EngineInPluginDemo_artefacts/Release/VST3/EngineInPluginDemo.vst3/Contents/MacOS/EngineInPluginDemo] Error 126
2024-08-05T15:11:01.7923180Z make[3]: *** Deleting file `examples/EngineInPluginDemo/EngineInPluginDemo_artefacts/Release/VST3/EngineInPluginDemo.vst3/Contents/MacOS/EngineInPluginDemo'
2024-08-05T15:11:01.7932850Z make[2]: *** [examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/all] Error 2
2024-08-05T15:11:01.7939700Z make[1]: *** [examples/EngineInPluginDemo/CMakeFiles/EngineInPluginDemo_VST3.dir/rule] Error 2
2024-08-05T15:11:01.7947510Z make: *** [EngineInPluginDemo_VST3] Error 2
2024-08-05T15:11:01.8344200Z 
2024-08-05T15:11:01.8490800Z ##[error]Bash exited with code '2'.
2024-08-05T15:11:01.8640940Z ##[section]Finishing: CmdLine

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

drowaudio commented 2 months ago

That looks like an error in juce?

2024-08-05T15:11:01.7916990Z /bin/sh: ./juce_vst3_helper: Bad CPU type in executable

Could this be that the runner is x86_64 and you're trying to build arm64 only? It could be that whatever is in juce_vst3_helper (is this Steinberg code?) needs to read a native binary?

JelleBakker commented 2 months ago

The runner is Intel and it's building for arm64. So yes this is probably the issue. But building for arm on intel should be possible, right. At least I've been doing this without issues before.

drowaudio commented 2 months ago

Yes, it's just that I don't know if juce supports building just an arm binary.

I'm just guessing here but I think that is a steinberg tool that juce packages up. If it expects the native architecture of the build machine, it's going to look for an x86_64 binary. If it doesn't find that, it seems to be failing.

Is there a reason you're not building a Universal Binary? I.e. x86_64 & arm64 in the same build? There's a fair chance that will work as it will be able to get whatever info it needs from the x86_64 part.

Does this work? -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"

JelleBakker commented 2 months ago

That worked indeed.

I asked it on the JUCE forum: https://forum.juce.com/t/cannot-build-for-apple-silicon-on-intel/62395/3

So, It seems like what I'm trying to do is not really supported.

The reason I'm doing it this way is because I have another library that I use that has a seperate binary for Apple Silicon and Intel, but I'll attempt to merge those into a Universal one and avoid building JUCE for Intel and Silicon seperately.

drowaudio commented 2 months ago

Ok, I'll close this then.

BTW, it's quite easy to merge an arm and x64 binary in to a fat binary using lipo