Skip to content

NEW TOOLCHAIN: Add the ARMC6 Compiler #4949

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 25 commits into from
Sep 13, 2017

Conversation

theotherjimmy
Copy link
Contributor

@theotherjimmy theotherjimmy commented Aug 21, 2017

Description

This implementation shares much more code with ARMC5 and comes with an
exporter: make_armc6. This all comes at a cost though: I was required to
remove the CPP invocations from the top of all of the scatter files and
add them back dynamically,
I had to replace (or not) the scatter shebang dynamically, based on the toolchain being used.

Design Notes

This variant was designed to minimize the change set. In particular, I removed all of the #!s from the top of Arm Compiler scatter files, and I replace the shebangs at runtime (of the tools). This does impose a requirement that the tools must always be able to do this going forward, but they should (and will, soon) detect if a scatter file does not contain a preprocessor invocation or contains a compatible preprocessor invocation and use it directly without modification. This may lead to linker errors, but I hope that "command armcc not found" and "command armclang not found" will be descriptive enough to users.

Comparison to #4905

Advantages

  • Exporting is possible, and it even comes with a working uVision5 exporter (armc5 only) and make exporter pair (for both armc5 and armc6).
  • Coexistence of armc5 and armc6 code is allowed and supported
    • Migration can then be done on a single target, single MCU, family or vendor basis

Disadvantages

  • There is no longer a single Arm toolchain, which might confuse users.
  • The tools do a bit of "magic" by forcing all scatter files to be preprocessed. that corrects armc5 invocations to armc6 invocations and armc6 invocations to armc5 invocations.

TODO:

  • Write section detailing this new toolchain in the Handbook
  • Add ARMC6 to the CI
  • Run nightly test to verify my implementation of ARMC6
  • Process dependency information for ARM6
  • Add small profile
  • Small error/warning messages
  • Test skip detection

@theotherjimmy
Copy link
Contributor Author

Note this is an alternate implementation for #4905

@theotherjimmy theotherjimmy changed the title NEW TOOLCHAIN: ARMC6, alternate implementation NEW TOOLCHAIN: Add the ARMC6 Compiler, alternate implementation Aug 21, 2017

if mem_map:
args.extend(["--scatter", mem_map])
def make_real_scatter(self, scatter_file):
Copy link
Contributor

Choose a reason for hiding this comment

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

What about leaving the shebang in as is for ARMC5 so all the linker script stay as they are and have make_real_scatter replace the ARMC5 shebang with the ARMC6 shebang only when building for ARMC6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great! I'll do it first thing tomorrow.

from tools.toolchains.gcc import GCC_ARM
from tools.toolchains.iar import IAR

TOOLCHAIN_CLASSES = {
'ARM': ARM_STD,
'uARM': ARM_MICRO,
'ARMC6': ARMC6,
Copy link
Contributor

Choose a reason for hiding this comment

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

are we removing uARM ,because ARM_MICRO class is still defined ? Is this breaking change or what is the intention here? or I have missed something - most probably

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not mean to do that. Rebase coming anyway. I'll remove that change.

@@ -14,6 +14,13 @@
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
"-Wl,-n"]
},
"ARMC6": {
"common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz", "-DNDEBUG", "-flto"],
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this duplicate flto as it is also defined in the ld ?

Curious about choosing - Oz for the release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. ld flags are not taken from common.

-Oz is for minimizing the size. That's what the release profile does. It used to be called small after all.

@theotherjimmy theotherjimmy force-pushed the feature-armc5+armc6 branch 2 times, most recently from d3591e7 to 6a50eb2 Compare August 22, 2017 14:17
@theotherjimmy
Copy link
Contributor Author

@c1728p9 @0xc0170 I think I have addressed all of your comments. Please take another look.

