esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 36 forks source link

API component fails with linker error on M1 Mac #6051

Closed andrein closed 3 months ago

andrein commented 3 months ago

The problem

I'm trying to use the ESPhome SDL display to rapidly prototype an UI on a M1 Macbook pro. Linking fails with the following error:

INFO Compiling app...
DEBUG Running:  platformio run -d .esphome/build/sdl-display -v
Processing sdl-display (build_flags: -DESPHOME_LOG_LEVEL=ESPHOME_LOG_LEVEL_DEBUG, -DUSE_HOST, -L/opt/homebrew/lib, -Wno-sign-compare, -Wno-unused-but-set-variable, -Wno-unused-variable, -fno-exceptions, -lsodium, -std=c++17; lib_deps: esphome/noise-c@0.1.4; platform: platformio/native)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- noise-c @ 0.1.4 (License: MIT, Path: /Users/andrein/Projects/andrein/esphome/.esphome/build/sdl-display/.piolibdeps/sdl-display/noise-c)
|   |-- libsodium @ 1.10018.1 (License: MIT, Path: /Users/andrein/Projects/andrein/esphome/.esphome/build/sdl-display/.piolibdeps/sdl-display/libsodium)
Building in release mode
g++ -o .pioenvs/sdl-display/program .pioenvs/sdl-display/src/esphome/components/api/api_connection.o .pioenvs/sdl-display/src/esphome/components/api/api_frame_helper.o .pioenvs/sdl-display/src/esphome/components/api/api_pb2.o .pioenvs/sdl-display/src/esphome/components/api/api_pb2_service.o .pioenvs/sdl-display/src/esphome/components/api/api_server.o .pioenvs/sdl-display/src/esphome/components/api/list_entities.o .pioenvs/sdl-display/src/esphome/components/api/proto.o .pioenvs/sdl-display/src/esphome/components/api/subscribe_state.o .pioenvs/sdl-display/src/esphome/components/api/user_services.o .pioenvs/sdl-display/src/esphome/components/host/core.o .pioenvs/sdl-display/src/esphome/components/host/gpio.o .pioenvs/sdl-display/src/esphome/components/host/preferences.o .pioenvs/sdl-display/src/esphome/components/logger/logger.o .pioenvs/sdl-display/src/esphome/components/logger/logger_esp32.o .pioenvs/sdl-display/src/esphome/components/logger/logger_esp8266.o .pioenvs/sdl-display/src/esphome/components/logger/logger_host.o .pioenvs/sdl-display/src/esphome/components/logger/logger_libretiny.o .pioenvs/sdl-display/src/esphome/components/logger/logger_rp2040.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_component.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_esp32.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_esp8266.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_host.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_libretiny.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_rp2040.o .pioenvs/sdl-display/src/esphome/components/network/util.o .pioenvs/sdl-display/src/esphome/components/socket/bsd_sockets_impl.o .pioenvs/sdl-display/src/esphome/components/socket/lwip_raw_tcp_impl.o .pioenvs/sdl-display/src/esphome/components/socket/lwip_sockets_impl.o .pioenvs/sdl-display/src/esphome/components/socket/socket.o .pioenvs/sdl-display/src/esphome/core/application.o .pioenvs/sdl-display/src/esphome/core/color.o .pioenvs/sdl-display/src/esphome/core/component.o .pioenvs/sdl-display/src/esphome/core/component_iterator.o .pioenvs/sdl-display/src/esphome/core/controller.o .pioenvs/sdl-display/src/esphome/core/entity_base.o .pioenvs/sdl-display/src/esphome/core/helpers.o .pioenvs/sdl-display/src/esphome/core/log.o .pioenvs/sdl-display/src/esphome/core/ring_buffer.o .pioenvs/sdl-display/src/esphome/core/scheduler.o .pioenvs/sdl-display/src/esphome/core/string_ref.o .pioenvs/sdl-display/src/esphome/core/time.o .pioenvs/sdl-display/src/esphome/core/util.o .pioenvs/sdl-display/src/main.o -L.pioenvs/sdl-display -L/opt/homebrew/lib .pioenvs/sdl-display/lib393/libsodium.a .pioenvs/sdl-display/lib498/libnoise-c.a -lsodium
Undefined symbols for architecture arm64:
  "__crypto_generichash_blake2b_pick_best_implementation", referenced from:
      _sodium_init in libsodium.a[20](core.o)
  "__crypto_pwhash_argon2_pick_best_implementation", referenced from:
      _sodium_init in libsodium.a[20](core.o)
  "__crypto_stream_salsa20_pick_best_implementation", referenced from:
      _sodium_init in libsodium.a[20](core.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** [.pioenvs/sdl-display/program] Error 1
=============================================================================================================================== [FAILED] Took 0.63 seconds ===============================================================================================================================

The docs point out that libsodium must be installed via homebrew, but esphome seems to use the esphome/libsodium platformio package instead of the one installed via homebrew, see the .pioenvs/sdl-display/lib393/libsodium.a in the command line.

If I remove that and run the command manually, it builds successfully:

❯ cd .esphome/build/sdl-display/
❯ g++ -o .pioenvs/sdl-display/program .pioenvs/sdl-display/src/esphome/components/api/api_connection.o .pioenvs/sdl-display/src/esphome/components/api/api_frame_helper.o .pioenvs/sdl-display/src/esphome/components/api/api_pb2.o .pioenvs/sdl-display/src/esphome/components/api/api_pb2_service.o .pioenvs/sdl-display/src/esphome/components/api/api_server.o .pioenvs/sdl-display/src/esphome/components/api/list_entities.o .pioenvs/sdl-display/src/esphome/components/api/proto.o .pioenvs/sdl-display/src/esphome/components/api/subscribe_state.o .pioenvs/sdl-display/src/esphome/components/api/user_services.o .pioenvs/sdl-display/src/esphome/components/host/core.o .pioenvs/sdl-display/src/esphome/components/host/gpio.o .pioenvs/sdl-display/src/esphome/components/host/preferences.o .pioenvs/sdl-display/src/esphome/components/logger/logger.o .pioenvs/sdl-display/src/esphome/components/logger/logger_esp32.o .pioenvs/sdl-display/src/esphome/components/logger/logger_esp8266.o .pioenvs/sdl-display/src/esphome/components/logger/logger_host.o .pioenvs/sdl-display/src/esphome/components/logger/logger_libretiny.o .pioenvs/sdl-display/src/esphome/components/logger/logger_rp2040.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_component.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_esp32.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_esp8266.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_host.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_libretiny.o .pioenvs/sdl-display/src/esphome/components/mdns/mdns_rp2040.o .pioenvs/sdl-display/src/esphome/components/network/util.o .pioenvs/sdl-display/src/esphome/components/socket/bsd_sockets_impl.o .pioenvs/sdl-display/src/esphome/components/socket/lwip_raw_tcp_impl.o .pioenvs/sdl-display/src/esphome/components/socket/lwip_sockets_impl.o .pioenvs/sdl-display/src/esphome/components/socket/socket.o .pioenvs/sdl-display/src/esphome/core/application.o .pioenvs/sdl-display/src/esphome/core/color.o .pioenvs/sdl-display/src/esphome/core/component.o .pioenvs/sdl-display/src/esphome/core/component_iterator.o .pioenvs/sdl-display/src/esphome/core/controller.o .pioenvs/sdl-display/src/esphome/core/entity_base.o .pioenvs/sdl-display/src/esphome/core/helpers.o .pioenvs/sdl-display/src/esphome/core/log.o .pioenvs/sdl-display/src/esphome/core/ring_buffer.o .pioenvs/sdl-display/src/esphome/core/scheduler.o .pioenvs/sdl-display/src/esphome/core/string_ref.o .pioenvs/sdl-display/src/esphome/core/time.o .pioenvs/sdl-display/src/esphome/core/util.o .pioenvs/sdl-display/src/main.o -L.pioenvs/sdl-display -L/opt/homebrew/lib .pioenvs/sdl-display/lib498/libnoise-c.a -lsodium
❯ .pioenvs/sdl-display/program
[16:48:34][I][app:029]: Running through setup()...
[16:48:34][C][api:025]: Setting up Home Assistant API server...
[16:48:34][I][app:062]: setup() finished successfully!
[16:48:34][W][component:157]: Component api set Warning flag: unspecified
[16:48:34][I][app:100]: ESPHome version 2024.7.0 compiled on Jul 17 2024, 16:43:52
[16:48:34][C][logger:185]: Logger:
[16:48:34][C][logger:186]:   Level: DEBUG
[16:48:34][C][mdns:116]: mDNS:
[16:48:34][C][mdns:117]:   Hostname: sdl-display
[16:48:34][C][api:139]: API Server:
[16:48:34][C][api:140]:   Address: :6053
[16:48:34][C][api:142]:   Using noise encryption: YES

Which version of ESPHome has the issue?

2024.7.0

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

No response

What platform are you using?

Host (arm64, M1 Macbook Pro)

Board

No response

Component causing the issue

api

Example YAML snippet

esphome:
  name: sdl-display
  friendly_name: SDL Display

host:

logger:
  level: DEBUG

api:
  encryption:
    key: "JJaaJNBPa2wN3ikAWrBOQSe9vThxRCQzKVXKrrVqFuE="

Anything in the logs that might be useful for us?

No response

Additional information

No response

ngdio commented 3 months ago

Experiencing the same issue.

clydebarrow commented 3 months ago

Fixed by https://github.com/esphome/esphome/pull/7288