Page 1 of 1

libsodium sodium_init causes compilation to fail

Posted: Sun Mar 31, 2024 1:11 pm
by letsbuild
As the title says importing libsodium and calling `sodium_init` causes idf.py build to fail with an error relating to aegis:
```
.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/espressif__libsodium/libespressif__libsodium.a(core.c.obj):(.literal.sodium_init+0x4): undefined reference to `_crypto_aead_aegis128l_pick_best_implementation'
.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/espressif__libsodium/libespressif__libsodium.a(core.c.obj):(.literal.sodium_init+0x8): undefined reference to `_crypto_aead_aegis256_pick_best_implementation'
.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/espressif__libsodium/libespressif__libsodium.a(core.c.obj): in function `sodium_init':
/home/sw/esp/test_project/build/../managed_components/espressif__libsodium/libsodium/src/libsodium/sodium/core.c:42:(.text.sodium_init+0x3b): undefined reference to `_crypto_aead_aegis128l_pick_best_implementation'
.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /home/sw/esp/test_project/build/../managed_components/espressif__libsodium/libsodium/src/libsodium/sodium/core.c:43:(.text.sodium_init+0x41): undefined reference to `_crypto_aead_aegis256_pick_best_implementation'
```
To test this it's as easy as creating a new project adding the libsodium dependency and in the main function calling `sodium_init();`


ESP Target: esp32, esp32c3, esp32s3 (haven't tried others)
IDF version is 5.3.0
Libsodium versions: 1.0.18, 1.0.19, 1.0.20, 1.0.20~1
OS: Debian 12