fix(tflm): vendor third-party deps to enable reproducible builds

tflite-micro's Makefile fetches 5 third-party dependencies (flatbuffers,
kissfft, gemmlowp, ruy, pigweed, plus CMSIS/CMSIS-NN for ARM targets)
via wget and git clone at build time. This breaks reproducible builds:
the build output depends on GitHub and pigweed.googlesource.com being
reachable and serving the exact pinned archives, which is not guaranteed
and has broken in the past when GitHub silently regenerated archive zips.

Bump the tflite_micro submodule to the new px4/vendored-deps branch on
PX4/tflite-micro, which commits the deps directly under
tensorflow/lite/micro/tools/make/downloads/. Upstream's download scripts
already no-op with "already exists, skipping the download" when the
target directories are present, so no Makefile patches are needed.

Drop the add_custom_command, build_tflm_native target, and the empty
generate_cc_arrays.py shim from CMakeLists.txt. They existed solely to
drive the (now-removed) make third_party_downloads invocation and to
overwrite the submodule's generate_cc_arrays.py to keep that invocation
quiet. With the download step gone, none of that machinery is needed,
and the submodule stays clean after a build.

Verified builds against the new submodule:
- px4_sitl_neural (linux/amd64 devcontainer)
- mro_pixracerpro_neural (linux/amd64 devcontainer)
- px4_fmu-v6xrt_allyes (linux/amd64 and linux/arm64 devcontainers)

Fixes #27054

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
Ramon Roche 2026-04-11 07:57:07 -07:00
parent 0e31dd560d
commit 3e5e77490e
No known key found for this signature in database
GPG Key ID: 275988FAE5821713
3 changed files with 5 additions and 21 deletions

View File

@ -72,25 +72,9 @@ if(CONFIG_LIB_TFLM)
${TFLITE_DOWNLOADS_DIR}/cmsis
)
set(TFLM_BUILD_TIMESTAMP ${CMAKE_CURRENT_BINARY_DIR}/tflm_build_complete.timestamp)
add_custom_command(
OUTPUT ${TFLM_BUILD_TIMESTAMP}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/generate_cc_arrays.py
${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro/tensorflow/lite/micro/tools/generate_cc_arrays.py
# TODO maybe change this if building for other architectures
COMMAND make -f tensorflow/lite/micro/tools/make/Makefile MICRO_LITE_EXAMPLE_TESTS= MICRO_LITE_BENCHMARKS= MICRO_LITE_TEST_SRCS= MICRO_LITE_INTEGRATION_TESTS= third_party_downloads
# Create timestamp file to mark completion
COMMAND ${CMAKE_COMMAND} -E touch ${TFLM_BUILD_TIMESTAMP}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro
COMMENT "Downloading TFLM third party dependencies"
DEPENDS git_tflite-micro
VERBATIM
)
add_custom_target(build_tflm_native
DEPENDS ${TFLM_BUILD_TIMESTAMP}
)
# Third-party dependencies are vendored in the PX4/tflite-micro fork under
# tensorflow/lite/micro/tools/make/downloads/ so no network fetch is needed
# at build time. See the px4/vendored-deps branch for details.
px4_add_library(tensorflow_lite_micro ${TFLITE_MICRO_SRCS})
if(CONFIG_BOARD_TOOLCHAIN STREQUAL "arm-none-eabi")
@ -98,7 +82,7 @@ if(CONFIG_LIB_TFLM)
endif()
target_include_directories(tensorflow_lite_micro PUBLIC ${TFLM_INCLUDE_DIRS})
add_dependencies(tensorflow_lite_micro build_tflm_native)
add_dependencies(tensorflow_lite_micro git_tflite-micro)
target_compile_features(tensorflow_lite_micro PRIVATE cxx_std_17)
target_compile_options(tensorflow_lite_micro PUBLIC

@ -1 +1 @@
Subproject commit 3c0b1e3091e4ea423e1bf9da89d41d09517eb0c9
Subproject commit 6450e42a8adfba36fe5ade4ab66e9ecf59920dc4