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

_Pragma warning weird interaction #69

Open
3 tasks done
KaeLL opened this issue Dec 6, 2024 · 8 comments
Open
3 tasks done

_Pragma warning weird interaction #69

KaeLL opened this issue Dec 6, 2024 · 8 comments

Comments

@KaeLL
Copy link

KaeLL commented Dec 6, 2024

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate.
  • Provided a clear description of your suggestion.
  • Included any relevant context or examples.

Issue or Suggestion Description

Compiling one of my apps against the latest IDF:master, the following code
Screenshot From 2024-12-06 16-39-53
Screenshot From 2024-12-06 16-39-21
Screenshot From 2024-12-06 16-40-23

when compiled, produces the following warnings

/app/components/w5100/port/src/w5100-ll.c: In function 'w5100_spi_init':
/app/components/w5100/port/src/w5100-ll.c:56:27: warning: VSPI_HOST is deprecated in favor of SPI3_HOST
   56 |                 &w5100_spi_handle ) );
      |                           ^~~~~~~~~~~~
[994/1023] Building C object esp-idf/nfc/CMakeFiles/__idf_nfc.dir/rfid_reader/Hardware/spi_nfc.c.obj
/app/components/nfc/rfid_reader/Hardware/spi_nfc.c: In function 'SPI_setup':
/app/components/nfc/rfid_reader/Hardware/spi_nfc.c:379:27: warning: VSPI_HOST is deprecated in favor of SPI3_HOST
  379 |                 &trf_hdl ) );
      |                           ^~~
[1015/1023] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/main.c.obj
/app/main/main.c: In function 'app_main':
/app/main/main.c:61:34: warning: VSPI_HOST is deprecated in favor of SPI3_HOST
   61 |                         SPI_DMA_CH1 ) );
      |                                  ^~~~~~~

That looks a bit weird. The lines reported point to the last line of the ESP_ERROR_CHECK macro calls, not the first. The markers are a bit off as well.
Then I checked the macros

#define SPI_HOST    _Pragma ("GCC warning \"SPI_HOST is deprecated in favor of SPI1_HOST\"")  SPI1_HOST
#define HSPI_HOST   _Pragma ("GCC warning \"HSPI_HOST is deprecated in favor of SPI2_HOST\"") SPI2_HOST
#define VSPI_HOST   _Pragma ("GCC warning \"VSPI_HOST is deprecated in favor of SPI3_HOST\"") SPI3_HOST

I guess C99 _Pragma's don't interact well with the diagnostics part of the front-end? Either way, looks like a bug.

@Lapshin
Copy link
Collaborator

Lapshin commented Dec 7, 2024

@KaeLL , thank you for the report!

Could you please attach minimal code reproducer in text (not pictures)? Along with command line you compile it

@KaeLL
Copy link
Author

KaeLL commented Dec 7, 2024

create main.c, paste and compile this

#include "driver/spi_master.h"

void app_main( void )
{
	ESP_ERROR_CHECK( spi_bus_initialize(
		VSPI_HOST,
		&( const spi_bus_config_t ) {
			.miso_io_num = 19,
			.mosi_io_num = 23,
			.sclk_io_num = 18,
			.quadwp_io_num = -1,
			.quadhd_io_num = -1,
			.isr_cpu_id = ESP_INTR_CPU_AFFINITY_1,
			.intr_flags = ESP_INTR_FLAG_IRAM },
		SPI_DMA_CH1 ) );

	spi_device_handle_t trf_hdl, w5100_spi_handle;
	ESP_ERROR_CHECK( spi_bus_add_device(
		VSPI_HOST,
		&( const spi_device_interface_config_t ) {
			.command_bits = 3,
			.address_bits = 5,
			.spics_io_num = 26,
			.clock_speed_hz = SPI_MASTER_FREQ_20M / 4,
			.mode = 1,
			.queue_size = 1,
			.cs_ena_pretrans = 1,
		},
		&trf_hdl ) );

	ESP_ERROR_CHECK( spi_bus_add_device(
		VSPI_HOST,
		&( const spi_device_interface_config_t ) {
			.clock_speed_hz = 1200000,
			.spics_io_num = 17,
			.queue_size = 1,
			.pre_cb = NULL,
			.post_cb = NULL },
		&w5100_spi_handle ) );
}

It'll get you this

[4/9] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/esp_gcc_69.c.obj
/esp_gcc_69/main/esp_gcc_69.c: In function 'app_main':
/esp_gcc_69/main/esp_gcc_69.c:16:27: warning: VSPI_HOST is deprecated in favor of SPI3_HOST
   16 |                 SPI_DMA_CH1 ) );
      |                           ^~~~~~                                         
/esp_gcc_69/main/esp_gcc_69.c:29:27: warning: VSPI_HOST is deprecated in favor of SPI3_HOST
   29 |                 }, &trf_hdl ) );
      |                           ^~~~~~                                         
/esp_gcc_69/main/esp_gcc_69.c:39:27: warning: VSPI_HOST is deprecated in favor of SPI3_HOST
   39 |                 &w5100_spi_handle ) );
      |                           ^~~~~~~~~~~~                                   

@Lapshin
Copy link
Collaborator

Lapshin commented Dec 8, 2024

@KaeLL , can you please simplify your example to only one file that can be compiled outside the IDF environment?

I tried to build hello-world example but replaced it with your code for esp32 on commit espressif/esp-idf@bcd80c9 and did not get any error/warning message.

Do I understand correctly that you reported a bug with an incorrect line indication only?

@igrr
Copy link
Member

igrr commented Dec 8, 2024

@Lapshin i guess you need to pull the latest changes to get espressif/esp-idf@0d7e589

(FWIW to me it looks like incorrect usage of pragmas on IDF side. IDK if we really need those deprecation warnings, seems like it's almost zero cost to keep the old names for compatibility.)

@KaeLL
Copy link
Author

KaeLL commented Dec 9, 2024

Be that as it may, still looks like an issue with GCC, no?

@Lapshin
Copy link
Collaborator

Lapshin commented Dec 10, 2024

@KaeLL , yes it's an issue that already improved for trunk (gcc's master branch) https://godbolt.org/z/Mr8bsoqa8

But it seems another issue appeared - double warnings output

@Lapshin
Copy link
Collaborator

Lapshin commented Dec 10, 2024

@KaeLL , you can track the issue here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117977

@igrr
Copy link
Member

igrr commented Dec 10, 2024

True, but seems like that is not an ESP-specific issue, upstream GCC also doesn't place the marker correctly:
https://godbolt.org/z/31Ta18eMx

This upstream bug report seems related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102887.

Edit: please ignore, next time I will refresh the page before commenting

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

No branches or pull requests

3 participants