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

Compilation error: v3.0.1 when used as esp-idf component #9784

Closed
ricardoquesada opened this issue Jun 6, 2024 · 9 comments · Fixed by #9801
Closed

Compilation error: v3.0.1 when used as esp-idf component #9784

ricardoquesada opened this issue Jun 6, 2024 · 9 comments · Fixed by #9801
Assignees
Labels
Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF Status: In Progress Issue is in progress
Milestone

Comments

@ricardoquesada
Copy link

Board

sparkfun esp32 thing

Device Description

sparkfun esp32 thing

Hardware Configuration

N/A

Version

v3.0.1

IDE Name

idf-idf.py command line

Operating System

Linux

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

115200

Description

compilation error when using Arduino Core v3.0.1 + ESP-IDF 5.1.4.
Arduino Core is used as component.

I just run "idf.py build" and fails to compile both in:

  • components/arduino/cores/esp32/esp32-hal-adc.c
  • components/arduino/cores/esp32/MacAddress.cpp

It used to compile Ok using Arduino Core v2.0.17 + ESP-IDF 4.4.7

Sketch

Not applicable.

Debug Message

* esp32-hal-adc.c


/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/esp32-hal-adc.c: In function 'analogContinuous':
/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/esp32-hal-adc.c:478:27: error: 'adc_unit' may be used uninitialized [-Werror=maybe-uninitialized]
  478 |   if (adc_handle[adc_unit].adc_oneshot_handle != NULL) {
      |       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/esp32-hal-adc.c:461:14: note: 'adc_unit' declared here
  461 |   adc_unit_t adc_unit;
      |              ^~~~~~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
  • MacAddress.cpp
/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/MacAddress.cpp: In member function 'bool MacAddress::fromString6(const char*)':
/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/MacAddress.cpp:75:10: error: 'char* strncpy(char*, const char*, size_t)' specified bound 18 equals destination size [-Werror=stringop-truncation]
   75 |   strncpy(cs, buf, sizeof(cs));  //strtok modifies the buffer: copy to working buffer.
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/MacAddress.cpp: In member function 'bool MacAddress::fromString8(const char*)':
/home/riq/progs/esp-idf-arduino-bluepad32-template/components/arduino/cores/esp32/MacAddress.cpp:94:10: error: 'char* strncpy(char*, const char*, size_t)' specified bound 24 equals destination size [-Werror=stringop-truncation]
   94 |   strncpy(cs, buf, sizeof(cs));  //strtok modifies the buffer: copy to working buffer.
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors


### Other Steps to Reproduce

_No response_

### I have checked existing issues, online documentation and the Troubleshooting Guide

- [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@SuGlider
Copy link
Collaborator

SuGlider commented Jun 6, 2024

Thanks for reporting it!

@SuGlider SuGlider added Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF and removed Status: Awaiting triage Issue is waiting for triage labels Jun 6, 2024
@SuGlider SuGlider self-assigned this Jun 6, 2024
@me-no-dev
Copy link
Member

@ricardoquesada are you sure you did not change any settings? The core is compiled with IDF constantly and we do not get those errors

@ricardoquesada
Copy link
Author

ricardoquesada commented Jun 6, 2024

sorry, my bad... yes, I'm using:

CONFIG_COMPILER_OPTIMIZATION_PERF=y

in sdkconfig.defaults

@Jason2866
Copy link
Collaborator

Duplicate of #9607

@Jason2866 Jason2866 marked this as a duplicate of #9607 Jun 6, 2024
@VojtechBartoska
Copy link
Collaborator

Thanks for pointing that out @Jason2866. Please take a look @lucasssvaz

@VojtechBartoska VojtechBartoska added this to the 3.0.2 milestone Jun 6, 2024
@VojtechBartoska VojtechBartoska added the Status: Needs investigation We need to do some research before taking next steps on this issue label Jun 6, 2024
@ricardoquesada
Copy link
Author

Technically this is not a duplicate of issue #9607

Issue #9607 mentions a bug in RainMaker.

This issue is about bugs in Arduino Core: esp32-hal-adc.c and MacAddress.cpp files.

@Jason2866
Copy link
Collaborator

Jason2866 commented Jun 6, 2024

Technically it is the same, the reason is [-Werror=stringop-truncation]
Just happening in different code parts.

@ricardoquesada
Copy link
Author

The root cause is that when using CONFIG_COMPILER_OPTIMIZATION_PERF=y is triggering different bugs:

  • RainMaker: [-Werror=stringop-truncation]
  • Arduino Core:
    • MacAddress.cpp: [-Werror=stringop-truncation]
    • esp32-hal-adc.c: [-Werror=maybe-uninitialized]

@SuGlider
Copy link
Collaborator

SuGlider commented Jun 6, 2024

The root cause is that when using CONFIG_COMPILER_OPTIMIZATION_PERF=y is triggering different bugs:

  • RainMaker: [-Werror=stringop-truncation]

  • Arduino Core:

    • MacAddress.cpp: [-Werror=stringop-truncation]
    • esp32-hal-adc.c: [-Werror=maybe-uninitialized]

@lucasssvaz
Please take alook into the warnings that @ricardoquesada has pointed out.
We may just need to change a few parts the code in order to avoid it.
I think that improving the code is always a good move.

@VojtechBartoska VojtechBartoska added Status: In Progress Issue is in progress and removed Status: Needs investigation We need to do some research before taking next steps on this issue labels Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF Status: In Progress Issue is in progress
Projects
Development

Successfully merging a pull request may close this issue.

6 participants