Skip to content
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

Add missing --preinclude and -input on assembly files #2303

Merged
merged 4 commits into from
Aug 2, 2016

Conversation

theotherjimmy
Copy link
Contributor

Except for IAR

Resolves #2272

@theotherjimmy
Copy link
Contributor Author

@sg-
Copy link
Contributor

sg- commented Jul 28, 2016

Except for IAR

@0xc0170 @bogdanm Didn't we convert these to -D for IAR ASM or is that just the build system logic and not exporters?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 29, 2016

Except for IAR
@0xc0170 @bogdanm Didn't we convert these to -D for IAR ASM or is that just the build system logic and not exporters?

This change: b4e8cf6. However, looks like just cmd options. @bogdanm Is that correct?

@AlessandroA Please can you test?

@theotherjimmy I can't figure out what the IAR change does. I assume the exporter.py adds preinclude to asm flags, and the iar change removes it ,because of the IAR limitation? Better commit message might answer it.

@theotherjimmy
Copy link
Contributor Author

@0xc0170 your assumtion is correct. The IAR assembler cannot handle the --preinclude command line flag, but all of the other exporters can. It was less code to remove it in IAR than to explicitly add it in all of the other exporters.

@bogdanm
Copy link
Contributor

bogdanm commented Jul 29, 2016

How did you test this? At least with GCC and make, I don't see how this can work, since the exporter template doesn't add the include paths for assembler files:

https://github.com/mbedmicro/mbed/blob/master/tools/export/gcc_arm_common.tmpl#L92

@AlessandroA
Copy link
Contributor

AlessandroA commented Jul 29, 2016

I tested the PR and the compilation still fails. The build command should also include the config file mbed_config.h.

Failure:

arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
-c -x assembler-with-cpp -include mbed_config.h -c -Wall -Wextra -Wno-unused-parameter
-Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin
-ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks
-fomit-frame-pointer -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Os
-o mbed-os/hal/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.o
../../../mbed-os/hal/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.S

cc1: fatal error: mbed_config.h: No such file or directory

compilation terminated.

File structure (the file is there):

.
├── GettingStarted.htm
├── Makefile
├── exporter.yaml
└── mbed_config.h

Note: To test it I cherry-picked this commit on top of mbed-os-5.1.0-rc3 and removed commit f3c0ea3 to fix #2312.

@geky @0xc0170 @bogdanm @sg-

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 29, 2016

@theotherjimmy please state always how you tested a patch (how to reproduce this prior the patch that it failed, and how it solves the problem after this patch).

@bogdanm
Copy link
Contributor

bogdanm commented Jul 29, 2016

The build command should also include the config file mbed_config.h.

It does here: -include mbed_config.h. However, it doesn't specify an include path, since include paths are not added for the assembler in the makefile generator template:

https://github.com/mbedmicro/mbed/blob/master/tools/export/gcc_arm_common.tmpl#L92

