A question about PX4 documents

Hello,
I read in https://dev.px4.io/v1.10_noredirect/en/setup/dev_env_linux_ubuntu.html#clang that it is possible to cross-compile using clang, can you please tell me now px4 Does px4 support this now?

When I tried the https://docs.px4.io/v1.13/en/dev_setup/dev_env_linux_ubuntu.html#clang-optional method on v1.13.0, I found that it didn’t actually using clang cross compilation.

You’re saying the clang build doesn’t work? What commands do you run? I suggest to use v1.14 or main though because it’s unlikely someone will go back to v1.13 and look into this.

clang did not work when following the steps described in the documentation for RasPi cross-compilation.

First of all, following RasPi’s request, I’m using ubuntu 18.04.
Second, configure the build environment by typing bash ubuntu.sh --no-nuttx --no-sim-tools.
Third, type sudo apt-get install -y gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-8 100 -- slave /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-8 sudo update-alternatives --config arm-linux-gnueabihf-gcc to configure the cross-compiler
Finally, following the documentation, I started running
mkdir build/px4_raspberrypi_default_clang cd build/px4_raspberrypi_default_clang cmake \ -G "Unix Makefiles" \ -DCONFIG=px4_raspberrypi_default \ -UCMAKE_C_COMPILER \ -DCMAKE_C_COMPILER=clang \ -UCMAKE_CXX_COMPILER \ -DCMAKE_CXX_COMPILER=clang++ \ ... /... make
to compile.

The result of the cmake execution is as follows, it does not use clang cross-compilation as described in the documentation, it still uses the gcc cross-compilation toolchain.

– PX4 version: v1.13.0
– Found PythonInterp: /usr/bin/python3 (found suitable version “3.6.9”, minimum required is “3”)
– PX4 config file: /home/lqs66/Desktop/px4-1.13.0/boards/px4/raspberrypi/default.px4board
– PLATFORM posix
– LINUX y
– TOOLCHAIN arm-linux-gnueabihf
– ARCHITECTURE cortex-a53
– ROMFSROOT px4fmu_common
– TESTING y
– PX4 config: px4_raspberrypi_default
– PX4 platform: posix
– PX4 lockstep: disabled
– cmake build type: RelWithDebInfo
– The CXX compiler identification is GNU 8.4.0
– The C compiler identification is GNU 8.4.0
– The ASM compiler identification is GNU
– Found assembler: /usr/bin/arm-linux-gnueabihf-gcc
– Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
– Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc
– Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Building for code coverage
– ccache enabled (export CCACHE_DISABLE=1 to disable)
– ROMFS: ROMFS/px4fmu_common
– Configuring done
– Generating done
– Build files have been written to: /home/lqs66/Desktop/px4-1.13.0/build/px4_raspberrypi_default_clang

The version of python3 in ubuntu 18.04 is 3.6, and the execution of “bash ubuntu.sh --no-nuttx --no-sim-tools” will cause problems with the version of python3, so I chose ubuntu 20.04.
follow https://docs.px4.io/v1.14/en/dev_setup/dev_env_linux_ubuntu.html#clang-optional I try to clang cross-compile RasPi with v1.14 of px4.

I found a very strange phenomenon.
After the first execution of “cmake -G "Unix Makefiles" -DCONFIG=px4_raspberrypi_default -UCMAKE_C_COMPILER -DCMAKE_C_COMPILER=clang -UCMAKE_CXX_ COMPILER -DCMAKE_CXX_COMPILER=clang++ ... /...” The gcc cross-compiler is still used.

– PX4 version: v1.14.0 (1.14.0)
– Found PythonInterp: /usr/bin/python3 (found suitable version “3.8.10”, minimum required is “3”)
– PX4 config file: /home/lqs66/桌面/px4-1.14.0/boards/px4/raspberrypi/default.px4board
– PLATFORM posix
– LINUX_TARGET y
– TOOLCHAIN arm-linux-gnueabihf
– ARCHITECTURE cortex-a53
– ROMFSROOT px4fmu_common
– ROOTFSDIR .
– TESTING y
– PX4 config: px4_raspberrypi_default
– PX4 platform: posix
– PX4 lockstep: disabled
– The CXX compiler identification is GNU 8.4.0
– The C compiler identification is GNU 8.4.0
– The ASM compiler identification is GNU
– Found assembler: /usr/lib/ccache/arm-linux-gnueabihf-gcc
– Check for working CXX compiler: /usr/lib/ccache/arm-linux-gnueabihf-g++
– Check for working CXX compiler: /usr/lib/ccache/arm-linux-gnueabihf-g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Check for working C compiler: /usr/lib/ccache/arm-linux-gnueabihf-gcc
– Check for working C compiler: /usr/lib/ccache/arm-linux-gnueabihf-gcc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– cmake build type: RelWithDebInfo
– ccache enabled via symlink (/usr/lib/ccache/arm-linux-gnueabihf-g++ → /usr/bin/ccache)
– Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
– ROMFS: ROMFS/px4fmu_common
Architecture: amd64
==> CPACK_INSTALL_PREFIX = @DEB_INSTALL_PREFIX@
– Configuring done
– Generating done

