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

Setting LV_ATTRIBUTE_FAST_MEM spawns linker warnings on ESP-IDF v5.1 #4391

Closed
3 of 4 tasks
fronders opened this issue Jul 21, 2023 · 5 comments
Closed
3 of 4 tasks

Setting LV_ATTRIBUTE_FAST_MEM spawns linker warnings on ESP-IDF v5.1 #4391

fronders opened this issue Jul 21, 2023 · 5 comments

Comments

@fronders
Copy link

fronders commented Jul 21, 2023

Perform all steps below and tick them with [x]

  • Read the FAQ
  • Check the related part of the Documentation
  • Update lvgl to the latest version
  • Reproduce the issue in a Simulator

Describe the bug

I'm using ESP-IDF v5.1 (stable) with lvgl v8.3.8 (from component manager). When I enable Set IRAM as LV_ATTRIBUTE_FAST_MEM linker produces a bunch of warnings about conflicting iram sections like this:

Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/misc/lv_math.c.obj
../managed_components/lvgl__lvgl/src/misc/lv_math.c:49:1: warning: ignoring attribute 'section (".iram1.3")' because it conflicts with previous 'section (".iram1.0")' [-Wattributes]
   49 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/misc/lv_math.c:9:
../managed_components/lvgl__lvgl/src/misc/lv_math.h:47:31: note: previous declaration here
   47 | LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle);
      |                               ^~~~~~~~~~~~

You can clearly see different sections are assigned to function and to its prototype because IRAM_ATTR expands with _SECTION_ATTR_IMPL(".iram1", __COUNTER__) macro that uses __COUNTER__. This was not the case for v5.0 supposedly because v5.1 updated to GCC12.2.0 and this was ignored

This issue comment mentions what can be a fix for this problem:

solution we would like to have is to remove IRAM_ATTR from function declarations in the header file, except for the static inline definitions

And indeed all ESP-IDF sources follow that practice


Here is the full output of the linkage:

esptool.py v4.6.2
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Generated /home/fronders/esp/mp3-player/build/bootloader/bootloader.bin
[96/96] cd /home/fronders/esp/mp3-player/build/bootloader/esp-idf/esptool_py && /home/fronders/.espressif/python_env/idf5.1_py3.8_env/bin/python /home/fronders/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 /home/fronders/esp/mp3-player/build/bootloader/bootloader.bin
Bootloader binary size 0x6eb0 bytes. 0x150 bytes (1%) free.
[728/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/sw/lv_draw_sw_gradient.c.obj
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_gradient.c:298:1: warning: ignoring attribute 'section (".iram1.12")' because it conflicts with previous 'section (".iram1.8")' [-Wattributes]
  298 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_gradient.c:9:
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_gradient.h:72:39: note: previous declaration here
   72 | LV_ATTRIBUTE_FAST_MEM lv_grad_color_t lv_gradient_calculate(const lv_grad_dsc_t * dsc, lv_coord_t range,
      |                                       ^~~~~~~~~~~~~~~~~~~~~
[743/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/sw/lv_draw_sw_img.c.obj
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_img.c:47:1: warning: ignoring attribute 'section (".iram1.19")' because it conflicts with previous 'section (".iram1.17")' [-Wattributes]
   47 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_img.c:9:
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw.h:64:28: note: previous declaration here
   64 | LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_img_decoded(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
      |                            ^~~~~~~~~~~~~~~~~~~~~~
[770/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/sw/lv_draw_sw_blend.c.obj
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.c:105:1: warning: ignoring attribute 'section (".iram1.21")' because it conflicts with previous 'section (".iram1.11")' [-Wattributes]
  105 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw.h:16,
                 from ../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.c:9:
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.h:59:28: note: previous declaration here
   59 | LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_basic(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
      |                            ^~~~~~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.c:242:1: warning: ignoring attribute 'section (".iram1.22")' because it conflicts with previous 'section (".iram1.19")' [-Wattributes]
  242 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.c:29:35: note: previous declaration here
   29 | LV_ATTRIBUTE_FAST_MEM static void fill_normal(lv_color_t * dest_buf, const lv_area_t * dest_area,
      |                                   ^~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.c:639:1: warning: ignoring attribute 'section (".iram1.23")' because it conflicts with previous 'section (".iram1.20")' [-Wattributes]
  639 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_blend.c:46:35: note: previous declaration here
   46 | LV_ATTRIBUTE_FAST_MEM static void map_normal(lv_color_t * dest_buf, const lv_area_t * dest_area, lv_coord_t dest_stride,
      |                                   ^~~~~~~~~~
[888/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/lv_draw_img.c.obj
../managed_components/lvgl__lvgl/src/draw/lv_draw_img.c:241:1: warning: ignoring attribute 'section (".iram1.17")' because it conflicts with previous 'section (".iram1.16")' [-Wattributes]
  241 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_img.c:28:39: note: previous declaration here
   28 | LV_ATTRIBUTE_FAST_MEM static lv_res_t decode_and_draw(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
      |                                       ^~~~~~~~~~~~~~~
[891/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/lv_draw_line.c.obj
../managed_components/lvgl__lvgl/src/draw/lv_draw_line.c:38:1: warning: ignoring attribute 'section (".iram1.16")' because it conflicts with previous 'section (".iram1.12")' [-Wattributes]
   38 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/../core/../hal/../draw/lv_draw.h:26,
                 from ../managed_components/lvgl__lvgl/src/draw/../core/../hal/lv_hal_disp.h:21,
                 from ../managed_components/lvgl__lvgl/src/draw/../core/../hal/lv_hal.h:16,
                 from ../managed_components/lvgl__lvgl/src/draw/../core/lv_obj.h:25,
                 from ../managed_components/lvgl__lvgl/src/draw/../core/lv_refr.h:16,
                 from ../managed_components/lvgl__lvgl/src/draw/lv_draw_line.c:10:
../managed_components/lvgl__lvgl/src/draw/../core/../hal/../draw/lv_draw_line.h:46:28: note: previous declaration here
   46 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
      |                            ^~~~~~~~~~~~~~~~~~~~~
[892/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/lv_draw_rect.c.obj
../managed_components/lvgl__lvgl/src/draw/lv_draw_rect.c:38:1: warning: ignoring attribute 'section (".iram1.16")' because it conflicts with previous 'section (".iram1.9")' [-Wattributes]
   38 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/lv_draw.h:23,
                 from ../managed_components/lvgl__lvgl/src/draw/lv_draw_rect.c:9:
../managed_components/lvgl__lvgl/src/draw/lv_draw_rect.h:77:28: note: previous declaration here
   77 | LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
      |                            ^~~~~~~~~~~~~~~~~~~~~
[906/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/lv_draw_label.c.obj
../managed_components/lvgl__lvgl/src/draw/lv_draw_label.c:79:1: warning: ignoring attribute 'section (".iram1.16")' because it conflicts with previous 'section (".iram1.11")' [-Wattributes]
   79 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/lv_draw.h:24,
                 from ../managed_components/lvgl__lvgl/src/draw/lv_draw_label.c:9:
../managed_components/lvgl__lvgl/src/draw/lv_draw_label.h:82:28: note: previous declaration here
   82 | LV_ATTRIBUTE_FAST_MEM void lv_draw_label(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,
      |                            ^~~~~~~~~~~~~
[930/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/sw/lv_draw_sw_letter.c.obj
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_letter.c:167:1: warning: ignoring attribute 'section (".iram1.20")' because it conflicts with previous 'section (".iram1.19")' [-Wattributes]
  167 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_letter.c:30:35: note: previous declaration here
   30 | LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,
      |                                   ^~~~~~~~~~~~~~~~~~
[932/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/lv_draw_mask.c.obj
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:113:1: warning: ignoring attribute 'section (".iram1.25")' because it conflicts with previous 'section (".iram1.13")' [-Wattributes]
  113 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/lv_draw.h:29,
                 from ../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:9:
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.h:244:42: note: previous declaration here
  244 | LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
      |                                          ^~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:147:1: warning: ignoring attribute 'section (".iram1.26")' because it conflicts with previous 'section (".iram1.14")' [-Wattributes]
  147 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.h:260:42: note: previous declaration here
  260 | LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply_ids(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
      |                                          ^~~~~~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:247:1: warning: ignoring attribute 'section (".iram1.27")' because it conflicts with previous 'section (".iram1.15")' [-Wattributes]
  247 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.h:302:31: note: previous declaration here
  302 | LV_ATTRIBUTE_FAST_MEM uint8_t lv_draw_mask_get_cnt(void);
      |                               ^~~~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:599:1: warning: ignoring attribute 'section (".iram1.28")' because it conflicts with previous 'section (".iram1.16")' [-Wattributes]
  599 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:29:49: note: previous declaration here
   29 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_x,
      |                                                 ^~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:659:1: warning: ignoring attribute 'section (".iram1.29")' because it conflicts with previous 'section (".iram1.22")' [-Wattributes]
  659 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:48:49: note: previous declaration here
   48 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
      |                                                 ^~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:775:1: warning: ignoring attribute 'section (".iram1.30")' because it conflicts with previous 'section (".iram1.23")' [-Wattributes]
  775 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:51:49: note: previous declaration here
   51 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
      |                                                 ^~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:917:1: warning: ignoring attribute 'section (".iram1.31")' because it conflicts with previous 'section (".iram1.18")' [-Wattributes]
  917 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:35:49: note: previous declaration here
   35 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs_x,
      |                                                 ^~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:1056:1: warning: ignoring attribute 'section (".iram1.32")' because it conflicts with previous 'section (".iram1.17")' [-Wattributes]
 1056 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:32:49: note: previous declaration here
   32 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x,
      |                                                 ^~~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:1173:1: warning: ignoring attribute 'section (".iram1.33")' because it conflicts with previous 'section (".iram1.19")' [-Wattributes]
 1173 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:38:49: note: previous declaration here
   38 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_x,
      |                                                 ^~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:1219:1: warning: ignoring attribute 'section (".iram1.34")' because it conflicts with previous 'section (".iram1.20")' [-Wattributes]
 1219 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:41:49: note: previous declaration here
   41 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x,
      |                                                 ^~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:1253:1: warning: ignoring attribute 'section (".iram1.35")' because it conflicts with previous 'section (".iram1.21")' [-Wattributes]
 1253 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:44:49: note: previous declaration here
   44 | LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_polygon(lv_opa_t * mask_buf, lv_coord_t abs_x,
      |                                                 ^~~~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:1522:1: warning: ignoring attribute 'section (".iram1.36")' because it conflicts with previous 'section (".iram1.24")' [-Wattributes]
 1522 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/lv_draw_mask.c:61:46: note: previous declaration here
   61 | LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_t mask_new);
      |                                              ^~~~~~~~
[934/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/sw/lv_draw_sw_line.c.obj
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:54:1: warning: ignoring attribute 'section (".iram1.22")' because it conflicts with previous 'section (".iram1.18")' [-Wattributes]
   54 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:10:
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw.h:67:28: note: previous declaration here
   67 | LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_line(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
      |                            ^~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:114:1: warning: ignoring attribute 'section (".iram1.23")' because it conflicts with previous 'section (".iram1.20")' [-Wattributes]
  114 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:28:35: note: previous declaration here
   28 | LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
      |                                   ^~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:200:1: warning: ignoring attribute 'section (".iram1.24")' because it conflicts with previous 'section (".iram1.21")' [-Wattributes]
  200 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:30:35: note: previous declaration here
   30 | LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
      |                                   ^~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:280:1: warning: ignoring attribute 'section (".iram1.25")' because it conflicts with previous 'section (".iram1.19")' [-Wattributes]
  280 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_line.c:26:35: note: previous declaration here
   26 | LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
      |                                   ^~~~~~~~~~~~~~
[953/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/draw/sw/lv_draw_sw_rect.c.obj
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_rect.c:435:1: warning: ignoring attribute 'section (".iram1.22")' because it conflicts with previous 'section (".iram1.19")' [-Wattributes]
  435 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_rect.c:38:35: note: previous declaration here
   38 | LV_ATTRIBUTE_FAST_MEM static void draw_shadow(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc,
      |                                   ^~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_rect.c:955:1: warning: ignoring attribute 'section (".iram1.23")' because it conflicts with previous 'section (".iram1.20")' [-Wattributes]
  955 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_rect.c:40:35: note: previous declaration here
   40 | LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s,
      |                                   ^~~~~~~~~~~~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_rect.c:1041:1: warning: ignoring attribute 'section (".iram1.24")' because it conflicts with previous 'section (".iram1.21")' [-Wattributes]
 1041 | {
      | ^
../managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw_rect.c:42:35: note: previous declaration here
   42 | LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
      |                                   ^~~~~~~~~~~~~~~~~~
[1025/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/misc/lv_color.c.obj
../managed_components/lvgl__lvgl/src/misc/lv_color.c:37:1: warning: ignoring attribute 'section (".iram1.8")' because it conflicts with previous 'section (".iram1.7")' [-Wattributes]
   37 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/misc/lv_color.c:9:
../managed_components/lvgl__lvgl/src/misc/lv_color.h:647:28: note: previous declaration here
  647 | LV_ATTRIBUTE_FAST_MEM void lv_color_fill(lv_color_t * buf, lv_color_t color, uint32_t px_num);
      |                            ^~~~~~~~~~~~~
[1033/1068] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/misc/lv_math.c.obj
../managed_components/lvgl__lvgl/src/misc/lv_math.c:49:1: warning: ignoring attribute 'section (".iram1.3")' because it conflicts with previous 'section (".iram1.0")' [-Wattributes]
   49 | {
      | ^
In file included from ../managed_components/lvgl__lvgl/src/misc/lv_math.c:9:
../managed_components/lvgl__lvgl/src/misc/lv_math.h:47:31: note: previous declaration here
   47 | LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle);
      |                               ^~~~~~~~~~~~
../managed_components/lvgl__lvgl/src/misc/lv_math.c:110:1: warning: ignoring attribute 'section (".iram1.4")' because it conflicts with previous 'section (".iram1.2")' [-Wattributes]
  110 | {
      | ^
../managed_components/lvgl__lvgl/src/misc/lv_math.h:87:28: note: previous declaration here
   87 | LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask);
      |                            ^~~~~~~
[1067/1068] Generating binary image from built executable
esptool.py v4.6.2
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Generated /home/fronders/esp/mp3-player/build/mp3-player.bin
[1068/1068] cd /home/fronders/esp/mp3-player/build/esp-idf/esptool_py && /home...n_table/partition-table.bin /home/fronders/esp/mp3-player/build/mp3-player.bin
mp3-player.bin binary size 0x70280 bytes. Smallest app partition is 0x100000 bytes. 0x8fd80 bytes (56%) free.
@kisvegabor
Copy link
Member

Hi,

Thank you for opening this issue!

solution we would like to have is to remove IRAM_ATTR from function declarations in the header file, except for the static inline definitions

Are we sure that the compiler in general will like having the LV_ATTRIBUTE_FAST_MEM only in the C files? Will they know how to call RAM functions without without having any attributes in the prototypes?

What do you think?

@fronders
Copy link
Author

At least this is how all the sources of ESP-IDF are made, IRAM_ATTR is placed only in C files for function bodies, and in H files if it's an inline function. Here's a quick search for IRAM_ATTR in component header files and you can see it comes up only at inline functions.

And they are clearly aware of this issue, here's a piece of CMakeLists.txt where they temporarily silence this warning for Clang (support for which hasn't been released yet). Probably GCC prior to 12 did not generate a warning for this, but Clang and GCC12 do:
https://github.com/espressif/esp-idf/blob/3187b8b3264e32933de81d4e4f216a05957bd3fc/CMakeLists.txt#L95-L98

BUT, I did some research and as GCC docs state:

Function attributes are introduced by the __attribute__ keyword in the declaration of a function, followed by an attribute specification enclosed in double parentheses. You can specify multiple attributes in a declaration by separating them by commas within the double parentheses or by immediately following one attribute specification with another

Based on this, I'd rather keep the LV_ATTRIBUTE_FAST_MEM only in function prototypes and inline function definitions. And all of GCC examples of function attributes are specified for prototypes. So technically ESP-IDF has it wrongly implemented.

OTOH if an attribute is mentioned only in header prototypes, wouldn't it create a new section on each inclusion of a header file because of the counter macro? So maybe keeping it in C files only isn't a bad idea after all, I doubt the compiler would have problems with C-files-only attributes since this work is done by the linker after the fact anyways

@kisvegabor
Copy link
Member

OTOH if an attribute is mentioned only in header prototypes, wouldn't it create a new section on each inclusion of a header file because of the counter macro? So maybe keeping it in C files only isn't a bad idea after all, I doubt the compiler would have problems with C-files-only attributes since this work is done by the linker after the fact anyways

I agree with that. Do you have time to send a Pull request with the required changes?

@fronders
Copy link
Author

fronders commented Jul 24, 2023

Sure, should I use release/v8.3 for that?
Also maybe it would be reasonable to do to the same to all of the LV_ATTRIBUTE_* function attributes?

fronders added a commit to fronders/lvgl that referenced this issue Jul 24, 2023
removed function attributes from prototypes and kept only on function
declarations or static inline functions:
- LV_ATTRIBUTE_TICK_INC
- LV_ATTRIBUTE_TIMER_HANDLER
- LV_ATTRIBUTE_FLUSH_READY

This fixes an issue in ESP-IDF where section attributes use  __COUNTER__
macro, and this results in prototype and declaration having different
sections assigned
fronders added a commit to fronders/lvgl that referenced this issue Jul 24, 2023
…gl#4391)

removed function attributes from prototypes and kept only on function
declarations or static inline functions:
- LV_ATTRIBUTE_FAST_MEM

This fixes an issue in ESP-IDF where section attributes use  __COUNTER__
macro, and this results in prototype and declaration having different
sections assigned
fronders added a commit to fronders/lvgl that referenced this issue Jul 25, 2023
fixed attributes should be specified before the declarator in a function definition
regression introduced in 6663930
fronders added a commit to fronders/lvgl that referenced this issue Jul 25, 2023
…gl#4391)

fixed attributes should be specified before the declarator in a function definition
regression introduced in 0b5c7e5
@kisvegabor
Copy link
Member

PR is mered, closing.

ktand added a commit to ktand/lvgl that referenced this issue Jan 24, 2024
…kept only on function declarations or static inline functions

This fixes an issue in ESP-IDF where section attributes use __COUNTER__ macro, and this results in prototype and declaration having different sections assigned

This was previously fixed in the 8.x release.

lvgl#4391
lvgl#4404
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

2 participants