(you'd also need the -DDEVICE_ to fix your bug, but that's yet another fix, I'm afraid).

@theotherjimmy
Copy link
Contributor Author

Woops. Yes @bogdanm, you are correct I did not specify an include path for the mbed_config.h.

@theotherjimmy
Copy link
Contributor Author

That should do it.

Except for IAR, it does not support the --preinclude option for assembly
files but all of the other exporters can. It was less code to remove it
in IAR than to explicitly add it in all of the other exporters.
@theotherjimmy
Copy link
Contributor Author

I also added the full explanation of why not IAR that I gave to @0xc0170 to the first commit message.

.s.o:
+@$(call MAKEDIR,$(dir $@))
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<
$(CC) $(CPU) -c $(ASM_FLAGS $(INCLUDE_PATHS)) -o $@ $<
Copy link
Contributor

Choose a reason for hiding this comment

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

Syntax error here (parantheses opening/closing incorrectly).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh! Just a moment. It passed my test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for being on top of code review!

@@ -196,6 +197,7 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
self.config_header = self.toolchain.MBED_CONFIG_FILE_NAME
config.get_config_data_header(join(trg_path, self.config_header))
self.config_macros = []
self.resources.inc_dirs.append(dirname(self.config_header))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this does anything useful. 3 lines above (line 197) we set config_header to the name of the config header file, not to its path. So its dirname will always be empty.

Copy link
Contributor Author

@theotherjimmy theotherjimmy Jul 29, 2016

Choose a reason for hiding this comment

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

True.......... So it should just append trg_path then? (I'm apparently still asleep over here :P)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that'll help, yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually that does some strange stuff. -I..//home/jimbri01/src/mbedmicro/mbed/.build/export/.temp ends up in my command line.

Copy link
Contributor Author

@theotherjimmy theotherjimmy Jul 29, 2016

Choose a reason for hiding this comment

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

I'm pretty sure that the mbed_config.h file will always be in the same directory as the Makefile.

@@ -196,6 +197,7 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
self.config_header = self.toolchain.MBED_CONFIG_FILE_NAME
config.get_config_data_header(join(trg_path, self.config_header))
self.config_macros = []
self.resources.inc_dirs.append(".")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to assume that you veridifed that . == trg_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.

Actually, the trg_path is an absolute path to the .temp directory where the project files are generated. I did verify that the Makefile and mbed_config.h always live in the same directory.

@geky
Copy link
Contributor

geky commented Jul 29, 2016

I tested locally with ARMmbed/mbed-os-example-uvisor#8:

Follow up on the issue:
ARMmbed/mbed-os-example-uvisor#8 (comment)

After fixing the CC_FLAGS issue, this pr should be good to go.

@@ -76,6 +76,8 @@ def generate(self, progen_build=False):
project_data['tool_specific']['iar'].setdefault("misc", {})
project_data['tool_specific']['iar'].update(tool_specific['iar'])
project_data['tool_specific']['iar']['misc'].update(self.progen_flags)
project_data['tool_specific']['iar']['misc']['asm_flags'].remove(
self.toolchain.get_config_option(self.config_header)[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to provide configuration options to the IAR assembler in the exporters now? On the command line, it's done by switching to -Ds instead of using --preinclude:

https://github.com/ARMmbed/mbed-os/blob/master/tools/toolchains/iar.py#L155

@bogdanm
Copy link
Contributor

bogdanm commented Aug 2, 2016

@theotherjimmy: any news on this?

@theotherjimmy
Copy link
Contributor Author

Updated per @geky's comment.

@geky
Copy link
Contributor

geky commented Aug 2, 2016

Ah! Sorry @theotherjimmy, it should be CC_SYMBOLS for asm rules.

@geky
Copy link
Contributor

geky commented Aug 2, 2016

Looks good to me and worked locally. LGTM 👍

@bogdanm
Copy link
Contributor

bogdanm commented Aug 2, 2016

Any answer to this:

Is there a way to provide configuration options to the IAR assembler in the exporters now? On the command line, it's done by switching to -Ds instead of using --preinclude:

Or should we just ignore this for now?

@theotherjimmy
Copy link
Contributor Author

from iasmarm help:

-DSYMB        Equivalent to: #define SYMB 1
-DSYMB=xx     Equivalent to: #define SYMB xx

That's my best guess.

@bogdanm
Copy link
Contributor

bogdanm commented Aug 2, 2016

from iasmarm help:

And again, as I already explained in a previous comment, that's already implemented here for command line:

https://github.com/ARMmbed/mbed-os/blob/master/tools/toolchains/iar.py#L155

Question is, do we plan to do the same thing in exporters?

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Aug 2, 2016

I think we should. The question in my mind is: should it be part of this PR? EDIT: Yes.

@bridadan
Copy link
Contributor

bridadan commented Aug 2, 2016

/morph test

@mbed-bot
Copy link

mbed-bot commented Aug 2, 2016

Result: SUCCESS

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

/morph test

Output

mbed Build Number: 582

All builds and test passed!

@bogdanm
Copy link
Contributor

bogdanm commented Aug 2, 2016

Given the circumstances, I think we can go ahead with this and fix the IAR ASM flags issue when/if we need to.

@bogdanm bogdanm merged commit c6c8d42 into ARMmbed:master Aug 2, 2016
@bogdanm bogdanm deleted the export-asm-symbols branch August 2, 2016 17:57
@bogdanm
Copy link
Contributor

bogdanm commented Aug 2, 2016

...so yeah, the fix for IAR ASM is already in this PR. Thanks @theotherjimmy. I'll be right back, need to find a good optician.

@theotherjimmy theotherjimmy restored the export-asm-symbols branch August 3, 2016 15:37
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.

8 participants