@@ -600,7 +600,7 @@
"K64F": {
"supported_form_factors": ["ARDUINO"],
"core": "Cortex-M4F",
"supported_toolchains": ["ARM", "GCC_ARM", "IAR"],
"supported_toolchains": ["ARM", "GCC_ARM", "IAR", "ARMC6"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drop this change.


TOOLCHAIN_PATHS = {
'ARM': ARM_PATH,
'uARM': ARM_PATH,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix.

@theotherjimmy
Copy link
Contributor Author

I closed the other implementation, so I'm changing the title and removing the dupe label.

@theotherjimmy theotherjimmy changed the title NEW TOOLCHAIN: Add the ARMC6 Compiler, alternate implementation NEW TOOLCHAIN: Add the ARMC6 Compiler Aug 24, 2017
@@ -122,4 +122,4 @@ LR_m_text m_interrupts_start m_text_start+m_text_size-m_interrupts_start { ; l
}
RW_IRAM1 ImageLimit(RW_m_data_2) { ; Heap region growing up
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick - this file doesn't need to be modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. I'll rebase that out.

"""
with open(scatter_file, "rb") as input:
lines = input.readlines()
if (lines[0].startswith(self.SHEBANG) or
Copy link
Contributor

Choose a reason for hiding this comment

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

should the line be normalized before using this check? That way extra spaces won't cause this comparison to fail

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 comparison failing would not be that bad: it would just emit another linker script with the correct shebang. I'm not sure I want to make that check complicated, but you're right that it can be improved to reduce the frequency of emitting linker scripts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. I didn't realize there is no harm done if the comparison fails. I agree, it would be good to keep it simple like it is now.

@theotherjimmy
Copy link
Contributor Author

I need to update this PR to include support for all targets.

@theotherjimmy theotherjimmy force-pushed the feature-armc5+armc6 branch 5 times, most recently from 45c3dc8 to b7c1072 Compare August 29, 2017 22:16
@studavekar
Copy link
Contributor

studavekar commented Sep 11, 2017

@theotherjimmy armc6 looks good except for below 2

  1. for target REALTEK_RTL8195AM,toolchain ARMC6 there are long of warning : http://mbed-ci-master-2.austin.arm.com:8081/job/build_matrix/1138/target=REALTEK_RTL8195AM,toolchain=ARMC6/console

  2. KL46Z,NUCLEO_L073RZ fails http://mbed-ci-master-2.austin.arm.com:8081/job/build_matrix/1138/target=KL46Z,toolchain=ARMC6/consoleFull

00:00:44.012         [DEBUG] Output: ./TESTS/mbed_hal/flash/functional_tests/main.cpp:82:11: error: no flag-preserving variant of this instruction available
00:00:44.012         [DEBUG] Output:     "%=:\n\t"
00:00:44.013         [DEBUG] Output:           ^
00:00:44.013         [DEBUG] Output: <inline asm>:2:2: note: instantiated into assembly here
00:00:44.013         [DEBUG] Output:         SUB  r0, #1

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1283

Build failed!

@adbridge
Copy link
Contributor

/morph test

@adbridge
Copy link
Contributor

adbridge commented Sep 12, 2017

So I assume this is the outstanding Realtek error

[DEBUG] Output: /home/arm/mbed_jenkins/workspace/bm_wrap/1374/mbed-os/targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/rtl8195a_init.c:21:10: fatal error: 'cmsis_gcc.h' file not found
17:52:41         [DEBUG] Output: #include "cmsis_gcc.h"

In this file we have :

#if defined(__CC_ARM)
#include "cmsis_armcc.h"
#elif defined(__GNUC__)
#include "cmsis_gcc.h"
#else
#include <cmsis_iar.h>
#endif

So it looks like GNUC is being defined for ARMCC 6 ? Which is a bit weird in itself. Speaking to Bartek he says it should be including cmsis_armclang.h for ARMCC 6 so I think this needs to look like -

#if defined(__CC_ARM) 
#include "cmsis_armcc.h"
#elif (defined (__ARMCC_VERSION) && __ARMCC_VERSION >= 6010050)
#include "cmsis_armclang.h"
#elif defined(__GNUC__)
#include "cmsis_gcc.h"
#else
#include <cmsis_iar.h>
#endif

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1288

Build failed!

@studavekar
Copy link
Contributor

REALTEK_RTL8195AM,toolchain ARMC6 there are long of warning : http://mbed-ci-master-2.austin.arm.com:8081/job/build_matrix/1138/target=REALTEK_RTL8195AM,toolchain=ARMC6/console

Build time for REALTEK_RTL8195AM :

  • ARM 5 - 4 min
  • ARM 6 - 1 hr 27 min

The temp fix to this is reduce the verbosity of logs, caveat to reduced info in case of failure.

@theotherjimmy
Copy link
Contributor Author

So it looks like __GNUC__ is being defined for ARMCC 6 ?

Yep

@theotherjimmy
Copy link
Contributor Author

@adbridge Yes, that's the correct fix. Thanks for pushing it!

@adbridge
Copy link
Contributor

/morph test

1 similar comment
@studavekar
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1289

Build failed!

@studavekar
Copy link
Contributor

/morph test

@ARMmbed ARMmbed deleted a comment from mbed-bot Sep 12, 2017
@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1291

Example Build failed!

@studavekar
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1294

Example Build failed!

@studavekar
Copy link
Contributor

Run with ARM 6 build disabled since we have following issue to be resolved

  1. Build time for REALTEK device : NEW TOOLCHAIN: Add the ARMC6 Compiler #4949 (comment)
  2. NORDIC application are not build properly missing boot loader resulting in device fails to boot the firmware.

/morph test

@studavekar
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1298

All builds and test passed!

@adbridge
Copy link
Contributor

@studavekar Thanks for getting this through CI.

@adbridge adbridge merged commit 7b42891 into ARMmbed:master Sep 13, 2017
@theotherjimmy theotherjimmy deleted the feature-armc5+armc6 branch September 13, 2017 14:02
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.

9 participants