Comparing Arduino IDE and ESP-IDF build systems

@kristof

We do not use “start-group”/“end-group” linker flags as part of our ESP-IDF CMake build systems. Instead, we encourage that components (library archive) specifies its requirement clearly in its build template through “REQUIRES” or “PRIV_REQUIRES” constructs, more on this at: Build System - ESP32 - — ESP-IDF Programming Guide latest documentation

This allows to identify dependencies precisely, rather than creating lot of circular dependencies without noticing this. Similar thread discussing 2 approaches is at c++ - Resolving circular dependencies by linking the same library twice? - Stack Overflow

Coming to next problem which is mbedtls build, this is third party project which has its own CMake build system. So approach here is little different, as described at Build System - ESP32 - — ESP-IDF Programming Guide latest documentation

ESP-IDF build system builds “libmedtls.a” as its component and mbedtls library builds 3 additional archives “libmbedcrypto.a libmbedtls.a libmbedx509.a” per its build template.

If you look at object files within ESP-IDF built “libmbedtls.a” then it only contains couple of port files:

$ size build/esp-idf/mbedtls/libmbedtls.a 
   text	   data	    bss	    dec	    hex	filename
   1635	      0	    324	   1959	    7a7	esp_crt_bundle.c.obj (ex build/esp-idf/mbedtls/libmbedtls.a)
  64212	      0	      0	  64212	   fad4	x509_crt_bundle.S.obj (ex build/esp-idf/mbedtls/libmbedtls.a)

So yes, all 4 libraries would be required during linking step for successful application build.

Hope this information helps here!