Skip to content

Commit 8771f89

Browse files
authored
Test - linkage sanity check (#9265)
Check GCC building C++ in addition to C code Check that compiler can build and link .elf using default build flags & defines Check for known issue w/ newlib-4.5.0 when expecting wide characters support by attempting to link with libstdc++ while using <iostream> and <regex>
1 parent ec1d3a5 commit 8771f89

File tree

1 file changed

+111
-5
lines changed

1 file changed

+111
-5
lines changed

tests/sanity_check.sh

Lines changed: 111 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,46 @@ popd
1010

1111
pushd "$cache_dir"
1212

13-
gcc="$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc"\
14-
" -I$root/cores/esp8266"\
15-
" -I$root/tools/sdk/include"\
16-
" -I$root/variants/generic"\
17-
" -I$root/tools/sdk/libc/xtensa-lx106-elf"
13+
cppflags=$"\
14+
-DARDUINO \
15+
-DARDUINO_ESP8266_GENERIC \
16+
-DF_CPU=80000000L \
17+
-DNONOSDK305=1 \
18+
-DLWIP_OPEN_SRC \
19+
-DTCP_MSS=1460 \
20+
-DLWIP_IPV4=1 \
21+
-DLWIP_IPV6=1 \
22+
-DLWIP_FEATURES=1 \
23+
-I$root/cores/esp8266 \
24+
-I$root/tools/sdk/lwip2/include \
25+
-I$root/tools/sdk/include \
26+
-I$root/variants/generic \
27+
-I$root/tools/sdk/libc/xtensa-lx106-elf"
28+
cflags=$"\
29+
-Os \
30+
-g \
31+
-free \
32+
-fipa-pta \
33+
-Werror=return-type \
34+
-Wpointer-arith \
35+
-fno-inline-functions \
36+
-mtext-section-literals \
37+
-mlongcalls \
38+
-falign-functions=4 \
39+
-ffunction-sections \
40+
-fdata-sections"
41+
gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
42+
$cppflags
43+
$cflags"
1844

1945
$gcc --verbose
2046

2147
set -v -x
2248

49+
cp $root/cores/esp8266/libc_replacements.cpp ./
50+
51+
$gcc -c libc_replacements.cpp
52+
2353
cat << EOF > arduino.c
2454
#include <Arduino.h>
2555
EOF
@@ -43,3 +73,79 @@ cat << EOF > sdk.c
4373
EOF
4474

4575
$gcc -c sdk.c
76+
77+
cat << EOF > iostream.cpp
78+
#include <iostream>
79+
void foo() {
80+
std::cout << "hello world";
81+
}
82+
EOF
83+
84+
$gcc -c iostream.cpp
85+
86+
cat << EOF > regex.cpp
87+
#include <string>
88+
#include <regex>
89+
90+
bool bar(std::string v) {
91+
std::regex r("HELLO", std::regex_constants::ECMAScript | std::regex_constants::icase);
92+
if (std::regex_search(v, r))
93+
return true;
94+
return false;
95+
}
96+
EOF
97+
98+
$gcc -c regex.cpp
99+
100+
cp "$root/tools/sdk/ld/eagle.flash.1m.ld" "local.eagle.flash.ld.h"
101+
preprocess=$"$gcc \
102+
-DFP_IN_IROM \
103+
-DVTABLES_IN_FLASH \
104+
-DMMU_IRAM_SIZE=0x8000 \
105+
-DMMU_ICACHE_SIZE=0x8000 \
106+
-CC -E -P"
107+
108+
$preprocess \
109+
"$root/tools/sdk/ld/eagle.app.v6.common.ld.h" \
110+
-o "local.eagle.app.v6.common.ld"
111+
112+
$preprocess \
113+
"local.eagle.flash.ld.h" \
114+
-o "local.eagle.flash.ld"
115+
116+
libs=$"-lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \
117+
-lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \
118+
-lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc"
119+
objects="libc_replacements.o arduino.o coredecls.o features.o sdk.o iostream.o"
120+
121+
link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
122+
-nostdlib
123+
-u app_entry
124+
-mlongcalls
125+
-L$cache_dir
126+
-L$root/tools/sdk/lib/NONOSDK305
127+
-L$root/tools/sdk/lib
128+
-L$root/tools/sdk/ld
129+
-Wl,-EL
130+
-Wl,-T,local.eagle.flash.ld
131+
-Wl,--no-check-sections
132+
-Wl,-Map,xtensa.map
133+
-Wl,--gc-sections
134+
-Wl,--defsym,app_entry=0xaaaaaaaa
135+
-Wl,--defsym,abort=0xfefefefe
136+
-Wl,--defsym,malloc=0xfefefefe
137+
-Wl,--defsym,free=0xfefefefe
138+
-Wl,--defsym,_read_r=0xfefefefe
139+
-Wl,--defsym,_lseek_r=0xfefefefe
140+
-Wl,--defsym,_write_r=0xfefefefe
141+
-Wl,--defsym,_close_r=0xfefefefe
142+
-Wl,--defsym,_free_r=0xfefefefe
143+
-Wl,--defsym,_malloc_r=0xfefefefe
144+
-Wl,--defsym,_realloc_r=0xfefefefe
145+
-Wl,--defsym,_calloc_r=0xfefefefe
146+
-Wl,--defsym,_fstat_r=0xfefefefe
147+
-Wl,--start-group $objects $libs -Wl,--end-group"
148+
149+
nm=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-nm -C"
150+
151+
$link -o xtensa.elf

0 commit comments

Comments
 (0)