tracktion_engine
tracktion_engine copied to clipboard
Needed -latomic linker flag to generate examples on Raspberry Pi 4
I observed issues due to missing -latomic linker flag when executing tests/linux/generate_examples on 32-bit Raspbian 10 (buster) for armv7l with g++ 8.3.0.
As a workaround, I edited the Makefiles for Projucer and StepSequencerDemo demo, which I was trying to build, by adding the linker flag -latomic. For more information about the specific system environment, please refer to the video I recorded on my YouTube channel as well as the video description.
Raspberry Pi 4: Compiled StepSequencerDemo From Tracktion Engine on Raspbian 10 (buster) https://youtu.be/7Rxsc66khE0
Regards, Alan Mikhak
I was able to generate the examples and build Projucer and the StepSequencerDemo without observing the -latomic issue on an Nvidia Jetson Nano DevKit platform which runs 64-bit Ubuntu 18.0.4 on 64-bit Linux kernel for aarch64 architecture.
I was able to do the same without observing the -latomic issue on my NanoPi M4 board which runs 64-bit FriendlyElec OS on 64-bit Linux kernel for aarch64 architecture.
We're in the process of transitioning to the cmake generated examples. If you run those, they should include the -latomic
flags. Do they work out of the box?
I have cmake 3.20.1 compiled from sources and installed on the PATH. I see CMakeLists.txt in Projucer and StepSequencerDemo folders. I didn't see an example of how I should invoke cmake to generate Projucer or the StepSequencerDemo demo. I can try to guess at it.
You just have to cd
in to the StepSequencerDemo
dir and then use the normal cmake generation commands e.g. cmake -B ~/Desktop/build
I see -latomic in the CMakeFiles/StepSequencerDemo.dir/link.txt generated by cmake.
Building StepSequencerDemo with the Makefile generated by CMake produced the following error on the same Raspberry Pi 4:
[ 96%] Building CXX object CMakeFiles/StepSequencerDemo.dir/home/pi/src/github.com/Tracktion/tracktion_engine/modules/tracktion_graph/tracktion_graph.cpp.o
:::
:::
/tmp/ccMjKunc.s: Assembler messages:
/tmp/ccMjKunc.s:5378: Error: selected processor does not support yield' in ARM mode /tmp/ccMjKunc.s:41948: Error: selected processor does not support
yield' in ARM mode
/tmp/ccMjKunc.s:41951: Error: selected processor does not support yield' in ARM mode /tmp/ccMjKunc.s:44358: Error: selected processor does not support
yield' in ARM mode
/tmp/ccMjKunc.s:44361: Error: selected processor does not support yield' in ARM mode /tmp/ccMjKunc.s:45207: Error: selected processor does not support
yield' in ARM mode
/tmp/ccMjKunc.s:45210: Error: selected processor does not support yield' in ARM mode /tmp/ccMjKunc.s:46283: Error: selected processor does not support
yield' in ARM mode
/tmp/ccMjKunc.s:46286: Error: selected processor does not support `yield' in ARM mode
make[2]: *** [CMakeFiles/StepSequencerDemo.dir/build.make:388: CMakeFiles/StepSequencerDemo.dir/home/pi/src/github.com/Tracktion/tracktion_engine/modules/tracktion_graph/tracktion_graph.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:166: CMakeFiles/StepSequencerDemo.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
On the aarch64 Jetson Nano DevKit, I see the following error and many warnings with CMake whereas the build with the published procedure was clean and no warnings.
$ make Consolidate compiler generated dependencies of target StepSequencerDemo [ 4%] Linking CXX executable StepSequencerDemo_artefacts/StepSequencerDemo c++: error: unrecognized command line option ‘-m64’ CMakeFiles/StepSequencerDemo.dir/build.make:472: recipe for target 'StepSequencerDemo_artefacts/StepSequencerDemo' failed make[2]: *** [StepSequencerDemo_artefacts/StepSequencerDemo] Error 1 CMakeFiles/Makefile2:165: recipe for target 'CMakeFiles/StepSequencerDemo.dir/all' failed make[1]: *** [CMakeFiles/StepSequencerDemo.dir/all] Error 2 Makefile:135: recipe for target 'all' failed make: *** [all] Error 2
To be honest, those examples were never configured to run on ARM Pis.
The -m64
is obviously the wrong architecture flag for ARM CPUs. You'll probably need to modify the target_link_options(${CMAKE_PROJECT_NAME} PRIVATE "-m64")
to be whatever the ARM arch you're targeting it or you might be able to delete that line completely to allow it to use the default for the platform?
Try that first to see if it will compile. We build Waveform on Pi 32 & 64 bit so it should find the yield
instruction if it detects the CPU correctly. If not, we might have to add a different version for aarch64 like asm volatile("yield" ::: "memory")
Thanks. I understand. It is great that it works with generate_examples script for ARM. It was clean for 64-bit ARM, at least on two of my aarch64 boards. For 32-bit armv7l Raspberry Pi 4, I just had to add the -latomic flag. That's relatively less work for now than with CMake. I will explore the CMake path since it may be heading that way.
Ok, let me know what you find. I'd add ARM to our examples if our CI could run it but as far as I'm aware, GitHub Actions doesn't currently support hosted ARM instances which makes it difficult for us to test them.
As an alternative workaround for Raspberry Pi 4 running 32-bit Raspbian 10 (buster) for armv7l, I can compile the StepSequencerDemo with either of the following commands:
$ make LDFLAGS=-latomic CONFIG=Release or $ make CXX=clang++ CONFIG=Release
To resolve the "-m64" issue for CMake method on 64-bit ARM, I edited the CMakeLists.txt as follows:
$ git diff
diff --git a/examples/StepSequencerDemo/CMakeLists.txt b/examples/StepSequencerDemo/CMakeLists.txt
index cfaeca88..d5897f2b 100644
--- a/examples/StepSequencerDemo/CMakeLists.txt
+++ b/examples/StepSequencerDemo/CMakeLists.txt
@@ -66,5 +66,9 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "-latomic")
- target_link_options(${CMAKE_PROJECT_NAME} PRIVATE "-m64")
+ if ("${ARCH}" STREQUAL "x86")
+ if (${ARCH_BIT} EQUAL 64)
+ target_link_options(${CMAKE_PROJECT_NAME} PRIVATE "-m64")
+ endif()
+ endif()
endif()
With the above change, I was able to build the StepSequencerDemo using the CMake method on three of my aarch64 boards, the Nvidia Jetson Nano DevKit, the NanoPi M4, and the Google Coral Dev board.
I can build the StepSequencerDemo using the CMake method for 32-bit armv7l on my Raspberry Pi 4 with clang++ as follows:
$ cd ~/src/github.com/Tracktion/tracktion_engine/examples/StepSequencerDemo
$ cmake . -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
$ make
The following is the output of cmake command using clang++ 10.0.0 as the compiler:
$ cmake . -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Not building with VST2
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= clang
CMAKE_CXX_COMPILER= clang++
CMAKE_C_COMPILER= clang
CMAKE_CXX_COMPILER= clang++
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/pi/src/github.com/llvm/llvm-10.0.0/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/pi/src/github.com/llvm/llvm-10.0.0/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29")
-- Checking for module 'libcurl'
-- Found libcurl, version 7.64.0
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
-- Found webkit2gtk-4.0, version 2.30.6
-- Found gtk+-x11-3.0, version 3.24.5
-- Checking for module 'alsa'
-- Found alsa, version 1.1.8
-- Checking for module 'freetype2'
-- Found freetype2, version 22.1.16
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Not building with VST2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/src/github.com/Tracktion/tracktion_engine/examples/StepSequencerDemo