From b631b68558104ce12972b2293e52ba543f91fc3f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 12 Aug 2022 14:49:51 +0000 Subject: [PATCH] Enable clang compiler and mold linker when cross compiling --- src/CMakeLists.txt | 3 +++ src/CMakeToolChainRPi.txt | 21 ++++++++++++++++----- src/control.cc | 1 - 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93b72c3..964af00 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,6 +68,9 @@ set (PNG_FILES project(vomp) add_executable(vomp ${VOMP_OBJ_COMMON} ${VOMP_OBJ_RASPBERRY} pngs.o) +# Enable next line to use mold linker. Only available when using clang +target_link_options(vomp PRIVATE "-fuse-ld=/opt/mold/bin/mold") + set(CMAKE_BUILD_TYPE Debug) target_compile_options(vomp PRIVATE -O0) diff --git a/src/CMakeToolChainRPi.txt b/src/CMakeToolChainRPi.txt index 48ee17e..d437ad9 100644 --- a/src/CMakeToolChainRPi.txt +++ b/src/CMakeToolChainRPi.txt @@ -1,13 +1,24 @@ set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc) -set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++) - set(CMAKE_FIND_ROOT_PATH /pi-root) set(CMAKE_SYSROOT /pi-root) -set(CMAKE_C_FLAGS "-Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenmp") -set(CMAKE_CXX_FLAGS "-Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenmp") + +# GCC +#set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc) +#set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++) +#set(CMAKE_C_FLAGS "-Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenmp") +#set(CMAKE_CXX_FLAGS "-Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenmp") + +# Pi1: -mtune=arm1176jzf-s Pi2: -mtune=cortex-a7 Pi3: -mtune=cortex-a53 + +# Clang +set(CMAKE_C_COMPILER /usr/bin/clang-11) +set(CMAKE_CXX_COMPILER /usr/bin/clang++-11) +set(CMAKE_LINKER /usr/bin/arm-linux-gnueabihf-ld) +set(CMAKE_C_FLAGS "-target arm-linux-gnueabihf -mfloat-abi=hard -mcpu=cortex-a7") +set(CMAKE_CXX_FLAGS "-target arm-linux-gnueabihf -mfloat-abi=hard -mcpu=cortex-a7") + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/src/control.cc b/src/control.cc index d413498..0efd720 100644 --- a/src/control.cc +++ b/src/control.cc @@ -247,7 +247,6 @@ bool Control::init(bool tcrashed) led = NULL; FALLTHROUGH case 10: - FALLTHROUGH ; } -- 2.39.5