Skip to content

cmake: Fix compilation options for kobject_hash*.c #84636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

bjorniuppsala
Copy link
Contributor

Rework how the compilation-options for the gperf generated kobject_hash*.c files are put together to fix problems with SHELL: and cmake-list separators handling.

zephyr_get_compile_options_for_lang_as_string() returns the set of options as a cmake generator expression string which is cumbersome to edit. This caused the command line for the IAR toolchain to have broken SHELL: entries, and other some command line entries being postfixed by
"gnu".

This also adds CMake compiler properties for no_function_sections and no_data_sections options

@bjorniuppsala bjorniuppsala force-pushed the iar-BB-kobject-hash-compilation-arguments branch 3 times, most recently from 8113dd3 to 31d43a6 Compare January 28, 2025 13:52
@bjorniuppsala bjorniuppsala marked this pull request as draft January 29, 2025 12:01
@bjorniuppsala bjorniuppsala force-pushed the iar-BB-kobject-hash-compilation-arguments branch from 9213954 to eb98dcb Compare January 29, 2025 15:35
@bjorniuppsala
Copy link
Contributor Author

This may seem similar to #84862 but is not the same.

This was an other use of zephyr_get_compiler_options_for_lang_as_string() than the others in teh repo, since this is actually feeding the options back into our own cmake machinery, hence this is best solved by just hitting the raw properties, (which has the added benefits of keeping all SHELL: and such).

@bjorniuppsala bjorniuppsala marked this pull request as ready for review January 29, 2025 15:46
tejlmand
tejlmand previously approved these changes Jan 30, 2025
Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

lgtm.

Some small nits observed, but nothing blocking.

@bjorniuppsala bjorniuppsala force-pushed the iar-BB-kobject-hash-compilation-arguments branch 3 times, most recently from 2b8eff3 to 888b9c0 Compare January 30, 2025 15:36
@bjorniuppsala
Copy link
Contributor Author

Is it possible to politely ask for input on this ?

Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

Minor nit.

For completeness, I propose to also add the function-sections and data-sections symbold, although that's already the default used in Zephyr.

@@ -210,3 +210,9 @@ set_compiler_property(PROPERTY warning_shadow_variables)

set_compiler_property(PROPERTY no_builtin -fno-builtin)
set_compiler_property(PROPERTY no_builtin_malloc -fno-builtin-malloc)

# Compiler flag for placing functions in their own sections:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is wrong, cause the no_function_sections prevents placing functions in their own sections.

# Compiler flag for placing functions in their own sections:
set_compiler_property(PROPERTY no_function_sections "-fno-function-sections")

# Compiler flag for placing variables in their own sections:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, remember to take no into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@bjorniuppsala
Copy link
Contributor Author

bjorniuppsala commented Feb 27, 2025

Minor nit.

For completeness, I propose to also add the function-sections and data-sections symbold, although that's already the default used in Zephyr.

I dont think it is worth adding it since noby is using it. There are many options that dont have this kind of completeness, is there any particular reason why these two deserves it ?

@bjorniuppsala bjorniuppsala force-pushed the iar-BB-kobject-hash-compilation-arguments branch 2 times, most recently from 81e5803 to d8ddd7c Compare February 27, 2025 14:54
Rework how the compilation-options for the gperf generated
kobject_hash*.c files are put together to fix problems with SHELL:
and cmake-list separators handling.

zephyr_get_compile_options_for_lang_as_string() returns the set of
options as a cmake generator expression string which is cumbersome to
edit. This caused the command line for the IAR toolchain to have broken
SHELL: entries, and other some command line entries being postfixed by
"gnu".

This also adds CMake compiler properties for no_function_sections and
no_data_sections options

Signed-off-by: Björn Bergman <[email protected]>
@bjorniuppsala bjorniuppsala force-pushed the iar-BB-kobject-hash-compilation-arguments branch from d8ddd7c to fb4955a Compare February 28, 2025 08:47
@tejlmand
Copy link
Collaborator

There are many options that dont have this kind of completeness, is there any particular reason why these two deserves it ?

Some of the others has the completeness in the sense that they are either default used if not specified or indirectly being set by specifying another flag.
Though i'm also sure there are some where the same proposal of adding the corresponding option would make sense for completeness.

But it was just a general proposal and thus not blocking for the review.

@bjorniuppsala
Copy link
Contributor Author

I would greatly appreciate further comments (or approvals) on this.

This is one of the things that hinders IAR-toolchain together with CONFIG_USERSPACE.

@57300 57300 removed their request for review April 1, 2025 18:59
@bjorniuppsala
Copy link
Contributor Author

More review input (and approval) would be greatly appreciated.

@nashif nashif merged commit bb797ab into zephyrproject-rtos:main May 31, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants