Skip to content

uARM: Fix deprecate warning printing wrongly for GCC_ARM/IAR toolchain build #12198

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

Merged
merged 4 commits into from
Jan 16, 2020

Conversation

rajkan01
Copy link
Contributor

@rajkan01 rajkan01 commented Jan 7, 2020

Summary of changes

Mbed OS build tool is wrongly printing uARM toolchain deprecation warning when building with GCC_ARM toolchain, so added the toolchain check before appending warning message.

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@evedon @hugueskamba


@rajkan01 rajkan01 force-pushed the bug_fix_uARM_depreciate branch from 0619941 to 0c9d8b2 Compare January 7, 2020 15:25
@ciarmcom ciarmcom requested review from evedon, hugueskamba and a team January 7, 2020 16:00
@ciarmcom
Copy link
Member

ciarmcom commented Jan 7, 2020

@rajkan01, thank you for your changes.
@hugueskamba @evedon @ARMmbed/mbed-os-tools @ARMmbed/mbed-os-maintainers please review.

@rajkan01 rajkan01 changed the title uARM: Fix depreciate warning printing wrongly for other toolchains uARM: Fix deprecate warning printing wrongly for other toolchains Jan 7, 2020
@rajkan01 rajkan01 force-pushed the bug_fix_uARM_depreciate branch from 0c9d8b2 to de3c737 Compare January 7, 2020 16:03
@rajkan01 rajkan01 changed the title uARM: Fix deprecate warning printing wrongly for other toolchains uARM: Fix deprecate warning printing wrongly for GCC_ARM/IAR toolchain build Jan 7, 2020
@0xc0170 0xc0170 added the release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 label Jan 8, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 8, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Jan 8, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 8, 2020

@ARMmbed/mbed-os-tools Please review. If approved, this is ready for integration

@0xc0170 0xc0170 removed the release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 label Jan 10, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 13, 2020

@ARMmbed/mbed-os-tools Please review. If approved, this is ready for integration

Quick review here 👍

end_warnings.append(UARM_TOOLCHAIN_WARNING)
if toolchain_name == "uARM":
end_warnings.append(UARM_TOOLCHAIN_WARNING)
elif toolchain_name == "ARMC6" and target.default_toolchain == "uARM":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you checking for target.default_toolchain?
Also isn't there an opportunity do so something like:

if (
    toolchain_name in ["uARM", "ARMC5", "ARMC6"]
    and target.default_toolchain == "uARM"
):
    end_warnings.append(UARM_TOOLCHAIN_WARNING)

(check if the syntax is correct)

Copy link
Contributor

Choose a reason for hiding this comment

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

For me, this logic has become too complex to maintain. Please can you take the opportunity to refactor this into a sequence of 'if' statements at the same level, rather than the current complex arrangement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why are you checking for target.default_toolchain?
Also isn't there an opportunity do so something like:
if (
toolchain_name in ["uARM", "ARMC5", "ARMC6"]
and target.default_toolchain == "uARM"
):
end_warnings.append(UARM_TOOLCHAIN_WARNING)

(check if the syntax is correct)

The reason for checking target.default_toolchain is, if the target tries to build with ARM(ARMC5 or ARMC6) toolchain but the target.default_toolchain is configured to uARM then internally build tool use ARM with Small library.

So code snapshot will not work for all the target, such as LPC11C24 has uARM in the supported_toolchain but there is no target.default_toolchain.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks.
Please refactor the code to avoid repetitions and add comment where an explanation is needed.

end_warnings.append(UARM_TOOLCHAIN_WARNING)
if toolchain_name == "uARM":
end_warnings.append(UARM_TOOLCHAIN_WARNING)
elif toolchain_name == "ARMC6" and target.default_toolchain == "uARM":
Copy link
Contributor

Choose a reason for hiding this comment

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

For me, this logic has become too complex to maintain. Please can you take the opportunity to refactor this into a sequence of 'if' statements at the same level, rather than the current complex arrangement.

