build: build SDCC 4.6.0 with two mcs51 fixes in the tree

Released SDCC 4.5.0 and 4.6.0 miscompile some of our code in the mcs51
register allocator (SDCC bugs 4153 and 4154, fixed in trunk r17025 and
r17039). The first make now downloads the 4.6.0 sources, checks their
sha256, applies the two fixes from sdcc/ and installs the compiler into
toolchain/, named after a checksum of sdcc/, so a changed patch builds a
new one. make CC=sdcc still uses an installed compiler.
This commit is contained in:
d00f committed 2026-10-24 21:58:46 +02:00
1 parent bb16302a80
commit 905e588071
7 files changed
+87 -6

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
https://sourceforge.net/p/sdcc/bugs/4153/
Index: src/mcs51/ralloc.c
===================================================================
--- src/mcs51/ralloc.c (revision 17011)
+++ src/mcs51/ralloc.c (working copy)
@@ -1208,7 +1208,7 @@
int change = 0;
/* if the result has been spilt then cannot share */
- if (opsym->isspilt)
+ if (result->isspilt || opsym->isspilt)
return 0;
for (;;)
+24
View File
@@ -0,0 +1,24 @@
https://sourceforge.net/p/sdcc/bugs/4154/
Index: src/mcs51/ralloc.c
===================================================================
--- src/mcs51/ralloc.c (revision 17011)
+++ src/mcs51/ralloc.c (working copy)
@@ -641,6 +641,7 @@
spillThis (symbol * sym)
{
int i;
+ bool ownsRegs = bitVectBitValue (_G.regAssigned, sym->key);
/* if this is rematerializable or has a spillLocation
we are okay, else we need to create a spillLocation
for it */
@@ -658,7 +659,8 @@
{
if (sym->regs[i])
{
- freeReg (sym->regs[i]);
+ if (ownsRegs)
+ freeReg (sym->regs[i]);
sym->regs[i] = NULL;
}
}
Executable
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
set -eu
V=4.6.0
SHA=5fd6a93e5997ce01756868fe35e441095cfb637894a80c262514a634094973b6
PREFIX=$1
D=$(cd "$(dirname "$0")" && pwd)
W=$(mktemp -d)
trap 'rm -rf "$W"' EXIT
curl -fL -o "$W/sdcc.tar.bz2" "https://downloads.sourceforge.net/project/sdcc/sdcc/$V/sdcc-src-$V.tar.bz2"
if command -v sha256sum >/dev/null; then
echo "$SHA $W/sdcc.tar.bz2" | sha256sum -c -
else
echo "$SHA $W/sdcc.tar.bz2" | shasum -a 256 -c -
fi
tar -C "$W" -xjf "$W/sdcc.tar.bz2"
cd "$W/sdcc-$V"
for p in "$D"/*.patch; do
patch -p0 < "$p"
done
off=""
for p in z80 z180 r2k r2ka r3ka r4k r5k r6k sm83 tlcs90 ez80 ez80_z80 z80n r800 ds390 ds400 pic14 pic16 hc08 s08 stm8 pdk13 pdk14 pdk15 mos6502 mos65c02 huc6280 f8 f8l; do
off="$off --disable-$p-port"
done
./configure --prefix="$PREFIX" $off --disable-sdcdb --disable-ucsim --disable-non-free
make -j"$(getconf _NPROCESSORS_ONLN)"
make install