Skip to content

CMake cores: fix cpu/fpu flags #14196

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 5 commits into from
Feb 2, 2021
Merged

Conversation

0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented Jan 26, 2021

Summary of changes

Couple of cores did not have common flag --mcpu set. I also aligned fpu.

This one goes along with #14190 - both are needed to have both toolchains fixed for couple of cores.

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

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

Reviewers


Couple of cores did not have common flag `--mcpu` set
@0xc0170 0xc0170 requested a review from hugueskamba January 26, 2021 14:23
@0xc0170 0xc0170 changed the title CMake cores: fix cpu flag CMake cores: fix cpu flag for Gcc Arm Jan 26, 2021
@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Jan 26, 2021
@ciarmcom ciarmcom requested review from a team January 26, 2021 14:30
@ciarmcom
Copy link
Member

@0xc0170, thank you for your changes.
@ARMmbed/mbed-os-tools @ARMmbed/mbed-os-maintainers please review.

@@ -9,6 +9,7 @@ if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
"-mfpu=vfpv3"
"-mfloat-abi=hard"
"-mno-unaligned-access"
""-mcpu=cortex-a9""
Copy link
Contributor

Choose a reason for hiding this comment

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

Excessive quoting. Shouldn't this replace the -march=armv7-a?

Copy link
Contributor Author

@0xc0170 0xc0170 Jan 27, 2021

Choose a reason for hiding this comment

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

Good point, checked https://community.arm.com/developer/tools-software/tools/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu

On Arm, -mcpu combines -march and -mtune.4 On x86, -mcpu and -mtune are the same.5 .

-mcpu=X: On Arm, this flag is a combination of -march and -mtune. It simultaneously specifies the target architecture and optimizes for a given microarchitecture. On x86 this flag is a deprecated synonym for -mtune.

I'll remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for Gcc:
This specifies the name of the target ARM processor. GCC uses this name to derive the name of the target ARM architecture

@@ -8,6 +8,7 @@ if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
"-mfpu=fpv5-sp-d16"
"-mfloat-abi=softfp"
"-march=armv8-m.main"
"-mcpu=cortex-m33+nodsp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, this should be replacing the -march. That would possibly have been used due to older toolchains not knowing "cortex-m33". I assume that's valid with whatever we require now?

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 now (I also fixed dsp options as there were again errors between march or toolchains).

I realized we specified nodsp for M33 core but had march for FE parts enabled with dsp.
This fixes it.

M33F has no dsp. M33FE cores have dsp enabled.
@mergify mergify bot dismissed kjbracey’s stale review January 27, 2021 10:32

Pull request has been modified.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Jan 27, 2021

I added 2 commits, addressing march and dsp options.

@@ -7,11 +7,11 @@ if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
"-mthumb"
"-mfpu=fpv5-sp-d16"
"-mfloat-abi=softfp"
"-march=armv8-m.main+dsp"
"-mcpu=cortex-m33+dsp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is +dsp valid here? Maybe, but don't see it in the docs. They just say cortex-m33 DSP is assumed, and you can specify +nodsp. (Note we're also not specifying +fp).

https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

-mcpu works differently to -march in this regard - you're always enabling extensions in -march, but usually disabling them in -mcpu.

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'll remove dsp from this one

)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
list(APPEND common_options
"-mcpu=cortex-m33"
"-mcpu=cortex-m33+dsp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Unlike for GCC, this is perfectly fine according to the docs, as +X and +noX are always available. But if you do want to say +dsp to be explicit, why not +fp too?

I would imagine ARMC6's defaults are the same as GCC's so might be best to keep it the same as GCC.

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, I only followed for now what we had (separate fpu settings for both toolchains). To keep both toolchains the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's not clear from docs how +fp/+nofp (or lack of and hence default) and -mfpu interact. Maybe don't mess with whatever we know/think works from original python stuff.

Move the fpu settings across all cores so they are aligned.
Some cores did not have fpu set for ARMClang. I matched here both toolchains to set up
the fpu the same (Only exception is soft vs hard - that is separate issue I would not like to touch
in this series).
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jan 27, 2021

I aligned fpu settings for all cores. I matched both toolchains. There still might be issues, please review.

@0xc0170 0xc0170 changed the title CMake cores: fix cpu flag for Gcc Arm CMake cores: fix cpu/fpu flags Jan 27, 2021
@0xc0170 0xc0170 requested a review from jeromecoutant January 27, 2021 13:20
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jan 27, 2021

@jeromecoutant I requested review as you also experienced issues with the core flags in CMake.

Copy link
Collaborator

@jeromecoutant jeromecoutant left a comment

Choose a reason for hiding this comment

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

I could verify with blinky application on:

  • NUCLEO_L552ZE_Q ("Cortex-M33FE")
  • NUCLEO_F767ZI ("Cortex-M7F")
  • NUCLEO_H743ZI2 ("Cortex-M7FD")
    Build and execution OK with ARM and GCC

@hugueskamba hugueskamba requested a review from kjbracey January 27, 2021 14:23
@mergify mergify bot added needs: CI and removed needs: work labels Jan 28, 2021
@ciarmcom
Copy link
Member

This pull request has automatically been marked as stale because it has had no recent activity. @ARMmbed/mbed-os-maintainers, please start CI to get the PR merged.

@ciarmcom ciarmcom added the stale Stale Pull Request label Jan 30, 2021
@0xc0170
Copy link
Contributor Author

0xc0170 commented Feb 2, 2021

Ci started

@mbed-ci
Copy link

mbed-ci commented Feb 2, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-test ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit 2e96400 into ARMmbed:master Feb 2, 2021
@mergify mergify bot removed the ready for merge label Feb 2, 2021
@LDong-Arm LDong-Arm requested a review from rajkan01 February 22, 2021 10:04
@0xc0170 0xc0170 deleted the fix-cores-gcc branch February 22, 2021 14:54
@mbedmain mbedmain removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants