Cannot build smart-light example

I can flash the led-blink example only after removing this line ( /Users/roman/esp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/components/chip; ) from build.ninja in build folder.

THIS IS TERMINAL OUTPUT AFTER TRYING TO BUILD smart-light example :

[7/13] Building Swift Module '__idf_main' with 6 sources

FAILED: esp-idf/main/__idf_main.swiftmodule esp-idf/main/CMakeFiles/__idf_main.dir/Main.swift.obj esp-idf/main/CMakeFiles/__idf_main.dir/LED.swift.obj esp-idf/main/CMakeFiles/idf_main.dir//Matter/Attribute.swift.obj esp-idf/main/CMakeFiles/idf_main.dir//Matter/Clusters.swift.obj esp-idf/main/CMakeFiles/idf_main.dir//Matter/Matter.swift.obj esp-idf/main/CMakeFiles/idf_main.dir//Matter/Node.swift.obj
...
[LOTS OF TEXT]
...
warning: conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'IDF_VER="v5.2.1"')

warning: conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'MBEDTLS_CONFIG_FILE="mbedtls/esp_config.h"')

warning: conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'SOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE')

warning: conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'SOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ')

warning: conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>')

error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: (LazyTypeMetadata.empty()), function emitLazyDefinitions, file GenDecl.cpp, line 1330.
Please submit a bug report (Swift.org - Contributing) and include the crash backtrace.

Thank for any help and advice!

We have a patch inflight to add CI to this repo, you can find it here: Add .github/workflows/build.yml by kubamracek · Pull Request #32 · apple/swift-matter-examples · GitHub

As the CI in this run is able to build all the examples, I'd recommend figuring how your environment differs from it and start from there.

1 Like
error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: (LazyTypeMetadata.empty()), function emitLazyDefinitions, file GenDecl.cpp, line 1330.

The latest swift.org toolchain has this problem fixed.

The CI setup that Rauhul mentions is now in place, too, so that should show this build failure resolved.

1 Like

After updating im facing another issue:

[546/548] Linking CXX executable light.elf

FAILED: light.elf

Im not sure whats causing this, so id appreciate every advice. Thanks :)

Can you post more logs? Is there any error printed?

[terminal.txt - Google Drive](This is full output from terminal)

I dont know if its related but i need to mention that i cannot successfuly build without deleting this line:
/Users/romanbelka/esp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/components/chip;
from any examples i try to build.
Error before deleting the line from build.ninja:

[709/1258] Performing build step for 'chip_gn'

FAILED: esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build esp-idf/chip/lib/libCHIP.a /Users/romanbelka/swift-matter-examples_01/smart-light/build/esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build /Users/romanbelka/swift-matter-examples_01/smart-light/build/esp-idf/chip/lib/libCHIP.a

cd "/Users/romanbelka/esp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/components/chip;/Users/romanbelka/swift-matter-examples_01/smart-light/build/esp-idf/chip" && ninja esp32

/bin/sh: line 0: cd: /Users/romanbelka/esp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/components/chip;/Users/romanbelka/swift-matter-examples_01/smart-light/build/esp-idf/chip: No such file or directory

Pasting the relevant failure from the output:

/Users/romanbelka/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: esp-idf/main/libmain.a(Main.swift.obj): in function `$es12swift_retain6objectBpBp_tF':
Main.swift.obj:(.text.$es12swift_retain6objectBpBp_tF+0x14): undefined reference to `__atomic_load_4'
/Users/romanbelka/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: Main.swift.obj:(.text.$es12swift_retain6objectBpBp_tF+0x2e): undefined reference to `__atomic_fetch_add_4'
/Users/romanbelka/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: esp-idf/main/libmain.a(Main.swift.obj): in function `$es13swift_release6objectyBp_tF':
Main.swift.obj:(.text.$es13swift_release6objectyBp_tF+0x1e): undefined reference to `__atomic_load_4'
/Users/romanbelka/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: Main.swift.obj:(.text.$es13swift_release6objectyBp_tF+0x34): undefined reference to `__atomic_fetch_sub_4'
/Users/romanbelka/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: Main.swift.obj:(.text.$es13swift_release6objectyBp_tF+0x5e): undefined reference to `__atomic_store_4'
/Users/romanbelka/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: esp-idf/main/libmain.a(Main.swift.obj): in function `$es41swift_isUniquelyReferenced_nonNull_native6objectSbBp_tF':
Main.swift.obj:(.text.$es41swift_isUniquelyReferenced_nonNull_native6objectSbBp_tF+0x8): undefined reference to `__atomic_load_4'
collect2: error: ld returned 1 exit status

Can you share more details about your set up? Both the problems (needing to remove a line from build.ninja, and the linking problem) are pretty surprising to me. What OS are you on? Are you building in Docker? What CMake version do you have? What ESP IDF and ESP Matter versions do you have? Did you try a newer IDF?

OS: macOS Sonoma 14.6.1
Apple Swift version 6.2-dev (LLVM be8c96d78337932, Swift 0bbaa3519b62071) arm64-apple-macosx14.0
CMake version 3.31.2
ESP-IDF v5.2.1
ESP-Matter v1.3
No im not building in docker.
And im using same device as you in video(original ESP32-C6-DevKitC-1)

I updated ESP-IDF to 5.3.2, ESP-Matter to 1.3 and CMake to 3.31.2.
I dont need anymore to remove line from build.ninja, to successfuly build. There is still one error remaining:

Executing "ninja flash"...
ninja: error: '/Users/romanbelka/esp/esp-idf-v5.3.2/components/bt/controller/lib_esp32c6/esp32c6-bt-lib/libble_app.a', needed by 'light.elf', missing and no known rule to make it

Thanks for help:)