-
Notifications
You must be signed in to change notification settings - Fork 3k
Tools: Include configuration in ASM #7061
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
@theotherjimmy Any idea why this failed ?
E AttributeError: 'NoneType' object has no attribute 'get_config_data' |
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 would like to see more similarity between the exporter and the toolchain implementation of the same thing.
tools/toolchains/iar.py
Outdated
@@ -154,8 +154,10 @@ def get_compile_options(self, defines, includes, for_asm=False): | |||
|
|||
@hook_tool | |||
def assemble(self, source, object, includes): | |||
_, macros = self.config.get_config_data() | |||
defines = ['-D%s' % d for d in macros] if macros else [""] |
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'm pretty sure this is the same as the result of self.get_compile_options(self.get_symbols(True), includes, True)
below, so the changes in this file are not needed.
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.
No, I tried this at first, but the macros from the mbed_app.json and mbed_lib.json files are not included in the set returned by self.get_compile_options(self.get_symbols(True), includes, True). If they are supposed to, then perhaps this is a bug?
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.
get_symbols
is a shared bit of infrastructure so we can eliminate any compiler differences caused by it. This leaves get_compile_options
arm: https://github.com/ARMmbed/mbed-os/blob/master/tools/toolchains/arm.py#L136-L139
gcc: https://github.com/ARMmbed/mbed-os/blob/master/tools/toolchains/gcc.py#L144-L155
They seem to disagree on whether or not to include the include paths, but they both treat the defines passed in the same.
This makes me think that the issue this is trying to fix will introduce an inconsistency between the assemblers. That's something we should avoid.
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'm happy to have it fixed globally in get_symbols(), if that is doable.
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 doable, and I think that's how it should be done.
tools/export/iar/__init__.py
Outdated
@@ -111,6 +111,8 @@ def generate(self): | |||
self.resources.c_sources + self.resources.cpp_sources + \ | |||
self.resources.objects + self.resources.libraries | |||
flags = self.flags | |||
_, macros = self.toolchain.config.get_config_data() | |||
defines = ['-D%s' % d for d in macros] if macros else [""] |
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 you do:
macros = self.toolchain.get_symbols(True)
defines = self.toolchain.get_compile_options(macros, self.resources.inc_dirs, True)
so that it exactly matches the code run in iar.assemble
?
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.
Same thing here, defines does not include the macros from mbed_app.json and mbed_lib.json with this.
@TTornblom Has any progress been made on this? |
No progress. |
Because it only applies to IAR, and not ARM or GCC_ARM. Would you like me to change this patch to apply to all 3? |
@theotherjimmy If that's OK with you, then by all means go ahead, I'd be happy to have this sorted out. |
@TTornblom Yeah. No problem. Let me get that right now. |
@TTornblom I'd like to point out that:
This is not true. ARM, GCC_ARM, and IAR all have the same behavior here: they include macros for the toolchian and target labels and don't include |
@TTornblom I think this is now consistant: all compilers use |
Note: |
Unfortunately the EWARM assembler is based on an older codebase and does not support —preinclude. That would have been my preferred solution too. My first attempt was to run the C preprocessor, which does support —preinclude, but it was just too complicated to get that to work in the IDE. |
@TTornblom Dang. Any chance that the assembler reference could be updated to remove that option? |
I'll come back to this on Monday, to see if I can work around this problem with a via file full of -D. |
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.
--preinclude
does not work in the EWARM assembler.
I can submit an RFE against the EWARM assembler, but it is not a quick fix that would solve this problem, especially as the Mbed tool chain is still based on 7.x. |
Removing it from the documentation would not fix the problem, but prevent others from encountering the not-supported option. |
@theotherjimmy Where did you find that the EWARM assembler supports --preinclude? Need to fix this documentantion issue. |
My mistake, that's the wrong assembler reference. The correct PDF does not claim that |
Yes, the RL78 assembler is based on a newer code base, which does support --preinclude. |
@TTornblom I got everything passing along as I wanted, with export getting the |
@TTornblom That's incorrect. Our CI reports IDE failures (can't find the project file after generation), and the Mbed CLI build works Unless you mean CLI to mean IAR CLI. CLI can be quite ambiguous. |
Yes, I mean the IAR CLI and the IAR IDE. The test I did yesterday was to import "mbed-os-example-blinky", and replacing mbed-os in that with what's on github. I added an mbed_app.json file with the following content to the root of the project: {
"macros": [
"MBED_FAULT_HANDLER_DISABLED"
]
} and then built it as: mbed compile -t IAR -m K64F and it failed linking as mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S was not compiled using the mbed_app.json file, so it referred to the undefined symbol "mbed_fault_context". I then exported the project to EWARM: mbed export -i IAR -m K64F and built the project using EWARM 7.80, which worked OK, with no link errors and no "mbed_fault_context" defined, so the mbed_app.json file was handled correctly. My conclusion is that the IAR CLI is not handling the mbed_app.json (and I guess mbed_lib.json) files correctly, but that the IAR IDE exporter does handle them correctly. |
@TTornblom I'm sorry but that clarification did not help my understanding of the issues at hand. That's also quite interesting, as it's exactly the opposite of what our CI is reporting. I just tried your |
Sorry, my bad. I had a setting in EWARM 7.80 left over from my earlier work on this that apparently allowed the project to be built. I set up a new project, without replacing mbed-os, and with the setting in EWARM removed, and both the IAR CLI and EWARM builds then fails with an undefined "mbed_fault_context". |
/morph export-build |
/morph build |
I think that'll do it. I escaped the macros. Maybe the parser was having a bad day with the other file. I can no longer reproduce the issue locally (with K64F + mesh-minimal export) |
Build : SUCCESSBuild number : 2649 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2282 |
/morph mbed2-build |
Restarting test, CI exception /morph test |
Test : SUCCESSBuild number : 2389 |
Postponing this since an old issue seems to have resurfaced with it: #4879 |
@@ -140,17 +140,26 @@ def get_config_option(self, config_header): | |||
|
|||
def get_compile_options(self, defines, includes, for_asm=False): | |||
opts = ['-D%s' % d for d in defines] | |||
if for_asm : | |||
if for_asm: |
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.
@TTornblom Can you review this change in this file , regarding -f
for assembly? There's related issue #4879 that we faced again in the recent days.
How this can lead to IAR assembler crashing?
Tools: Include configuration in ASM
Description
This fix adds assembler command line defines for macros in mbed_app.json and mbed_lib.json files.
Tested with mbed-os-example-blinky project for K64F target, on IAR Embedded Workbench 7.80.4.
Tested on mbed CLI and mbed export for IAR.
Pull request type