Skip to content

Commit 79d9c68

Browse files
Add install target, fix newlib
Newlib was not built with the same options as prior ones, so was a little larger than needed. Fix. Add a "rel=2.5.0 subrel=1 ./build install" target that will take and rebuild newlib w/proper arduino prefix, install it, do the same for HAL, copy other libs, and update the platform*.json file. Remove Azure pipelines, it's not fast enough to build this.
1 parent 0983075 commit 79d9c68

File tree

3 files changed

+96
-35
lines changed

3 files changed

+96
-35
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ Pi ESP8266 toolchains in a Docker container.
55

66
## Work In Progesss
77

8-
Builds work for GCC 4.9, not tested for others,
9-
10-
No actual testing of the built chain done yet/
8+
Builds work for GCC 4.8, others not fully tested but were building last time they were tested
119

1210
## Building only native mode binaries
1311

@@ -26,3 +24,10 @@ git clone https://github.com/earlephilhower/esp-quick-toolchain
2624
cd esp-quick-toolchain
2725
docker run --user $(id -u):$(id -g) --rm -v $(pwd):/workdir earlephilhower/gcc-cross bash /workdir/buildall.sh {4.8|4.9|5.2|7.2}
2826
````
27+
28+
Then to install the libraries and headers into the Arduino core (not including the toolchain exes) just
29+
````
30+
rel=2.5.0 subrel=(1...999999) ./build install
31+
<in Arduino dir>
32+
git commit -a
33+
````

azure-pipelines.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

build

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/bin/bash
22

33
rel=${rel:-2.5.0}
4+
subrel=${subrel:-1}
45
make="-j 2"
56
which nproc >& /dev/null && make="-j $(($(nproc) + 1))"
67
gitopt="--depth 1 --single-branch"
78

9+
arduino=${arduino:-$HOME/Arduino/hardware/esp8266com/esp8266}
10+
811
gcc=${gcc:-4.8}
912
case $gcc in
1013
4.8|4.9) isl=0.12.2; xtensa_branch=call0-${gcc}.2;;
@@ -48,20 +51,59 @@ clean()
4851
cleangit lx106-hal
4952
}
5053

51-
set -e
52-
53-
unfinished="zzz-not-fully-built-yet-zzz"
54-
55-
case "$1" in
56-
clean) clean; exit 0;;
57-
build) :;;
58-
*) echo "need 'clean', 'build'"; exit 1;;
59-
esac
6054

