cpu/esp32: fixes compile problems#10362
Conversation
| LINKFLAGS += $(BINDIR)/esp_idf_esp32.a | ||
| LINKFLAGS += $(BINDIR)/esp_idf_nvs_flash.a | ||
| LINKFLAGS += $(BINDIR)/esp_idf_spi_flash.a | ||
| LINKFLAGS += $(BINDIR)/pthread.a |
There was a problem hiding this comment.
Putting the libraries into the linker command should already be done by
Line 7 in 98f42ee
However I see from the other parts that you duplicate dependency handling in both in Makefile.include and Makefile.dep. This comes because dependencies are resolved after board and cpu Makefile.include and I am currently trying to address it #9913
There was a problem hiding this comment.
Putting the libraries into the linker command should already be done by
Unfortunatly, it is a bit more tricky and I was not able to figure out another solution when I had to add the vendor libraries:
LINKFLAGS += -lcore -lrtc -lnet80211 -lpp -lsmartconfig -lcoexist
LINKFLAGS += -lwps -lwpa -lwpa2 -lespnow -lmesh -lphy -lstdc++
References in these libraries could only be resolved only by grouping them with module archives
esp_idf.a
esp_idf_esp32.a
esp_idf_nvs_flash.a
esp_idf_spi_flash.a
riot_freertos.a
even though they were already added by RIOT module makefiles. But they were in another --start-group ... --end-group and I could not figure out how to add further libraries to this list. Furthermore, these module archives reference symbols from other RIOT modules. So I had also to group
xtimer.a
core.a
pthread.a
with the libraries to be able to resolve all symbols.
With your hint to the BASELIBS variable, I could solve the problem as following:
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libcore.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/librtc.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libnet80211.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libpp.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libsmartconfig.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libcoexist.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libwps.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libwpa.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libwpa2.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libespnow.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libmesh.a
BASELIBS += $(ESP32_SDK_DIR)/components/esp32/lib/libphy.a
Would this be the right way?
There was a problem hiding this comment.
However I see from the other parts that you duplicate dependency handling in both in Makefile.include and Makefile.dep.
Yes, the reason was that the dependencies are included too late.
There was a problem hiding this comment.
@gschorcht I did not know that being in the same --start-group --end-group was important
For switching your -l to putting archives in BASELIBS I am not sure it is better to list all archives. I do not know the difference for the toolchain between the two.
Would it work and be sensible to put your -l into BASELIBS directly ? it would put it in the same group even if the variable name does not describe this
Line 433 in 0319a56
Regarding missing symbols there could also be issues with the current linking process as explained first in #5757 currently followed in this PR #8711
There was a problem hiding this comment.
With this diff to your PR it also compiles for your test command (not tested!)
diff --git a/cpu/esp32/Makefile.include b/cpu/esp32/Makefile.include
index 12ff0b1af..89e3d3814 100644
--- a/cpu/esp32/Makefile.include
+++ b/cpu/esp32/Makefile.include
@@ -121,21 +121,8 @@ LINKFLAGS += -L$(ESP32_SDK_DIR)/components/esp32/lib
LINKFLAGS += -Wl,--start-group
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
- LINKFLAGS += $(BINDIR)/cpu.a
- LINKFLAGS += $(BINDIR)/esp_idf.a
- LINKFLAGS += $(BINDIR)/esp_idf_esp32.a
- LINKFLAGS += $(BINDIR)/esp_idf_nvs_flash.a
- LINKFLAGS += $(BINDIR)/esp_idf_spi_flash.a
- LINKFLAGS += $(BINDIR)/pthread.a
- LINKFLAGS += $(BINDIR)/riot_freertos.a
- LINKFLAGS += $(BINDIR)/xtimer.a
- LINKFLAGS += -lcore -lrtc -lnet80211 -lpp -lsmartconfig -lcoexist
- LINKFLAGS += -lwps -lwpa -lwpa2 -lespnow -lmesh -lphy -lstdc++
-endif
-
-ifneq (,$(filter pthread,$(USEMODULE)))
- LINKFLAGS += $(BINDIR)/core.a
- LINKFLAGS += $(BINDIR)/pthread.a
+ BASELIBS += -lcore -lrtc -lnet80211 -lpp -lsmartconfig -lcoexist
+ BASELIBS += -lwps -lwpa -lwpa2 -lespnow -lmesh -lphy -lstdc++
endif
LINKFLAGS += -lhal -lg -lc -lg
When putting -lhal -lg -lc -lg into BASELIBS it failed to compiled but did not investigate further.
There was a problem hiding this comment.
@cladmi Thanks, based on your hints I was able to further reduce the special stuff.
There was a problem hiding this comment.
Cool :) Could you split this part out as it can be merged alone.
The handling of INCLUDES path and conflicts is a different topic where there are other things to consider. I am also still not sure of what to do there.
There was a problem hiding this comment.
@cladmi Do you mean as a separate pull request or just a separate commit?
There was a problem hiding this comment.
I would say separate PRs as I could merge the BASELIBS changes alone earlier.
There was a problem hiding this comment.
I wanted to have the split merged before this one but I forgot to put the label >< My bad.
|
I'm trying to test this, but I cannot run your command neither with this PR nor with master: I think it may have something to do with the recursive dependency resolution. Using Is this a bug? |
|
@jcarrano You are putting |
|
It seems to work: |
8d52ae1 to
2a7c33b
Compare
|
I can confirm that cherry-picking this PR on top of 2018.10 fixes the build issue from #10432 for me. |
|
@jcarrano Thanks 😃 |
|
@gschorcht please tell me when you have a PR split to put the libraries in BASELIBS, or if you want me to do it. |
Contribution description
This PR fixes the following compilation problems:
posixmodule as described in PR sys/posix: make posix module provide only headers. #10357esp_nowdue to lack of dependency on the pthread moduleesp_noware usedTesting procedure
Try to compile a test application with a combination of
spiffsandesp_nowmodules, e.g.:The compilation should be successful.
Issues/PRs references
See also PR #10357.