Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d85661

Browse files
authored
Test - correct output format when building & linking (#9266)
Replace .o -> .c.o or .cpp.o, .ld pattern expects source-named objects to place them into ROM instead of IRAM (which would blow up otherwise) Check another known issue w/ newlib-4.0.0 libm which was missing remainder{,f} using existing device test code Actually use the funcs in the resulting .elf via app_entry
1 parent 8771f89 commit 9d85661

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

‎tests/sanity_check.sh‎

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,60 +42,96 @@ gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
4242
$cppflags
4343
$cflags"
4444

45+
function build() {
46+
local f=1ドル
47+
$gcc -c -o "$f".o "$f"
48+
}
49+
4550
$gcc --verbose
4651

4752
set -v -x
4853

4954
cp $root/cores/esp8266/libc_replacements.cpp ./
5055

51-
$gcc -c libc_replacements.cpp
56+
build libc_replacements.cpp
5257

5358
cat << EOF > arduino.c
5459
#include <Arduino.h>
5560
EOF
5661

57-
$gcc -c arduino.c
62+
build arduino.c
5863

5964
cat << EOF > coredecls.c
6065
#include <coredecls.h>
6166
EOF
6267

63-
$gcc -c coredecls.c
68+
build coredecls.c
6469

6570
cat << EOF > features.c
6671
#include <core_esp8266_features.h>
6772
EOF
6873

69-
$gcc -c features.c
74+
build features.c
7075

7176
cat << EOF > sdk.c
7277
#include <version.h>
7378
EOF
7479

75-
$gcc -c sdk.c
80+
build sdk.c
81+
82+
cat << EOF > cmath.cpp
83+
#include <cmath>
84+
85+
bool test_remainder(float x) {
86+
return fabs(std::remainder((float)15.123456, x) - (float)0.123456) < 1e-5;
87+
}
88+
89+
bool test_remainder(double x) {
90+
return std::fabs(std::remainder((double)10.123456, x) - (double)0.123456) < 1e-5;
91+
}
92+
EOF
93+
94+
build cmath.cpp
7695

7796
cat << EOF > iostream.cpp
7897
#include <iostream>
79-
void foo() {
80-
std::cout << "helloworld";
98+
void test_iostream(bool val) {
99+
std::cout << (val ? "hello" : "world") << '\n';
81100
}
82101
EOF
83102

84-
$gcc -c iostream.cpp
103+
build iostream.cpp
85104

86105
cat << EOF > regex.cpp
87106
#include <string>
88107
#include <regex>
89108
90-
bool bar(std::string v) {
109+
bool test_regex(std::string v) {
91110
std::regex r("HELLO", std::regex_constants::ECMAScript | std::regex_constants::icase);
92111
if (std::regex_search(v, r))
93112
return true;
94113
return false;
95114
}
96115
EOF
97116

98-
$gcc -c regex.cpp
117+
build regex.cpp
118+
119+
cat << EOF > app_entry.cpp
120+
#include <string>
121+
122+
bool test_remainder(float);
123+
bool test_remainder(double);
124+
bool test_regex(std::string);
125+
void test_iostream(bool);
126+
127+
extern "C" void app_entry() {
128+
test_iostream(test_remainder(1.23f));
129+
test_iostream(test_remainder(4.56));
130+
test_iostream(test_regex("hello world"));
131+
}
132+
EOF
133+
134+
build app_entry.cpp
99135

100136
cp "$root/tools/sdk/ld/eagle.flash.1m.ld" "local.eagle.flash.ld.h"
101137
preprocess=$"$gcc \
@@ -116,11 +152,11 @@ $preprocess \
116152
libs=$"-lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \
117153
-lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \
118154
-lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc"
119-
objects="libc_replacements.o arduino.o coredecls.o features.o sdk.o iostream.o"
155+
objects=$(find . -name '*.o' -printf ' %f')
120156

121157
link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
122158
-nostdlib
123-
-u app_entry
159+
-uapp_entry
124160
-mlongcalls
125161
-L$cache_dir
126162
-L$root/tools/sdk/lib/NONOSDK305
@@ -131,7 +167,6 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
131167
-Wl,--no-check-sections
132168
-Wl,-Map,xtensa.map
133169
-Wl,--gc-sections
134-
-Wl,--defsym,app_entry=0xaaaaaaaa
135170
-Wl,--defsym,abort=0xfefefefe
136171
-Wl,--defsym,malloc=0xfefefefe
137172
-Wl,--defsym,free=0xfefefefe
@@ -146,6 +181,4 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
146181
-Wl,--defsym,_fstat_r=0xfefefefe
147182
-Wl,--start-group $objects $libs -Wl,--end-group"
148183

149-
nm=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-nm -C"
150-
151184
$link -o xtensa.elf

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /