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

[BUG] ESP32-C3: Clang compiler compatibility issue when handling assembly and link scripts (IDFGH-14341) #15131

Open
3 tasks done
ErEbusE opened this issue Jan 3, 2025 · 2 comments
Assignees
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@ErEbusE
Copy link

ErEbusE commented Jan 3, 2025

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

ESP-IDF v5.3.2-dirty

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

PowerShell

What is the expected behavior?

  1. Assembly code's .size directive should be compiled correctly
  2. The link script should correctly identify the rtc_data_seg region definition
  3. Clang compiler should behave consistently with GCC compiler Actual Behavior

What is the actual behavior?

There are two compilation errors:

  1. Assembly syntax error:
ESP-IDF/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S:444:10: error: expected identifier
    .size, .-rtos_current_tcb
         ^

portasm.S.txt@444g
2. Link script error:There are two compilation errors in memory.ld:

ld.lld: error: memory region not defined: rtc_data_seg
>>> _data_seg_org = ORIGIN(rtc_data_seg);

memory.ld.txt@125g

Steps to reproduce.

sdkconfig.txt
1.Create a new ESP32-C3 project
2.Set the compiler to esp-clang
3.Execute the compilation command

Build or installation Logs.

No response

More Information.

1.Fix assembly syntax:

    ret
    .size rtos_current_tcb, .-rtos_current_tcb

2.Fix link script

MEMORY 
{
    // ...existing code...
}

// Can the declaration order be swapped?
REGION_ALIAS("rtc_data_seg", rtc_iram_seg);
REGION_ALIAS("rtc_slow_seg", rtc_iram_seg);
REGION_ALIAS("rtc_data_location", rtc_iram_seg);

_data_seg_org = ORIGIN(rtc_data_seg);
@ErEbusE ErEbusE added the Type: Bug bugs in IDF label Jan 3, 2025
@github-actions github-actions bot changed the title [BUG] ESP32-C3: Clang compiler compatibility issue when handling assembly and link scripts [BUG] ESP32-C3: Clang compiler compatibility issue when handling assembly and link scripts (IDFGH-14341) Jan 3, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 3, 2025
@ErEbusE
Copy link
Author

ErEbusE commented Jan 4, 2025

2.Fix link script

MEMORY 
{
    // ...existing code...
}

 //Can the declaration order be swapped?
REGION_ALIAS("rtc_data_seg", rtc_iram_seg);
REGION_ALIAS("rtc_slow_seg", rtc_iram_seg);
REGION_ALIAS("rtc_data_location", rtc_iram_seg);

_data_seg_org = ORIGIN(rtc_data_seg);

This doesn't work, there are errors

[937/942] Linking CXX executable project-HelloWorld.elf
FAILED: project-HelloWorld.elf
C:\WINDOWS\system32\cmd.exe /C "cd . && D:\Tool\Espressif\tools\esp-clang\esp-18.1.2_20240912\esp-clang\bin\clang++.exe --target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32C3=0 -Wl,--Map=D:/MyProgram/ESP32-workspace/ESP32-C3/project-HelloWorld/build/project-HelloWorld.map -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--warn-common -T rom.api.ld -T esp32c3.peripherals.ld -T esp32c3.rom.ld -T esp32c3.rom.api.ld -T esp32c3.rom.bt_funcs.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.version.ld -T esp32c3.rom.eco3.ld -T esp32c3.rom.eco3_bt_funcs.ld -T esp32c3.rom.newlib.ld -T memory.ld -T sections.ld @CMakeFiles\project-HelloWorld.elf.rsp -o project-HelloWorld.elf && cd ."
ld.lld: error: section: .eh_frame is not contiguous with other relro sections
ld.lld: error: .flash_rodata_dummy section must be placed at the beginning of the rodata segment.
ld.lld: error: DRAM segment data does not fit.
ld.lld: error: The gap between .flash.appdesc and .flash.rodata must not exist to produce the final bin image.
ld.lld: error: The gap between .flash.rodata and .eh_frame_hdr must not exist to produce the final bin image.
ld.lld: error: The gap between .eh_frame_hdr and .eh_frame must not exist to produce the final bin image.
ld.lld: error: The gap between .eh_frame and .flash.tdata must not exist to produce the final bin image.
ld.lld: error: The gap between .flash.tdata and .flash.tbss must not exist to produce the final bin image.
ld.lld: error: DRAM segment data does not fit.
clang++: error: ld command failed with exit code 1 (use -v to see invocation)

@Lapshin
Copy link
Collaborator

Lapshin commented Jan 6, 2025

@ErEbusE , the issue regarding wrong asm syntax was fixed in this commit 9ca231e

I can not reproduce your issue using clean IDF v5.3.2 and using clang + your sdkconfig file. For some reason in your logs appeared clang version esp-18.1.2_20240912 which is wrong for IDF v5.3.2 (should be 16.0.1-fe4f10a809). Also, you should not get assembler errors because in v5.3.2 for clang passed -no-integrated-as option (GNU as should be used instead).

After these mismatches it's difficult to say what else could be wrong with your environment... Could you please retry your test with fresh IDF and IDF's export.bat/export.ps1 environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants