diff options
-rw-r--r-- | cmake/toolchain-armv7m.cmake | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cmake/toolchain-armv7m.cmake b/cmake/toolchain-armv7m.cmake new file mode 100644 index 0000000000..641b0debf2 --- /dev/null +++ b/cmake/toolchain-armv7m.cmake @@ -0,0 +1,38 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(PREFIX armv7m-cros-eabi-) +set(CMAKE_SYSROOT /usr/armv7m-cros-eabi/) + +set(CMAKE_C_COMPILER ${PREFIX}clang) +set(CMAKE_CXX_COMPILER ${PREFIX}clang++) +set(CMAKE_LINKER ${PREFIX}ld.lld) +set(CMAKE_AR ${PREFIX}ar) +set(CMAKE_NM ${PREFIX}nm) +set(CMAKE_OBJCOPY ${PREFIX}objcopy) +set(CMAKE_OBJDUMP ${PREFIX}objdump) +set(CMAKE_RANLIB ${PREFIX}ranlib) +set(CMAKE_READELF ${PREFIX}readelf) + +add_compile_options(-Oz) + +add_compile_options(-flto) +add_link_options(-flto) + +# TODO(b/234507656): Remove this include when clang is fixed. +add_compile_options(-I/usr/armv7m-cros-eabi/usr/include/c++/v1) +# TODO(b/254916723): Remove this define when clang is fixed. +add_compile_options(-D_GNU_SOURCE) +add_link_options(-lclang_rt.builtins-armv7m) +add_link_options(-lnosys) + +set(CMAKE_POSITION_INDEPENDENT_CODE OFF) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) |