Xtensa-esp32s3-elf/bin/ld.exe: group ended before it began (--help for usage)

I try to compile the esp-who example for the ESP32-S3-EYE board and got the following error message during the linking:

.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: group ended before it began (--help for usage) collect2.exe: error: ld returned 1 exit status *** [.pio\build\debug\firmware.elf] Error 1

My configuration is the following:

[platformio]
src_dir = src
default_envs = debug

# Common build environment that is used for each of the tasks
[env]
board = esp32-s3-devkitc-1
platform = espressif32
framework = espidf

# Flash memory and partition selection
# NOTE: You have to edit the parameter `CONFIG_PARTITION_TABLE_CUSTOM_FILENAME` in `sdkconfig` too!
# 16 MB module version
#board_upload.flash_size = 16MB
#board_upload.maximum_size = 16777216
#board_build.partitions = partitions.csv
# 8 MB module version
board_upload.flash_size = 8MB
board_upload.maximum_size = 8388608
board_build.partitions = partitions.csv

# 4 MB module version
#board_upload.flash_size = 4MB
#board_upload.maximum_size = 4194304
#board_build.partitions = partitions.csv
board_build.filesystem = littlefs

board_build.embed_files =
    files/www/index_ov5640.html.gz
    files/www/monitor.html.gz

# Settings for serial upload
upload_speed = 921600
upload_port = COM5

# Settings for serial console
monitor_speed = 115200
monitor_port = COM5
monitor_filters = esp32_exception_decoder

# Additional packages
platform_packages =

# Aditional build scripts for all environments to run before (`pre`) and after (`post`) the main build script
extra_scripts =
    pre:scripts/Clean.py

# Common build flags for all environments
build_flags =
    # Application version
    -D APP_VERSION_MAJOR=0
    -D APP_VERSION_MINOR=0
    -D APP_VERSION_REV=1
    -D APP_NAME=esp32-s3-eye

    # ESP32 specific
    -D ESP32
    -D BOARD_HAS_PSRAM

lib_deps =

[env:debug]
build_type = debug
build_flags =
    ${env.build_flags}
    -D DEBUG
    -D APP_VERSION_POST=debug

lib_deps =
    ${env.lib_deps}
    ${env.lib_deps}

extra_scripts =
    ${env.extra_scripts}

[env:release]
build_type = release
build_flags =
    ${env.build_flags}
    -D RELEASE

lib_deps =
    ${env.lib_deps}
    ${env.lib_deps}

extra_scripts =
    ${env.extra_scripts}

How can I fix the issue?

What’s the linker command? CLIpio run -v -j1 please.

These string macros don’t look right at all, they should be stringifed.

    '-D APP_NAME="esp32-s3-eye"'
    '-D APP_VERSION_POST="debug"'

Please take a look at the output:

