Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:asm,required>

# @Intent: Enforce standard integer type correspondance to match Zephyr usage.
# (must be after compiler specific flags)
zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${ZEPHYR_BASE}/include/toolchain/zephyr_stdint.h")
if(NOT CONFIG_ARCH_POSIX)
# `zephyr_stdint.h` is not included for the POSIX (native) arch because it
# compiles with the host toolchain/headers and there can be conflicts if we
# arbitrarily redefine our own type system (see #37718).
zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${ZEPHYR_BASE}/include/toolchain/zephyr_stdint.h")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the comment above be inside the if ?

# @Intent: Enforce standard integer type correspondance to match Zephyr usage.
# (must be after compiler specific flags)

As I see it, that comment belongs with the zephyr_compile_options(...) call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that comment describes the following "code block" which includes the zephyr_compile_options inside if.

In this file, we seem to have multiple instances of the @Intent comment being placed similarly:

zephyr/CMakeLists.txt

Lines 109 to 112 in d7b5c3b

# @Intent: Set compiler flags to detect general stack overflows across all functions
if(CONFIG_STACK_CANARIES)
zephyr_compile_options($<TARGET_PROPERTY:compiler,security_canaries>)
endif()

zephyr/CMakeLists.txt

Lines 165 to 170 in d7b5c3b

# @Intent: Obtain compiler specific flags for compiling under different ISO standards of C++
if(CONFIG_CPLUSPLUS)
# From kconfig choice, pick a single dialect.
# Kconfig choice ensures only one of these CONFIG_STD_CPP* is set.
if(CONFIG_STD_CPP98)
set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp98>)

zephyr/CMakeLists.txt

Lines 282 to 286 in d7b5c3b

# @Intent: Add cmake -DW toolchain supported warnings, if any
if(W MATCHES "1")
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_dw_1>>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_1>>)
endif()

This is really just a style issue, so I will relocate that comment in this PR if you prefer it that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point.
But the other examples closely follows what they are testing, like:

  • general stack overflows comment follows if(CONFIG_STACK_CANARIES)
  • C++ comment follows the if(CONFIG_CPLUSPLUS)
  • -DW comment follows if(W MATCHES "1")

whereas this comment talks about enforcing standard integer types, so the relation from that comment to ARCH_POSIX is less obvious.

Maybe the best solution is to not move that comment, but instead update it, so that it is clear from the @Intent comment that it only applies for not native posix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but my main reason for original comment was to be sure it was forgotten by mistake, and based on your answer it seems to be on purpose.

endif()

# Common toolchain-agnostic assembly flags
zephyr_compile_options(
Expand Down