If I don’t run make at this point and choose to re-run “cmake -G “Unix Makefiles” -DCONFIG=px4_raspberrypi_default -UCMAKE_C_COMPILER -DCMAKE_C_COMPILER=clang -UCMAKE_CXX_COMPILER -DCMAKE_CXX_COMPILER=clang++ …”. /…" The clang cross-compiler is configured correctly, but when I run make I get an error.

– PX4 version: v1.14.0 (1.14.0)
– PX4 config file: /home/lqs66/桌面/px4-1.14.0/boards/px4/raspberrypi/default.px4board
– PLATFORM posix
– LINUX_TARGET y
– TOOLCHAIN arm-linux-gnueabihf
– ARCHITECTURE cortex-a53
– ROMFSROOT px4fmu_common
– ROOTFSDIR .
– TESTING y
– PX4 config: px4_raspberrypi_default
– PX4 platform: posix
– PX4 lockstep: disabled
– cmake build type: RelWithDebInfo
– Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
– ROMFS: ROMFS/px4fmu_common
Architecture: amd64
==> CPACK_INSTALL_PREFIX = @DEB_INSTALL_PREFIX@
– 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_CXX_COMPILER= clang++
CMAKE_C_COMPILER= clang

– PX4 version: v1.14.0 (1.14.0)
– Found PythonInterp: /usr/bin/python3 (found suitable version “3.8.10”, minimum required is “3”)
– PX4 config file: /home/lqs66/桌面/px4-1.14.0/boards/px4/sitl/default.px4board
– PLATFORM posix
– ROMFSROOT px4fmu_common
– ROOTFSDIR .
– TESTING y
– ETHERNET y
– PX4 config: px4_sitl_default
– PX4 platform: posix
– PX4 lockstep: enabled
– The CXX compiler identification is Clang 10.0.0
– The C compiler identification is Clang 10.0.0
– The ASM compiler identification is Clang
– Found assembler: /usr/lib/ccache/clang
– Check for working CXX compiler: /usr/lib/ccache/clang++
– Check for working CXX compiler: /usr/lib/ccache/clang++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Check for working C compiler: /usr/lib/ccache/clang
– Check for working C compiler: /usr/lib/ccache/clang – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– cmake build type: RelWithDebInfo
– ccache enabled via symlink (/usr/lib/ccache/clang++ → /usr/bin/ccache)
– Could NOT find gz-transport (missing: gz-transport_DIR)
– Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
– ROMFS: ROMFS/px4fmu_common
Architecture: amd64
==> CPACK_INSTALL_PREFIX = @DEB_INSTALL_PREFIX@
– Configuring done
– Generating done
– Build files have been written to: /home/lqs66/桌面/px4-1.14.0/build/raspi

[ 10%] Performing install step for ‘libmicroxrceddsclient_project’
– libmicroxrceddsclient_project install command succeeded. See also /home/lqs66/桌面/px4-1.14.0/build/raspi/src/modules/uxrce_dds_client/src/libmicroxrceddsclient_project-stamp/libmicroxrceddsclient_project-install-*.log
[ 10%] Completed ‘libmicroxrceddsclient_project’
[ 10%] Built target libmicroxrceddsclient_project
Scanning dependencies of target parameters_xml
[ 11%] Built target parameters_xml
Scanning dependencies of target ver_gen
[ 11%] Generating git version header
[ 11%] Built target ver_gen
Scanning dependencies of target events_json
make[2]: *** No rule to make target “src/modules/uxrce_dds_client/dds_topics.h”, by “events/px4.json”. Requirements. Stop.
make[1]: *** [CMakeFiles/Makefile2:11604: src/lib/events/CMakeFiles/events_json.dir/all] error 2
make: *** [Makefile:152: all] error 2