Skip to content

Fixed config-related options for the IAR assembler #2020

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 1 commit into from
Jun 27, 2016
Merged

Conversation

bogdanm
Copy link
Contributor

@bogdanm bogdanm commented Jun 27, 2016

The IAR assembler doesn't accept '--preinclude', but it accepts -D.
This commit changes the way the config-related macros are propagated
to the IAR assembler to use '-D' instead of '--preinclude'. This is
the only change related to functionality, the others are small,
backward compatible changes to the config code to make passing arguments
to the toolchain instances easier.

Tested by compiled blinky with IAR, GCC_ARM and ARM for K64F.

@bogdanm
Copy link
Contributor Author

bogdanm commented Jun 27, 2016

@screamerbg

if for_asm:
# The assembler doesn't support '--preinclude', so we need to add
# the macros directly
opts = opts + ['-D%s' % d for d in self.get_config_macros()]
Copy link
Contributor

Choose a reason for hiding this comment

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

@bogdanm This won't work with values that contain {} and "'. But in general I think we should filter these as assembler can't use strings anyway. E.g. this could be a filtered list of the macros that are defined and/or MACRO= statement. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are 100% correct about {} and "", I've forgotten about that. Regarding filtering though, we can't just start to filter which macros we put on the command line. I think the right answer to this is a proper quoting of the macro values on the command line. But this requires a bit of thought, I'm not sure yet what's the best way to do it.

Copy link
Contributor

@screamerbg screamerbg Jun 27, 2016

Choose a reason for hiding this comment

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

What I meant is different. Unlike c/cpp, in asm files you can't do string comparisons and assignments etc. You cannot even set float values for macros in Keil / asm settings. Because of this we can filter out all macros that neither simple defines nor integer assignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might not be needed. Even if you set the value of a macro to an invalid value (like -DWRONG_MACRO={1,2,3,4}), you won't get an error until you try to use that macro. If the .S file doesn't try to use it at all, all is well.

Copy link
Contributor

Choose a reason for hiding this comment

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

you won't get an error until you try to use that macro

A tool like uvision can't go further with assembly defines as shown above, therefore -DWRONG_MACRO={1,2,3,4} returns error that parsing failed (it's slightly cryptic error). That's what I experienced, therefore there's a fix in mbed codebase to remove floating point from TIMESTAMP for the macros in the uvision exporter.

Copy link
Contributor Author

@bogdanm bogdanm Jun 27, 2016

Choose a reason for hiding this comment

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

Ah OK. With #1975 in place, this won't be a problem for uVision anyway (note that this change applies only to IAR). We need to figure out how the other IDEs (like IAR) deal with this.

Copy link
Contributor

@screamerbg screamerbg Jun 27, 2016

Choose a reason for hiding this comment

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

Again, if you open Keil uVision, go to "Options for Target...", go to ASM tab and add a macro like MBED_TIMESTAMP=123232412.123232 or MBED_CONFIG_NSAPI_ETC={0xc0} then all compiles will fail and ARMCC will complain that invalid macro is specified. Knowing that this is an issue both for ARMCC and IAR we could filter these.
@bogdanm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@screamerbg: with #1975 in place, uVision is not going to be an issue. For IAR, I just opened Embedded Workbench and added a definition DUMMY_MACRO={1,2,3,4,5} to the C/C++ Copmiler/Preprocessor tab. EW didn't complain about that, it failed with a different error regarding duplicate object files (which is the same error that I get if I remove the definition of DUMMY_MACRO).

The IAR assembler doesn't accept '--preinclude', but it accepts -D.
This commit changes the way the config-related macros are propagated
to the IAR assembler to use '-D' instead of '--preinclude'. This is
the only change related to functionality, the others are small,
backward compatible changes to the config code to make passing arguments
to the toolchain instances easier.

Tested by compiled blinky with IAR, GCC_ARM and ARM for K64F.
@bogdanm bogdanm force-pushed the fix_iar_asm_options branch from 1e57c0e to b4e8cf6 Compare June 27, 2016 12:57
@bogdanm
Copy link
Contributor Author

bogdanm commented Jun 27, 2016

CI build failed because of an invalid import of config, I've pushed-force the fix.

@bogdanm
Copy link
Contributor Author

bogdanm commented Jun 27, 2016

CI passed with the latest change.

@bridadan
Copy link
Contributor

Tried this locally, looks good to me.

@bridadan
Copy link
Contributor

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,IAR,ARM
TARGETS=K64F,LPC1114,K22F,NUCLEO_F411RE,LPC1768

@mbed-bot
Copy link

[Build 538]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@sg- sg- merged commit f3e15eb into master Jun 27, 2016
@screamerbg
Copy link
Contributor

+1

@sg- sg- deleted the fix_iar_asm_options branch October 18, 2016 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants