esp32 - wrong include paths
The recent esp32-snapshots (Toolchain version: esp32-2019r1) require 2 include-File changes in order to compile AtomVM for esp32:
AtomVM/src/platforms/esp32/main:
sys.c
#include <posix/sys/socket.h>
-> #include "absolute path to $(IDF_PATH)/components/lwip/lwip/src/include/compat/posix/sys/socket.h"
network_driver.c:
#include <lwip/apps/sntp.h>
--> #include <apps/sntp/sntp.h>
There is a component.mk in the components/libatomvm where a INCLUDE_FIXUP_DIR could be set. Obviously this does not affect the generation in main. The component.mk file in main however is empty. Maybe one could specify the Include-Corrections there
For sys.c
#include <posix/sys/socket.h>
-> #include <compat/posix/sys/socket.h>
works.
I have few comments about your points:
For sys.c
#include <posix/sys/socket.h> -> #include <compat/posix/sys/socket.h>works.
This would break esp-idf v3.2, right now we are focusing only on tagged esp-idf versions so we don't have to worry about a moving target. Do you have any good reason about using a snapshot rather than v3.2?
#include <lwip/apps/sntp.h> --> #include <apps/sntp/sntp.h>
I'm not sure what do you mean here. Do you mind to attach a patch?
Last but not least: we are not testing our code against snapshots, so unexpected bugs may occur on newer esp-idf versions.
Anyway thank you for opening this issue :) Issues and questions are always appreciated.
When I installed the esp-idf I simply took the latest snapshot since I did not realized a hint that a 3.2-vesion has to be explicitly used. But this explains now why I am facing problems and I will switch to v3.2 .
Nevertheless it might be a good idea of making the C(Make) version more aware adding switches that allow for different esp-idf versions. But I agree to make AtomVM work with all versions of esp-idf should not have the highest priority.
With the most recent esp-idf and xtensa-esp32-elf/esp32-2019r1-8.2.0 and the above include-patches I can build AtomVM. But I cannot build it with esp-idf v3.2 as it crashes. What would you recommend?
/home/florian/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:155:44: error: expected initializer before '__result_use_check'
void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
^~~~~~~~~~~~~~~~~~
/home/florian/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:340:52: error: expected initializer before '__alloc_align'
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
I found something: https://esp32.com/viewtopic.php?t=11366&p=46054
Actually I got stuck with a proper tool chain.
I'm using this toolchain right now:
$ xtensa-esp32-elf-gcc --version
xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 5.2.0
Our CI is downloading it from here: https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
Right now we support all versions from 4.2.4 to 5.1, so I think this issue is not relevant anymore.