-
Notifications
You must be signed in to change notification settings - Fork 3k
NEW TOOLCHAIN: Add the ARMC6 compiler #4905
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
fdae641
to
6de4878
Compare
rtos/mbed_boot.c
Outdated
@@ -232,7 +232,7 @@ osMutexAttr_t singleton_mutex_attr; | |||
#if !defined(HEAP_START) | |||
#if defined(__ICCARM__) | |||
#error "Heap should already be defined for IAR" | |||
#elif defined(__CC_ARM) | |||
#elif defined(__CC_ARM) || defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
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.
You might consider wrapping defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
in parentheses as is done below.
@@ -400,7 +400,14 @@ void pre_main (void) | |||
With the RTOS there is not only one stack above the heap, there are multiple | |||
stacks and some of them are underneath the heap pointer. | |||
*/ | |||
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) | |||
__asm(".global __use_two_region_memory\n\t"); | |||
__asm(".global __use_no_semihosting\n\t"); |
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.
Does the ARMCC reference manual recommend setting __use_two_region_memory
and __use_no_semihosting
using this syntax? Its a bit odd seeing inline assembly outside the body of a function.
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.
rtos/rtx5/TARGET_CORTEX_M/rtx_lib.c
Outdated
@@ -595,7 +595,6 @@ void *__user_perthread_libspace (void) { | |||
typedef void *mutex; | |||
|
|||
// Initialize mutex | |||
__USED |
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.
Why was __USED
removed for _mutex_initialize only and not the other functions like _mutex_free?
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.
I think that has to be reverted, I remember linker was removing these symbols for some reason.
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.
When that was in, it was conflicting with our define. We should look into why Used + Weak was not working correctly.
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.
When I revert this change, I get the following linker error:
Error: L6200E: Symbol _mutex_initialize multiply defined (by rtx_lib.o and mbed_boot.o).
It looks like __USED
beats __WEAK
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.
@0xc0170 I think you fixed issues with the tests with ops (malloc?) not being thread safe due to these symbols being stripped out?
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.
Looking through CMSIS RTX 5 source, it looks like we added the weak.
@@ -58,7 +58,7 @@ void __assert_func(const char *file, int line, const char *func, const char *fai | |||
void InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler) | |||
{ | |||
/* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */ | |||
#if defined(__CC_ARM) | |||
#if defined(__CC_ARM) || defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
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.
parentheses
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.
Is there any way we can simplify this?
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.
@bulislaw Not that I'm aware of
tools/memap.py
Outdated
@@ -770,7 +770,7 @@ def parse(self, mapfile, toolchain): | |||
self.list_dir_obj(os.path.abspath(mapfile)) | |||
|
|||
if toolchain == "ARM" or toolchain == "ARM_STD" or\ |
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.
nitpick - could you put this on one line with
if toolchain in ("ARM", "ARM_STD", "ARM_MICRO", "ARMC6"):
tools/profiles/debug.json
Outdated
"ARMC6": { | ||
"common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-g", "-O0"], | ||
"asm": [], | ||
"c": ["-D__ASSERT_MSG", "-fno-rtti", "-std=gnu99"], |
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.
Is -fno-rtti
a valid C option? I thought rtti was only for C++ classes.
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.
It does not seem to mind. I'll take it out
tools/profiles/develop.json
Outdated
@@ -23,6 +23,13 @@ | |||
"cxx": ["--cpp", "--no_rtti", "--no_vla"], | |||
"ld": [] | |||
}, | |||
"ARMC6": { | |||
"common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-g", "-O3", "-Os"], |
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.
Is it valid to have both -O3
and -Os
?
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.
That's how I read it. You can take a look here: https://developer.arm.com/docs/100066/latest/optimization/optimizing-for-code-size-or-performance
👍 for the description, some of the info might be part of the commit message (I assume you will add more there once you rebase)
@studavekar Please confirm as soon as ARMC6 is installed in our CI to test this PR (for those targets it supports at least , for now would be k64f) |
6de4878
to
d16491f
Compare
@0xc0170 Detailed design description added to first commit message. squashed fix commits into Enable K64F commit. |
d16491f
to
eba0012
Compare
@0xc0170 That second rebase was to re-flow the text of the commit message. |
f86bb08
to
b25d713
Compare
@c1728p9 I rebased again to address all of the comments that I could right now. |
@c1728p9 Dependency parsing is up. |
803354f
to
2837f6f
Compare
Some numbers:
|
GCC for comparison
|
This is a bit suspicious: Is the release profile optimizing for RAM at the expense of increasing Flash? |
9a69359
to
ab3cfac
Compare
Alrightly, I rebased, squashing like changes, and splitting unlike changes. Should still build (I have a super cool CI like thing running in the background of my rebase) and the commit history should make more sense now. |
ab3cfac
to
4bbbbc8
Compare
@@ -595,7 +595,9 @@ void *__user_perthread_libspace (void) { | |||
typedef void *mutex; | |||
|
|||
// Initialize mutex | |||
#if !defined(__ARMCC_VERSION) || __ARMCC_VERSION < 6010050 |
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.
I've asked in ARM-software/CMSIS_5#213 (comment) whether CMSIS guys have some better way of doing that.
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.
Thanks @bulislaw. It looks like they're staying until the CMSIS guys can find a better solution.
FYI, another rebase coming. I'm going to try REPLACING ARMC5 with ARMC6. I think it will yield a much simpler implementation. |
While ARMC6 does use the same linker (armlink) as ARM Compiler 5, it is not compatible. The reason for this incompatibility are twofold: * armlink may invoke the C preprocessor by adding a shebang (`#!`) to the top of their input files. * ARMC6 and ARMC5 differ in how you invoke the preprocessor: * ARMC5: `#! armcc -E` * ARMC6: `#! armclang -E` This does not yet handle dependencies properly
4bbbbc8
to
ae8e7df
Compare
Closing this version of the PR, as the alternate implementation in #4949 Is better in most ways. |
Description
This PR adds a new compiler to mbed OS: ARM Compiler 6 or armclang. This compiler
uses LLVM and CLang as the front end to an ARM proprietary optimization and code
generation layer. ARMC6 supports the new ARMv8M, ARMv8R and ARMv8A architectures.
Design notes
You may notice, when reviewing the code, that the ARMC6 toolchain class does not
inherit from the ARM toolchain class. This is intentional. While ARMC6 does use
the same linker (armlink) and assembler (armasm) as ARM Compiler 5, it is not
compatible.
The reason for this incompatibility are twofold:
and armasmmay invoke the C preprocessor by adding a shebang (#!
) tothe top of their input files.
#! armcc -E
#! armclang -E
When a toolchain inherits from another, each of their class names become
converted a
TOOLCHAIN_<name>
define and the resource scanner will pick upfiles within directories of the same name. If ARMC6 were to inherit from the
ARM base class, it would pick up the arm assembler and linker files, which
contain a possibly incorrect preprocessor invocation. The correctness of the
preprocesssor invocation depends on if you have ARM Compiler 5 installed. This
is generally a Bad Thing.
Therefore, I elected to force the semi-duplication ofthese files to guarantee that the invocation is correct for each toolchain.
I have made a new partial Toolchain implementation for ARMASM, and created
a pair of
Current limitations
Presently, the tools are not creating or processing dependency files for ARMC6.This can make development with it a headache. I consider this an essentialfeature of a toolchain and will be updating this PR to include it.Done.Also, The output of ARMC6 is not filtered in any way to generate the short
version of each warning or error. This makes development with ARMC6 a little
verbose. I consider this a nonessential feature and will submit another PR to
include output processing unless someone convinces me otherwise.
Further, ARMC6 is not supported by the small build profile. This was an unintentionalDone.omission, and I will correct it in this PR.
This PR only adds K64F support for ARMC6. I think that other devices should be
supported with subsequent PRs, so I'm not going to add support in this PR.
There is no exporter for Uvision + ARMC6. I think this is also out of scope and
should come as a separate PR.
TODO