-
Notifications
You must be signed in to change notification settings - Fork 13.3k
section type conflict with __c #2078
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
Comments
/cc @Makuna |
@ewasscher, does this also occur with a simple sketch that just has a single PROGMEM global and a single F() string? |
This compiles fine: static constexpr char PROGMEM INVALID_UNIT[] = "Invalid unit";
void setup() {
Serial.println(INVALID_UNIT);
Serial.println(F(": "));
}
void loop() {
} |
Here's a related thread that @ewasscher posted in the PR that prompted this issue before: http://stackoverflow.com/questions/35091862/inline-static-data-causes-a-section-type-conflict IIUC, the section attribute (which is what The section conflict seems to mean that two variables end up in the same section, but having different linkage (or perhaps not just different, but also conflicting linkage that would result in different section-wide attributes). I suspect the location of the F() is relevant, and just putting it in
Being a template method, |
The sketch from the previous post does not build for ESP8266 2.2.0 core, it does for Nano and Due though.
|
@ewasscher the thread @matthijskooijman referenced sums up the issue. Due to the use of the templates function for Work around is to move the definition to a global or out of a function that relies on the linker to place it. This has another side effect in that if you had several uses in your code of the same string, before they would have each had a unique memory address, by making one global and using it, you save a little memory. |
@matthijskooijman do you understand and agree? I'm not sure I do. |
@Makuna, yeah that seems about right. What puzzles me, though, is why this does work for AVR. AFAIK |
@matthijskooijman on AVR PROGMEM |
The AVR doesn't use the GCC compiler.
|
Right, I misremembered that, then. That would explain why this works on AVR.
Huh? It certainly does, it calls
Right, I can't really think of any way to work around this from the core, while keeping the section attribute, and I guess I'll have to just work around this in my library (which, admittedly, isn't like your average Arduino library with its usage of templates). I looked a bit more at the objects mgenerated by the ESP compiler and the problem is indeed the same as in the stackoverflow: The template static variable gets the "GROUP" attribute (whatever that means exactly, couldn't find any docs about that), while the global one does not. It does not become "unique" as suggested by the article, so the route to getting this "GROUP" attribute is probably slightly different. However, looking more closely at the code, like how pgm_read_byte() is implemented, is all this PROGMEM-stuff even needed for ESP at all? It seems all that |
Some platforms don't have separate code and ram restrictions at all. AVR it was different asm calls to access it, esp8266, it just has a restriction that it must be read by 32bits calls only. PROGMEM was to abstract "if and how" it does it. So its needed for compatibility, if you want your code to run across platforms; and for many libraries this is desired. And no, there is no guarantee that const will force it into flash. |
@matthijskooijman consider the following code fragment char get_first_char() {
const char* p = get_some_string();
return p[0];
} In general, there is no way for the compiler to figure out where |
The use of PROGMEM for some global variables in parser.h caused GCC to report a section type conflict when building for ESP8266 as a result of the ESP8266 core's simulation of PROGMEM (which is in fact AVR specific). See esp8266/Arduino#2078. Fixed by disabling these uses of PROGMEM when building for ESP8266. As ESP8266 has more RAM than AVR chips (80K vs. 2K for the ATMega328p) the resulting increase in RAM use is not a major concern.
Thanks for the explanations and answers, I indeed think this is something that's just impossible to fix and needs to be worked around. @ewasscher already submitted a PR for my library to prevent this issue there. Thanks! |
@Makuna The teensy puts all const-declared variables into flash somehow, so maybe it's possible here? (Regarding your comment, "And no, there is no guarantee that const will force it into flash.") |
@ssilverman Tensy is ARM. Esp8266 does not; I suspect due to the restrictions on reads being 32bit only for flash of which ARM may not have these. But its a mute point, for compatibility reasons you should stick to the PROGMEM functions. |
Basic Infos
With (a modified version of) the arduino-dsmr library (https://github.com/matthijskooijman/arduino-dsmr) building the included examples for ESP8266 fails with "section type conflict with __c"
Hardware
Hardware: Any ESP8266
Core Version: 2.2.0
Description
With (a modified version of) the arduino-dsmr library (https://github.com/matthijskooijman/arduino-dsmr) building the included examples for ESP8266 fails with "section type conflict with __c" when using PROGMEM string literals (e.g. INVALID_UNIT) in one of the library's headers. Should this be considered a bug in the ESP core? I can work around this, but if there's a bug in the core involved I'd prefer not to do so and wait a bit more for the bugfix.
Settings in IDE
Not appliccable
Sketch
See the "parse" example sketch in the attached library
Debug Messages
arduino-dsmr-esp.zip
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: