Skip to content

Conversation

@stephanosio
Copy link
Member

The -Og (optimise for debugging) flag is only available for GCC 4.8.0
and above, and specifying it for a GCC version lower than 4.8.0 will
result in a compilation error.

This commit adds a run-time check for compiler -Og optimisation flag
support and a fallback to -O0 (disable optimisation) when -Og flag is
unsupported.

Signed-off-by: Stephanos Ioannidis [email protected]

@stephanosio stephanosio added area: Portability Standard compliant code, toolchain abstraction area: Toolchains Toolchains area: Build System labels Nov 12, 2019
Copy link
Contributor

@SebastianBoe SebastianBoe left a comment

Choose a reason for hiding this comment

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

gcc 4.8 was released 6 years ago.

Let's not add build overhead for all users due to a small amount of users having outdated toolchains.

Erroring-out as we are now doing when the user explicitly (OPTIMIZE_FOR_DEBUG_FLAG is not the default) enables a feature they can't have is a sane policy.

A user that is affected can either enable CONFIG_NO_OPTIMIZATIONS instead of CONFIG_DEBUG_OPTIMIZATIONS, or invoke CMake with -DOPTIMIZE_FOR_DEBUG_FLAG=-O0 .

And IMHO this is more than flexible enough.

@stephanosio
Copy link
Member Author

Let's not add build overhead for all users due to a small amount of users having outdated toolchains.

well, I just happened to be one of those users (I am stuck with an ancient toolchain because the vendor of this proprietary arch I am currently running Zephyr on refuses to release modern toolchain), but then I suppose check_compiler_flag is not free by any means.

@SebastianBoe If check_compiler_flag is too much of a burden, would you be okay with just a version check using CMAKE_C_COMPILER_VERSION because we know that GCC 4.8.0 is the first version to support -Og?

@SebastianBoe
Copy link
Contributor

A version check is OK.

The -Og (optimise for debugging) flag is only available for GCC 4.8.0
and above, and specifying it for a GCC version lower than 4.8.0 will
result in a compilation error.

This commit adds a check for compiler -Og optimisation flag support and
a fallback to -O0 (disable optimisation) when -Og flag is unsupported.

Signed-off-by: Stephanos Ioannidis <[email protected]>
@galak galak added this to the v2.2.0 milestone Nov 12, 2019
@ioannisg ioannisg merged commit cff94bf into zephyrproject-rtos:master Dec 9, 2019
@stephanosio stephanosio deleted the add_gcc_og_fallback branch April 23, 2020 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Build System area: Portability Standard compliant code, toolchain abstraction area: Toolchains Toolchains

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants