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

Consolidate .iram.text matcher in linker to wildcard matcher #4356

Merged

Conversation

kylefleming
Copy link
Contributor

Any symbol that is specified to be placed in the iram.text section (for example with the ICACHE_RAM_ATTR attribute) should generally be placed in that section regardless of where it came from, especially since this isn't something a non-Arduino/ESP8266 library would specify. As such, it seems like a wildcard matcher could be used here, in order to make sure no symbols fall through the cracks. This is how it's done with irom and irom0, so one could reasonably assume iram to be consistent. Does this seem reasonable?

@ivankravets
Copy link
Collaborator

ivankravets commented Feb 14, 2018

REMOVED

@igrr
Copy link
Member

igrr commented Feb 14, 2018

@ivankravets sorry, I don't follow. How is this PR related to library.json? It fixes a bug in the linker script that .iram.text sections from some files could be missed by the wildcard rules. It's not related to platformio (although it happens to reduce the number of platformio-specific rules).

@igrr igrr reopened this Feb 14, 2018
@ivankravets
Copy link
Collaborator

@igrr sorry, I thought that this issue is #4355 :(

I'll review it and answer here.

Copy link
Collaborator

@ivankravets ivankravets left a comment

Choose a reason for hiding this comment

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

Tested with this complex project. Works well!

Before PR

text	   data	    bss	    dec	    hex	filename
390880	   9104	  32464	 432448	  69940	.pioenvs/nodemcuv2/firmware.elf

After PR

text	   data	    bss	    dec	    hex	filename
392435	   7544	  32472	 432451	  69943	.pioenvs/nodemcuv2/firmware.elf

@ivankravets
Copy link
Collaborator

@kylefleming
Copy link
Contributor Author

@ivankravets It depends on what is being caught by the catch-all matcher in iram (found here). Converting the section you mention, which is in flash, to a catch-all matcher will change what the default section is for .literal* and .text* symbols. A lot of symbols are currently being whitelisted to be put in flash (here), but it's unclear which ones are left out and are expecting to be located in iram.

@igrr do you have a good sense of this? Since all user supplied .literal* and .text* symbols are being defaulted to flash (here), it certainly would make sense to default all .literal* and .text* symbols to flash and add a whitelist in iram for any system libraries that are expecting them in iram.

@igrr
Copy link
Member

igrr commented Feb 18, 2018

it certainly would make sense to default all .literal* and .text* symbols to flash and add a whitelist in iram for any system libraries that are expecting them in iram.

The problem is with defining this whitelist. Consider a hypothetical object file which is part of an SDK library. This object file has a few functions without any attribute (which get placed into .text or .text.functionname sections), and a few functions with ICACHE_FLASH_ATTR (which get placed into .irom.text section). How do we a) write a rule to place only some of these functions into flash and others into IRAM, and b) make sure that when SDK libraries are updated (and some functions are moved between sections), the rules are updated as well?

Could we have the same improvements for https://github.com/kylefleming/Arduino/blob/17a96a93ad8bd904663cf8c23a56ae747e191021/tools/sdk/ld/eagle.app.v6.common.ld#L91:L104 ?

I have suggested in the past to generate object files named xxx.c.o and yyy.cpp.o for xxx.c and yyy.cpp source files, when building with platformio. Then the behaviour would match that of arduino-builder, and this fragment of the linker script could be reduced to three lines.

@ivankravets
Copy link
Collaborator

@bdbaddog do we have an API in SCons to declare a custom $OBJSUFFIX per C and C++ files? Arduino IDE generates $OBJSUFFIX following the next template $FILENAME.o, they don't strip an extension from a source file.

Some LD scripts depend on these files

*.cpp.o(.iram.text)
*.c.o(.iram.text)

Thanks!

@ivankravets
Copy link
Collaborator

@kylefleming Could you try this temporary hook? Please navigate to 37 line https://github.com/esp8266/Arduino/blob/master/tools/platformio-build.py#L37 and add this

env.Replace(OBJSUFFIX =".c.o")

Now, you can try to remove/comment all PlatformIO-related lines in LD script. All should work, including #4355

Please confirm.

P.S: I know that we will append .c.o to CPP or ASM file... Nevertheless, it's a better solution and we will be more close to Arduino IDE behavior.

@ivankravets
Copy link
Collaborator

Starting from PIO Core 3.5.2b5 we will generate suffixes similar to Arduino IDE (thanks @bdbaddog for the idea with patching SCons.Builder).

I'll provide new PR tomorrow which will resolve #4355. Also, I'll remove all lines from LD related to PlatformIO.

P.S: @igrr should be happy :)

@ivankravets
Copy link
Collaborator

@igrr all things related to PlatformIO were removed from LD script. So, you can merge this PR

@kylefleming
Copy link
Contributor Author

Updated to integrate #4399 changes.

@d-a-v
Copy link
Collaborator

d-a-v commented Mar 26, 2018

Sorry about #4567, can you report your changes in the new .h file ?

Use wildcard matcher for .iram.text symbols.
@kylefleming kylefleming force-pushed the consolidate-iram-text-matcher branch from 2ac3f35 to bb3556d Compare April 16, 2018 02:46
@kylefleming
Copy link
Contributor Author

Updated

@earlephilhower earlephilhower added this to the 2.5.0 milestone Oct 4, 2018
@earlephilhower earlephilhower self-assigned this Oct 4, 2018
@earlephilhower
Copy link
Collaborator

@kylefleming I updated this via the online editor and think we're OK now.

@earlephilhower earlephilhower merged commit 9c46a81 into esp8266:master Oct 5, 2018
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.

5 participants