@@ -44,6 +44,13 @@
"please visit https://os.mbed.com/docs/mbed-os/latest/reference/using-small-c-libraries.html"
)

UARM_DEFAULT_TOOLCHAIN_WARNING = (
"Warning: We noticed that this target default_toolchain overrides --toolchain option with uARM Toolchain. "
"We are deprecating the use of uARM Toolchain. "
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"We are deprecating the use of uARM Toolchain. "
"We are deprecating the use of the uARM Toolchain. "

@@ -44,6 +44,13 @@
"please visit https://os.mbed.com/docs/mbed-os/latest/reference/using-small-c-libraries.html"
)

UARM_DEFAULT_TOOLCHAIN_WARNING = (
"Warning: We noticed that this target default_toolchain overrides --toolchain option with uARM Toolchain. "
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Warning: We noticed that this target default_toolchain overrides --toolchain option with uARM Toolchain. "
"Warning: We noticed that this target overrides default_toolchain with the uARM Toolchain (using --toolchain). "

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 15, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Jan 15, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@0xc0170 0xc0170 added the release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0 label Jan 15, 2020
"Warning: We noticed that you are using uARM Toolchain. "
"We are deprecating the use of uARM Toolchain. "
"Warning: We noticed that you are using uARM Toolchain either via --toolchain command line or default_toolchain option. "
"We are deprecating the use of the uARM Toolchain. "
"For more information on how to use the ARM toolchain with small C libraries, "
"please visit https://os.mbed.com/docs/mbed-os/latest/reference/using-small-c-libraries.html"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happened to UARM_DEFAULT_TOOLCHAIN_WARNING that you had before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have combined into existing UARM_TOOLCHAIN_WARNING

if not TOOLCHAIN_CLASSES[internal_tc_name].check_executable():
search_path = TOOLCHAIN_PATHS[internal_tc_name] or "No path set"
last_error = (
"Could not find executable for {}.\n"
"Currently set search path: {}"
).format(toolchain_name, search_path)
else:
if toolchain_name == "uARM" or target.default_toolchain == "uARM":
end_warnings.append(UARM_TOOLCHAIN_WARNING)
if toolchain_name in ["uARM", "ARMC5", "ARMC6"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use elif (condition): pass instead of else: if (condition): pass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is, it will fail for GCC_ARM

Copy link
Collaborator

Choose a reason for hiding this comment

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

It will not fail. It will work the exact same way. It is weird to have else and and single if.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

until if toolchain_name in ["uARM", "ARMC5", "ARMC6", "GCC_ARM"]:, it will not work when I combined as if with else.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was confused. I know understand that line 244 is only applicable to line 247 (To prevent adding the warning if a target has target.default_toolchain set to uARM even if say the GCC_ARM toolchain is used).
Perhaps line 244 should be moved to above 247 to be clear.

if toolchain_name == "uARM" or target.default_toolchain == "uARM":
end_warnings.append(UARM_TOOLCHAIN_WARNING)
if toolchain_name in ["uARM", "ARMC5", "ARMC6"]:
if toolchain_name == "ARMC5":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the following more readable?

elif toolchain_name in ["uARM", "ARMC5", "ARMC6"]:
    (end_warnings.append(ARMC5_MIGRATION_WARNING) if toolchain_name == "ARMC5")
    (end_warnings.append(UARM_TOOLCHAIN_WARNING) if "uARM" in {toolchain_name, target.default_toolchain})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bit difficult to readable "pass" followed if(condition)

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can at least do:
if "uARM" in {toolchain_name, target.default_toolchain}:

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 15, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Jan 15, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

Copy link
Collaborator

@hugueskamba hugueskamba left a comment

Choose a reason for hiding this comment

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

LGTM

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 16, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Jan 16, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 4
Build artifacts

@0xc0170 0xc0170 removed the needs: CI label Jan 16, 2020
@0xc0170 0xc0170 merged commit cbaa9bd into ARMmbed:master Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants