-
Notifications
You must be signed in to change notification settings - Fork 3k
Enable build with IAR when c_lib is set to small #12665
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
Enable build with IAR when c_lib is set to small #12665
Conversation
@hugueskamba, thank you for your changes. |
tools/toolchains/iar.py
Outdated
self.check_c_lib_supported(target, "iar") | ||
# Build with the standard C lib if c_lib is set to small as there | ||
# is no small lib for the IAR toolchain | ||
if target.c_lib.lower() != "small": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If c_lib
is set to "small" for IAR, we want to check that "std" is supported and if so revert to using standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
f4d874d
to
bc8aeb6
Compare
We should make this a generic feature.
|
tools/toolchains/iar.py
Outdated
# the value of the c_lib attribute is used to print a warning if std C lib | ||
# ends up being used instead of a small C lib as potentially requested. | ||
target_c_lib_check = copy.copy(target) | ||
if hasattr(target, "c_lib") and target.c_lib == "small": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use getattr() here to simplify this.
tools/build_api.py
Outdated
|
||
if ( | ||
toolchain_name == "IAR" | ||
and target.c_lib.lower() == "small" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since c_lib appears to be an optional attribute, need to use getattr() here to ensure that an exception is not thrown when it is not specified.
bc8aeb6
to
a9445c9
Compare
Pull request has been modified.
@@ -205,6 +210,27 @@ def get_toolchain_name(target, toolchain_name): | |||
|
|||
return toolchain_name | |||
|
|||
|
|||
def check_small_c_lib_support(target, toolchain_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two issues with this function: 1. The 'target' argument is potentially modified inside the function (ie the function has a side-effect that is not easily seen from outside). The name of the function 'check...' implies that it simply checks something. When the function is called, the user does not know that the target arg will be modified (without studying the internals of the function). This kind of thing is really hard to maintain in future. 2. The function mixes up the concepts of checking for some condition, and reporting on that condition. This makes it hard to test (and there are no tests for this). The reporting should be done by the caller IMO.
To fix this: return a boolean to indicate if the check passes or fails. Move the target modification and the error message formation up to the caller. Rename the function (suggest 'is_small_c_lib_supported' or something like that).
It might be that fixing these issues makes this whole function redundant (the code could be in-line since it is only called once anyway.
@@ -52,6 +52,11 @@ | |||
|
|||
RELEASE_VERSIONS = ['2', '5'] | |||
|
|||
SMALL_C_LIB_CHANGE_WARNING = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separating the message format from its arguments doesn't really make sense here. Since this is used only once, at the print, it makes more sense to put the text template there.
tools/build.py
Outdated
@@ -177,6 +178,10 @@ def main(): | |||
except NoValidToolchainException as e: | |||
print_end_warnings(e.end_warnings) | |||
args_error(parser, str(e)) | |||
|
|||
warning = check_small_c_lib_support(target, toolchain_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider not separating this out into a function - see below.
a9445c9
to
9e2d6c7
Compare
Pull request has been modified.
@hugueskamba Please do not force push, it makes it difficult to understand past comments without context. |
9e2d6c7
to
e38be3a
Compare
e38be3a
to
02bf3ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are may existing review comments that have been lost due to force-push. Please look again at the comments and reimplement accordingly.
The tests that were originally here have been removed. Please reinstate.
Closing this as the scope has changed. |
The following PR replaces the present PR: |
Summary of changes
If "c_lib" is set to "small" and "targets.supported_c_libs.iar" only has "std" it means that it is not possible to build with the IAR toolchain.
This commits modifies the tools to allow building with the IAR toolchain even when "small" is specified by reverting to the standard C library and displaying a message to warn that the standard library is used instead.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers
@evedon @rajkan01