xtensa-esp32s3-elf-g++ -o .pio\build\debug\firmware.elf -T memory.ld -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u include_esp_phy_override -u ld_include_highint_hdl -u start_app -u start_app_other_cores -T sections.ld -u __ubsan_include -T esp32s3.rom.ld -T esp32s3.rom.api.ld -T esp32s3.rom.libgcc.ld -T esp32s3.rom.newlib.ld -T esp32s3.rom.version.ld -T esp32s3.rom.newlib-time.ld -u __assert_func -u vfs_include_syscalls_impl -T esp32s3.peripherals.ld -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -u __cxx_fatal_exception -Wl,--Map=C:/Users/konta/Desktop/ESP32-S3/.pio/build/debug/ESP32-S3.map -Wl,--cref -Wl,--end-group -Wl,--gc-sections -Wl,--start-group -Wl,--undefined=uxTopUsedPriority -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Find_FDE -Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=__cxa_call_unexpected -Wl,--wrap=__deregister_frame_info -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__gxx_personality_v0 -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_table -Wl,--wrap=longjmp -fno-lto -fno-rtti -mlongcalls -Og -g2 -ggdb2 .pio\build\debug\src\app\app_button.o .pio\build\debug\src\app\app_camera.o .pio\build\debug\src\app\app_face.o .pio\build\debug\src\app\app_lcd.o .pio\build\debug\src\app\app_led.o .pio\build\debug\src\app\app_motion.o .pio\build\debug\src\main.o -L.pio\build\debug -Lcomponents\esp-code-scanner\lib\esp32s3 -Lcomponents\esp-code-scanner\lib -Lcomponents\esp-sr\lib\esp32s3 -Lcomponents\esp-sr\lib\esp32s3 -Lcomponents\esp-sr\esp-tts\esp_tts_chinese\esp32s3 -Lcomponents\esp-dl\lib\esp32s3 -LC:\Users\konta\.platformio\packages\framework-espidf\components\esp_wifi\lib\esp32s3 -LC:\Users\konta\.platformio\packages\framework-espidf\components\esp_phy\lib\esp32s3 -L.pio\build\debug\esp-idf\esp_system\ld -LC:\Users\konta\.platformio\packages\framework-espidf\components\xtensa\esp32s3 -LC:\Users\konta\.platformio\packages\framework-espidf\components\esp_rom\esp32s3\ld -LC:\Users\konta\.platformio\packages\framework-espidf\components\esp_wifi\lib\esp32s3 -LC:\Users\konta\.platformio\packages\framework-espidf\components\soc\esp32s3\ld -Wl,--start-group .pio\build\debug\esp-idf\esp_ringbuf\libesp_ringbuf.a .pio\build\debug\esp-idf\esp_hid\libesp_hid.a .pio\build\debug\esp-idf\protocomm\libprotocomm.a .pio\build\debug\esp-idf\esp_lcd\libesp_lcd.a .pio\build\debug\esp-idf\protobuf-c\libprotobuf-c.a 
.pio\build\debug\esp-idf\cmock\libcmock.a .pio\build\debug\esp-idf\cbor\libcbor.a .pio\build\debug\esp-idf\unity\libunity.a .pio\build\debug\esp-idf\asio\libasio.a .pio\build\debug\esp-idf\coap\libcoap.a .pio\build\debug\esp-idf\esp_adc_cal\libesp_adc_cal.a .pio\build\debug\esp-idf\openssl\libopenssl.a .pio\build\debug\esp-idf\jsmn\libjsmn.a .pio\build\debug\esp-idf\libsodium\liblibsodium.a .pio\build\debug\esp-idf\json\libjson.a .pio\build\debug\esp-idf\mqtt\libmqtt.a .pio\build\debug\esp-idf\perfmon\libperfmon.a .pio\build\debug\esp-idf\spiffs\libspiffs.a .pio\build\debug\esp-idf\usb\libusb.a .pio\build\debug\esp-idf\mdns\libmdns.a .pio\build\debug\esp-idf\esp_websocket_client\libesp_websocket_client.a .pio\build\debug\esp-idf\esp_local_ctrl\libesp_local_ctrl.a .pio\build\debug\esp-idf\expat\libexpat.a .pio\build\debug\esp-idf\wear_levelling\libwear_levelling.a .pio\build\debug\esp-idf\fatfs\libfatfs.a .pio\build\debug\esp-idf\freemodbus\libfreemodbus.a .pio\build\debug\esp-idf\fb_gfx\libfb_gfx.a .pio\build\debug\esp-idf\screen\libscreen.a .pio\build\debug\esp-idf\modules\libmodules.a .pio\build\debug\esp-idf\wifi_provisioning\libwifi_provisioning.a .pio\build\debug\esp-idf\bus\libbus.a .pio\build\debug\esp-idf\esp-sr\libesp-sr.a .pio\build\debug\esp-idf\esp32-camera\libesp32-camera.a 
.pio\build\debug\esp-idf\app_trace\libapp_trace.a .pio\build\debug\esp-idf\app_update\libapp_update.a .pio\build\debug\esp-idf\bootloader_support\libbootloader_support.a .pio\build\debug\esp-idf\console\libconsole.a .pio\build\debug\esp-idf\cxx\libcxx.a .pio\build\debug\esp-idf\driver\libdriver.a .pio\build\debug\esp-idf\efuse\libefuse.a .pio\build\debug\esp-idf\esp-tls\libesp-tls.a .pio\build\debug\esp-idf\esp_common\libesp_common.a .pio\build\debug\esp-idf\esp_eth\libesp_eth.a .pio\build\debug\esp-idf\esp_event\libesp_event.a .pio\build\debug\esp-idf\esp_gdbstub\libesp_gdbstub.a .pio\build\debug\esp-idf\esp_http_client\libesp_http_client.a .pio\build\debug\esp-idf\esp_http_server\libesp_http_server.a .pio\build\debug\esp-idf\esp_https_ota\libesp_https_ota.a .pio\build\debug\esp-idf\esp_hw_support\libesp_hw_support.a .pio\build\debug\esp-idf\esp_ipc\libesp_ipc.a .pio\build\debug\esp-idf\esp_netif\libesp_netif.a .pio\build\debug\esp-idf\esp_phy\libesp_phy.a .pio\build\debug\esp-idf\esp_pm\libesp_pm.a .pio\build\debug\esp-idf\esp_rom\libesp_rom.a .pio\build\debug\esp-idf\esp_serial_slave_link\libesp_serial_slave_link.a .pio\build\debug\esp-idf\esp_system\libesp_system.a .pio\build\debug\esp-idf\esp_timer\libesp_timer.a .pio\build\debug\esp-idf\esp_wifi\libesp_wifi.a .pio\build\debug\esp-idf\espcoredump\libespcoredump.a .pio\build\debug\esp-idf\freertos\libfreertos.a .pio\build\debug\esp-idf\hal\libhal.a .pio\build\debug\esp-idf\heap\libheap.a .pio\build\debug\esp-idf\log\liblog.a .pio\build\debug\esp-idf\lwip\liblwip.a .pio\build\debug\esp-idf\mbedtls\libmbedtls.a .pio\build\debug\esp-idf\newlib\libnewlib.a .pio\build\debug\esp-idf\nghttp\libnghttp.a .pio\build\debug\esp-idf\nvs_flash\libnvs_flash.a .pio\build\debug\esp-idf\pthread\libpthread.a .pio\build\debug\esp-idf\sdmmc\libsdmmc.a .pio\build\debug\esp-idf\soc\libsoc.a .pio\build\debug\esp-idf\spi_flash\libspi_flash.a .pio\build\debug\esp-idf\tcp_transport\libtcp_transport.a 
.pio\build\debug\esp-idf\tcpip_adapter\libtcpip_adapter.a .pio\build\debug\esp-idf\ulp\libulp.a .pio\build\debug\esp-idf\vfs\libvfs.a .pio\build\debug\esp-idf\wpa_supplicant\libwpa_supplicant.a .pio\build\debug\esp-idf\xtensa\libxtensa.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedcrypto.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedtls.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedx509.a -lesp-code-scanner -lnewlib_iconv -lhufzip -lesp_audio_front_end -lesp_audio_processor -lmultinet -lwakenet -ldl_lib -lc_speech_features -lesp-dsp -lesp_tts_chinese -lvoice_set_xiaole -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lxt_hal -lgcov -lc -lm -lstdc++ -lgcc -Wl,--end-group
c:/users/konta/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: group ended before it began (--help for usage)
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\debug\firmware.elf] Error 1

Thanks. I have the conversion in my code. But it´s a good hint to move it into the config file.

Well somehow the linking command containsg this piece

-Wl,–Map=C:/Users/konta/Desktop/ESP32-S3/.pio/build/debug/ESP32-S3.map -Wl,–cref -Wl,–end-group -Wl,–gc-sections -Wl,–start-group -Wl,–undefined=uxTopUsedPriority

Where a group is indeed ended before it is started, so the linking error is right.

Is this reproducable with a simpler project? Can you upload it?

Hi,

I´m not sure where this error comes from, because an empty project doesn´t produce the error. But I have uploaded my project for you without esp-camera, esp-dl and esp-sr.

https://cloud.server-kampert.de/s/LWqzj96oBFQBcpA