micro-ROS / micro_ros_stm32cubemx_utils

A set of utilities for integrating micro-ROS in a STM32CubeMX project
Apache License 2.0
137 stars 56 forks source link

Building library with optimization #137

Open Dmivaka opened 4 months ago

Dmivaka commented 4 months ago

Hi! I'm trying to build libmicroros.a with enabled optimization (-O3) for use with STM32CubeIDE. I didn't understand how to properly pass desired flag into the build environment, so I modified extract_flags.py instead:

    if len(optimization):
        out = out + " " + "-O3"

-O3 flag shows in the building log (with unmodified extract_flags.py there's -O0). Build finishes successfully, but the libmicroros.a size is exactly the same as for the unoptimized build. So the question is how to properly build the library with the optimization enabled. Thanks!

pablogs9 commented 4 months ago

Add the optimization flags to the cross compilation toolchain: https://github.com/micro-ROS/micro_ros_stm32cubemx_utils/blob/iron/microros_static_library/library_generation/toolchain.cmake