build: Avoid hard coding path to compiler
What changed, and why it matters
This commit is a build-system convenience change. It removes a fixed path to the ARM compiler (/usr/local/bin/arm-none-eabi-gcc) and instead lets the build find the compiler through the developer's PATH. It also auto-detects the compiler's target architecture and system root rather than hard-coding them. There is no security-relevant change to the firmware itself.
No security action required. Treat as ordinary build-system maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch changes CMake toolchain configuration for cross-compilation. arm.cmake no longer hard-codes TOOLCHAIN_PREFIX, CMAKE_C_COMPILER, or CMAKE_SYSROOT; it only sets CMAKE_C_COMPILER to ‘arm-none-eabi-gcc’ and relies on PATH resolution. CMakeLists.txt adds execute_process calls to derive TARGET_TRIPLE via -dumpmachine and CMAKE_SYSROOT via –print-sysroot, and updates find_program for size utility accordingly. These are build-environment ergonomics, not code behavior changes.
Changed components
CMakeLists.txtarm.cmakeInspect captured patch +18 / −6
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dc4b53..8a04df6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,11 +72,18 @@ message(FATAL_ERROR
)
endif()
+# Figure out what target our compiler builds for
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -dumpmachine
+ OUTPUT_VARIABLE TARGET_TRIPLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
# Finds objcopy and other utilities for us
include(CMakeFindBinUtils)
if(CMAKE_CROSSCOMPILING)
- find_program(CMAKE_SIZE "${TOOLCHAIN_PREFIX}size")
- message(STATUS "size: ${CMAKE_SIZE} ${TOOLCHAIN_PREFIX}size")
+ find_program(CMAKE_SIZE "${TARGET_TRIPLE}-size")
+ message(STATUS "size: ${CMAKE_SIZE} ${TARGET_TRIPLE}-size")
endif()
@@ -213,6 +220,12 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} --print-sysroot
+ OUTPUT_VARIABLE CMAKE_SYSROOT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
message(STATUS "\n\n=============================================")
message(STATUS " - General -")
message(STATUS "Firmware version: ${FIRMWARE_VERSION_FULL}")
@@ -225,6 +238,8 @@ message(STATUS "Processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS " - Build -")
message(STATUS "Compiler version: ${CMAKE_C_COMPILER_ID} ${C_COMPILER_VERSION}")
message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
+message(STATUS "Sysroot: ${CMAKE_SYSROOT}")
+message(STATUS "Target triple: ${TARGET_TRIPLE}")
message(STATUS "Compiler cache: ${CMAKE_C_COMPILER_LAUNCHER}")
message(STATUS "Linker: ${CMAKE_LINKER}")
message(STATUS "Archiver: ${CMAKE_AR}")
diff --git a/arm.cmake b/arm.cmake
index 338ad8a..6301002 100644
--- a/arm.cmake
+++ b/arm.cmake
@@ -1,10 +1,7 @@
set(CMAKE_SYSTEM_NAME "Generic")
set(CMAKE_SYSTEM_PROCESSOR "arm")
-set(TOOLCHAIN_PREFIX_PREFIX "arm-none-eabi")
-set(TOOLCHAIN_PREFIX "${TOOLCHAIN_PREFIX_PREFIX}-")
-set(CMAKE_C_COMPILER "/usr/local/bin/${TOOLCHAIN_PREFIX}gcc")
-set(CMAKE_SYSROOT "/usr/local/${TOOLCHAIN_PREFIX_PREFIX}")
+set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
# Search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.