Skip to content

Commit e8a3ee0

Browse files
committed
esp32/esp32_common.cmake: Add missing C flags to user C module sources.
On the esp32 port when adding a user C module, the source code for the user C module was being compiled without certain C flags. Notably the optimisation flag was missing. This commit fixes that by explicitly adding the missing C flags to the compilation of user C modules. The missing flags were the following, which are now included when building user C modules (found by inspecting the generated CMake files when building with ulab): -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-error=extra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -mdisable-hardware-atomics -O2 -fmacro-prefix-map=micropython/ports/esp32=. -fmacro-prefix-map=espressif/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion See related issue micropython#18880. Work done in collaboration with @andrewleech. Signed-off-by: Damien George <damien@micropython.org>
1 parent d41b8dc commit e8a3ee0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ports/esp32/esp32_common.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ target_compile_options(${MICROPY_TARGET} PUBLIC
277277
-Wno-missing-field-initializers
278278
)
279279
280+
# User C modules don't pick up certain compile options set by the IDF, most
281+
# importantly the optimisation level. So set them here.
282+
idf_build_get_property(idf_compile_options COMPILE_OPTIONS)
283+
target_compile_options(usermod INTERFACE ${idf_compile_options})
284+
280285
# Additional include directories needed for private NimBLE headers.
281286
target_include_directories(${MICROPY_TARGET} PUBLIC
282287
${IDF_PATH}/components/bt/host/nimble/nimble

0 commit comments

Comments
 (0)