From a1b20ca049c86c271719c8babf0a0436c0560c2d Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 9 Aug 2025 05:21:19 +0300 Subject: [PATCH 1/3] Test - linkage sanity check Check C++ in addition to C code Check for known issue w/ newlib-4.5.0 when expecting wide characters support Check that compiler can build and link .elf using default build flags & defines --- tests/sanity_check.sh | 111 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 5 deletions(-) diff --git a/tests/sanity_check.sh b/tests/sanity_check.sh index f5f2a6f2e1..2f1b63b53e 100755 --- a/tests/sanity_check.sh +++ b/tests/sanity_check.sh @@ -10,11 +10,25 @@ popd pushd "$cache_dir" -gcc="$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc"\ -" -I$root/cores/esp8266"\ -" -I$root/tools/sdk/include"\ -" -I$root/variants/generic"\ -" -I$root/tools/sdk/libc/xtensa-lx106-elf" +cflags=$" + -Os + -g + -free + -fipa-pta + -Werror=return-type + -Wpointer-arith + -fno-inline-functions + -mtext-section-literals + -mlongcalls + -falign-functions=4 + -ffunction-sections + -fdata-sections" +gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc + $cflags + -I$root/cores/esp8266 \ + -I$root/tools/sdk/include \ + -I$root/variants/generic \ + -I$root/tools/sdk/libc/xtensa-lx106-elf" $gcc --verbose @@ -43,3 +57,90 @@ cat << EOF > sdk.c EOF $gcc -c sdk.c + +cat << EOF > iostream.cpp +#include +void foo() { + std::cout << "hello world"; +} +EOF + +$gcc -c iostream.cpp + +cat << EOF > regex.cpp +#include +#include + +bool bar(std::string v) { + std::regex r("HELLO", std::regex_constants::ECMAScript | std::regex_constants::icase); + if (std::regex_search(v, r)) + return true; + return false; +} +EOF + +$gcc -c regex.cpp + +cp "$root/tools/sdk/ld/eagle.flash.1m.ld" "local.eagle.flash.ld.h" +preprocess=$"$gcc \ + -DFP_IN_IROM \ + -DVTABLES_IN_FLASH \ + -DMMU_IRAM_SIZE=0x8000 \ + -DMMU_ICACHE_SIZE=0x8000 \ + -CC -E -P" + +$preprocess \ + "$root/tools/sdk/ld/eagle.app.v6.common.ld.h" \ + -o "local.eagle.app.v6.common.ld" +step_summary \ + "Default local.eagle.app.v6.common.ld" \ + local.eagle.app.v6.common.ld + +$preprocess \ + "local.eagle.flash.ld.h" \ + -o "local.eagle.flash.ld" +cat local.eagle.flash.ld +step_summary \ + "Default local.eagle.flash.ld" \ + local.eagle.flash.ld + +libs=$"-lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \ +-lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \ +-lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc" +objects="arduino.o coredecls.o features.o sdk.o iostream.o" + +link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc + -nostdlib + -u app_entry + -mlongcalls + -L$cache_dir + -L$root/tools/sdk/lib/NONOSDK305 + -L$root/tools/sdk/lib + -L$root/tools/sdk/ld + -Wl,-EL + -Wl,-T,local.eagle.flash.ld + -Wl,--no-check-sections + -Wl,-Map,xtensa.map + -Wl,--gc-sections + -Wl,--defsym,app_entry=0xaaaaaaaa + -Wl,--defsym,abort=0xfefefefe + -Wl,--defsym,malloc=0xfefefefe + -Wl,--defsym,free=0xfefefefe + -Wl,--defsym,_read_r=0xfefefefe + -Wl,--defsym,_lseek_r=0xfefefefe + -Wl,--defsym,_write_r=0xfefefefe + -Wl,--defsym,_close_r=0xfefefefe + -Wl,--defsym,_free_r=0xfefefefe + -Wl,--defsym,_malloc_r=0xfefefefe + -Wl,--defsym,_realloc_r=0xfefefefe + -Wl,--defsym,_calloc_r=0xfefefefe + -Wl,--defsym,_fstat_r=0xfefefefe + -Wl,--start-group $objects $libs -Wl,--end-group" + +nm=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-nm -C" + +$link -o xtensa.elf +step_summary "CI .elf link map" xtensa.map + +$nm xtensa.elf > symbols.txt +step_summary "CI .elf symbols" symbols.txt From fd679f5c2999660984e9ae734b167f83750c4538 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 9 Aug 2025 21:24:25 +0300 Subject: [PATCH 2/3] cppflags, fix libc override usage (release vs. dev) --- tests/sanity_check.sh | 49 ++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/tests/sanity_check.sh b/tests/sanity_check.sh index 2f1b63b53e..430f5d5765 100755 --- a/tests/sanity_check.sh +++ b/tests/sanity_check.sh @@ -10,30 +10,46 @@ popd pushd "$cache_dir" -cflags=$" - -Os - -g - -free - -fipa-pta - -Werror=return-type - -Wpointer-arith - -fno-inline-functions - -mtext-section-literals - -mlongcalls - -falign-functions=4 - -ffunction-sections - -fdata-sections" -gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc - $cflags +cppflags=$"\ + -DARDUINO \ + -DARDUINO_ESP8266_GENERIC \ + -DF_CPU=80000000L \ + -DNONOSDK305=1 \ + -DLWIP_OPEN_SRC \ + -DTCP_MSS=1460 \ + -DLWIP_IPV4=1 \ + -DLWIP_IPV6=1 \ + -DLWIP_FEATURES=1 \ -I$root/cores/esp8266 \ + -I$root/tools/sdk/lwip2/include \ -I$root/tools/sdk/include \ -I$root/variants/generic \ -I$root/tools/sdk/libc/xtensa-lx106-elf" +cflags=$"\ + -Os \ + -g \ + -free \ + -fipa-pta \ + -Werror=return-type \ + -Wpointer-arith \ + -fno-inline-functions \ + -mtext-section-literals \ + -mlongcalls \ + -falign-functions=4 \ + -ffunction-sections \ + -fdata-sections" +gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc + $cppflags + $cflags" $gcc --verbose set -v -x +cp $root/cores/esp8266/libc_replacements.cpp ./ + +$gcc -c libc_replacements.cpp + cat << EOF > arduino.c #include EOF @@ -99,7 +115,6 @@ step_summary \ $preprocess \ "local.eagle.flash.ld.h" \ -o "local.eagle.flash.ld" -cat local.eagle.flash.ld step_summary \ "Default local.eagle.flash.ld" \ local.eagle.flash.ld @@ -107,7 +122,7 @@ step_summary \ libs=$"-lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \ -lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \ -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc" -objects="arduino.o coredecls.o features.o sdk.o iostream.o" +objects="libc_replacements.o arduino.o coredecls.o features.o sdk.o iostream.o" link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -nostdlib From dd33a61f9029ca528e5afb5ae74a5b93ee3d5fca Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 9 Aug 2025 21:28:41 +0300 Subject: [PATCH 3/3] no summaries for now --- tests/sanity_check.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/sanity_check.sh b/tests/sanity_check.sh index 430f5d5765..c975922167 100755 --- a/tests/sanity_check.sh +++ b/tests/sanity_check.sh @@ -108,16 +108,10 @@ preprocess=$"$gcc \ $preprocess \ "$root/tools/sdk/ld/eagle.app.v6.common.ld.h" \ -o "local.eagle.app.v6.common.ld" -step_summary \ - "Default local.eagle.app.v6.common.ld" \ - local.eagle.app.v6.common.ld $preprocess \ "local.eagle.flash.ld.h" \ -o "local.eagle.flash.ld" -step_summary \ - "Default local.eagle.flash.ld" \ - local.eagle.flash.ld libs=$"-lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \ -lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \ @@ -155,7 +149,3 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc nm=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-nm -C" $link -o xtensa.elf -step_summary "CI .elf link map" xtensa.map - -$nm xtensa.elf > symbols.txt -step_summary "CI .elf symbols" symbols.txt