55+
install()
56+
{
57+
# Need to rebuild and make install on newlib to get proper headers. Crufty, but we have an odd dir structure
58+
echo "-------- Building installable newlib"
59+
rm -rf arena/newlib-install
60+
mkdir -p arena/newlib-install
61+
(cd arena/newlib-install; ../../dl/newlib-xtensa/configure ${configurenewlibinstall}) &> $log.20.newlib.conf.log
62+
(cd arena/newlib-install; CROSS_CFLAGS="-DSIGNAL_PROVIDED -DABORT_PROVIDED -DMALLOC_PROVIDED" make ${make}) &> $log.21.newlib.make.log
63+
(cd arena/newlib-install; make install) &> $log.22.newlib.install.log
64+
echo "-------- Building installable hal"
65+
rm -rf arena/hal-install
66+
mkdir -p arena/hal-install
67+
(cd arena/hal-install; ../../dl/lx106-hal/configure --prefix=${arduino}/tools/sdk/libc --libdir=${arduino}/tools/sdk/lib --host=xtensa-lx106-elf $(echo ${configure} | sed 's/--host=[a-zA-Z0-9_-]*//' | sed 's/--prefix=[a-zA-Z0-9_-\\]*//')) &> $log.23.hal.conf.log
68+
(cd arena/hal-install; make ${make}) &> $log.24.hal.make.log
69+
(cd arena/hal-install; make install) &> $log.25.hal.install.log
70+
echo "-------- Copying GCC libs"
71+
cp ${installnative}/lib/gcc/xtensa-lx106-elf/*/libgcc.a ${arduino}/tools/sdk/lib/.
72+
cp ${installnative}/xtensa-lx106-elf/lib/libstdc++.a ${arduino}/tools/sdk/lib/.
73+
echo "-------- Copying toolchain directory"
74+
rm -rf ${arduino}/tools/sdk/xtensa-lx106-elf
75+
cp -a ${installnative}/xtensa-lx106-elf ${arduino}/tools/sdk/xtensa-lx106-elf
76+
echo "-------- Updating package.json"
77+
git=$(git rev-parse --short HEAD)
78+
ver=${rel}-${git}-${subrel}
79+
pkgfile=${arduino}/package/package_esp8266com_index.template.json
80+
(cat <<EOF
81+
import glob
82+
import json
83+
import os
84+
with open("$pkgfile") as f:
85+
data = json.load(f)
86+
for i in range(0, len(data["packages"][0]["platforms"][0]["toolsDependencies"])):
87+
if data["packages"][0]["platforms"][0]["toolsDependencies"][i]["name"] == "xtensa-lx106-elf-gcc":
88+
data["packages"][0]["platforms"][0]["toolsDependencies"][i]["version"] = "$ver"
89+
for i in range(0, len(data["packages"][0]["tools"])):
90+
if data["packages"][0]["tools"][i]["name"] == "xtensa-lx106-elf-gcc":
91+
data["packages"][0]["tools"][i]["version"] = "$ver"
92+
data["packages"][0]["tools"][i]["systems"] = []
93+
for j in glob.glob("*xtensa-lx106-elf*"+"$git"+"*json"):
94+
with open(j) as s:
95+
part = json.load(s)
96+
data["packages"][0]["tools"][i]["systems"].append(part)
97+
print json.dumps(data, indent=3, separators=(',',': '))
98+
EOF
99+
) | python > $pkgfile.new
100+
mv -f ${pkgfile}.new ${pkgfile}
101+
echo "Install done"
102+
}
61103

62-
echo "Building GCC-$gcc"
63-
echo "For architecture: $host"
104+
set -e
64105

106+
unfinished="zzz-not-fully-built-yet-zzz"
65107

66108
installnative=$(pwd)/xtensa-lx106-elf.x86_64
67109
install=$(pwd)/xtensa-lx106-elf${EXT}
@@ -83,6 +125,19 @@ configure+=" --disable-bootstrap"
83125
configure+=" --enable-lto"
84126
configure+=" --disable-libstdcxx-verbose"
85127

128+
configurenewlibcom=" --with-newlib --enable-multilib --disable-newlib-io-c99-formats --disable-newlib-supplied-syscalls"
129+
configurenewlibcom+=" --enable-newlib-nano-formatted-io --enable-newlib-reent-small --enable-target-optspace"
130+
configurenewlibcom+=" --disable-option-checking"
131+
configurenewlibcom+=" --target=xtensa-lx106-elf"
132+
configurenewlibcom+=" --disable-shared"
133+
134+
135+
configurenewlibinstall="--prefix=${arduino}/tools/sdk/libc --with-target-subdir=xtensa-lx106-elf"
136+
configurenewlibinstall+=${configurenewlibcom}
137+
138+
configurenewlib="--prefix=${install}"
139+
configurenewlib+=${configurenewlibcom}
140+
86141
if $lto; then
87142
export CFLAGS_FOR_TARGET='-mlongcalls -flto -Wl,-flto -Os -g'
88143
export CXXFLAGS_FOR_TARGET='-mlongcalls -flto -Wl,-flto -Os -g'
@@ -91,18 +146,32 @@ else
91146
export CXXFLAGS_FOR_TARGET='-mlongcalls -Os -g'
92147
fi
93148

149+
export CFLAGS="-I${install}/include -pipe"
150+
export LDFLAGS="-L${install}/lib"
151+
export PATH="${installnative}/bin:${PATH}"
152+
export LD_LIBRARY_PATH="${installnative}/lib"
153+
154+
155+
case "$1" in
156+
clean) clean; exit 0;;
157+
build) :;;
158+
install) install; exit 0;;
159+
*) echo "need 'clean', 'build', or 'install'"; exit 1;;
160+
esac
161+
162+
163+
echo "Building GCC-$gcc"
164+
echo "For architecture: $host"
165+
166+
167+
94168
echo "-------- Checking for required tools"
95169
MISS=0
96170
for i in flex bison autogen makeinfo autoreconf make gcc g++; do
97171
which $i >& /dev/null || ( echo "Missing: $i" && MISS=1 )
98172
done
99173
if [ $MISS -ne 0 ]; then exit; fi
100174

101-
export CFLAGS="-I${install}/include -pipe"
102-
export LDFLAGS="-L${install}/lib"
103-
export PATH="${installnative}/bin:${PATH}"
104-
export LD_LIBRARY_PATH="${installnative}/lib"
105-
106175
mkdir -p arena
107176

108177
if [ ! -r arena/downloaded ]; then
@@ -215,8 +284,8 @@ if [ ! -r arena/gcc/jobdone-newlib ]; then
215284
echo "-------- newlib"
216285
# configure and build newlib
217286
mkdir -p arena/newlib
218-
(cd arena/newlib; ../../dl/newlib-xtensa/configure ${configure}) &> $log.06.newlib.conf.log
219-
(cd arena/newlib; make ${make}) &> $log.07.newlib.make.log
287+
(cd arena/newlib; ../../dl/newlib-xtensa/configure ${configurenewlib}) &> $log.06.newlib.conf.log
288+
(cd arena/newlib; CROSS_CFLAGS="-DSIGNAL_PROVIDED -DABORT_PROVIDED -DMALLOC_PROVIDED" make ${make}) &> $log.07.newlib.make.log
220289
touch arena/gcc/jobdone-newlib
221290
fi
222291
(cd arena/newlib; make install) &> $log.08.newlib.install.log
@@ -264,7 +333,7 @@ tarballsha256=$(sha256sum ${tarball} | cut -f1 -d" ")
264333
echo ' "archiveFileName": "'${tarball}'",' &&
265334
echo ' "checksum": "SHA-256:'${tarballsha256}'",' &&
266335
echo ' "size": "'${tarballsize}'"' &&
267-
echo ' },') > ${tarball}.json
336+
echo ' }') > ${tarball}.json
268337
rm -rf pkg
269338

270339
echo "all done (${install})"

0 commit comments

Comments
 (0)