Closed michal-narajowski closed 4 years ago
Explanation of problem is strange. Can you add example of one line that was generated before and after the fix in CMakeLists.txt Maybe also version of cmake used. And line that fails without fix with
set(CMAKE_VERBOSE_MAKEFILE ON)
This is a cmake issue probably as I can see this in compile_commands.json
produced by cmake.
cmake version 3.16.3
Diff on the command:
185c185,186
< -mthumb-interwork-DAPP_NAME=bleprph_memfault
---
> -mthumb-interwork
> -DAPP_NAME=bleprph_memfault
Before:
set_property(SOURCE repos/apache-mynewt-core/sys/memfault/ext/components/core/src/arch_arm_cortex_m.c APPEND_STRING
PROPERTY
COMPILE_FLAGS
"-DAPP_NAME=bleprph_memfault -DAPP_bleprph_memfault -DARCH_NAME=cortex_m4 -DARCH_cortex_m4 -DBSP_NAME=nordic_pca10056 -DBSP_nordic_pca10056 -DMEMFAULT_TRACE_REASON_USER_DEFS_FILE=\\\"memfault_trace_reason_user_config.def\\\" -DMYNEWT=1 -DNRF52840_XXAA -DSTATS_NAME_ENABLE -Og -Wall -Werror -fdata-sections -ffunction-sections -fno-common -fno-exceptions -ggdb -mcpu=cortex-m4 -mthumb -mthumb-interwork")
After:
set_property(SOURCE repos/apache-mynewt-core/sys/memfault/ext/components/core/src/arch_arm_cortex_m.c APPEND_STRING
PROPERTY
COMPILE_FLAGS
" -DAPP_NAME=bleprph_memfault -DAPP_bleprph_memfault -DARCH_NAME=cortex_m4 -DARCH_cortex_m4 -DBSP_NAME=nordic_pca10056 -DBSP_nordic_pca10056 -DMEMFAULT_TRACE_REASON_USER_DEFS_FILE=\\\"memfault_trace_reason_user_config.def\\\" -DMYNEWT=1 -DNRF52840_XXAA -DSTATS_NAME_ENABLE -Og -Wall -Werror -fdata-sections -ffunction-sections -fno-common -fno-exceptions -ggdb -mcpu=cortex-m4 -mthumb -mthumb-interwork")
Closing, as this is not the real cause. In reality this issue was caused by duplicated lines in CMakeLists.txt for the same files. CMake would then merge these lines and generate concatenated flags. Duplicates were not the fault of newt
but rather a duplicate line in pkg.yml
configuration in pkg.src_dirs
.
Thanks @kasjer for being vigilant!
By some recent change in gcc or cmake the compilation flags for sources defined in CMakeLists.txt would get reordered in a way that the first -D flag would come after the last -m flag. As a result we would get a gcc error "Unrecognized command line argument: -mthumb-interwork-DAPP_NAME="
Adding space before the first flag in CMakeLists.txt file fixes the problem.