SDCC: cleanup and update patchset, add debuginfo package

- Relocation patch needed some rework for SDCC 4.2
- Backport an upstream bugfix to fix a compiler crash in one of my projects
- Clean up the other parts of the patchset to prepare for upstream submission
This commit is contained in:
PulkoMandy
2023-05-01 14:21:21 +02:00
parent 941d5953d8
commit eb7afe26c7
2 changed files with 254 additions and 68 deletions

View File

@@ -1,14 +1,26 @@
From 829667eafa493858c979f9f7e8ff23d07f80289c Mon Sep 17 00:00:00 2001
From 66447125e5dfb95c8dd070ef443c1d2f0e640e88 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 14 Sep 2014 12:25:39 +0200
Subject: let sdbinutils know about Haiku.
Subject: Add Haiku to sdbinutils conig.bfd
So we don't get an "unknown operating system" during build.
diff --git a/support/sdbinutils/bfd/config.bfd b/support/sdbinutils/bfd/config.bfd
index 6d34c6d..5ae2396 100644
index 6d34c6d..52c91b0 100644
--- a/support/sdbinutils/bfd/config.bfd
+++ b/support/sdbinutils/bfd/config.bfd
@@ -853,6 +853,9 @@ case "${targ}" in
@@ -811,6 +811,10 @@ case "${targ}" in
want64=true
targ_underscore=no
;;
+ x86_64-*-haiku*)
+ targ_defvec=x86_64_elf64_vec
+ want64=true
+ ;;
x86_64-*-rdos*)
targ_defvec=x86_64_elf64_vec
want64=true
@@ -853,6 +857,9 @@ case "${targ}" in
targ_defvec=i386_elf32_vec
targ_selvecs="iamcu_elf32_vec i386_pe_vec i386_pei_vec"
;;
@@ -19,17 +31,18 @@ index 6d34c6d..5ae2396 100644
targ_defvec=i386_pei_vec
targ_selvecs="i386_pe_vec"
--
2.28.0
2.37.3
From a0d0065ff28aa8b5821aaa4656c8cbebc01d0a48 Mon Sep 17 00:00:00 2001
From aa4c0980ba7455e3d78f31fe3998348cc98c62a6 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 14 Sep 2014 12:26:14 +0200
Subject: Missing include.
Subject: Missing includes.
These are not needed on Linux, but they are on Haiku
diff --git a/sim/ucsim/cmd.src/newcmdposixcl.h b/sim/ucsim/cmd.src/newcmdposixcl.h
index b76fa1f..f6ba7d4 100644
index bba26c5..edb2db7 100644
--- a/sim/ucsim/cmd.src/newcmdposixcl.h
+++ b/sim/ucsim/cmd.src/newcmdposixcl.h
@@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
@@ -40,21 +53,11 @@ index b76fa1f..f6ba7d4 100644
/*
* Command fd console
--
2.28.0
From b38fb6711fbdf9cd381346848227e3e8ccb6d347 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 14 Sep 2014 12:59:31 +0200
Subject: strings.h fix.
diff --git a/sim/ucsim/pobj.cc b/sim/ucsim/pobj.cc
index dbf8d84..16775a2 100644
index 84d8861..cbe486d 100644
--- a/sim/ucsim/pobj.cc
+++ b/sim/ucsim/pobj.cc
@@ -29,6 +29,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
@@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <stdio.h>
#include <stdlib.h>
@@ -63,10 +66,10 @@ index dbf8d84..16775a2 100644
#include "pstr.h"
/*#include "pobjt.h"*/
--
2.28.0
2.37.3
From 30925c99d430b10611c0617858f316221cdac777 Mon Sep 17 00:00:00 2001
From f442eebd423e92de5acb950fd58c74b0459efd6c Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 15 Jan 2017 20:50:32 +0100
Subject: sdcpp: add missing include path
@@ -86,39 +89,20 @@ index cbf4e07..34435cb 100644
malloc realloc calloc free clock, , ,[
#include "ansidecl.h"
--
2.28.0
2.37.3
From dd2c3f9e753ef4b48b9ebe3f78eb0ccb0a8b3389 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 30 Sep 2020 19:00:21 +1000
Subject: Add x64 support
diff --git a/support/sdbinutils/bfd/config.bfd b/support/sdbinutils/bfd/config.bfd
index 5ae2396..52c91b0 100644
--- a/support/sdbinutils/bfd/config.bfd
+++ b/support/sdbinutils/bfd/config.bfd
@@ -811,6 +811,10 @@ case "${targ}" in
want64=true
targ_underscore=no
;;
+ x86_64-*-haiku*)
+ targ_defvec=x86_64_elf64_vec
+ want64=true
+ ;;
x86_64-*-rdos*)
targ_defvec=x86_64_elf64_vec
want64=true
--
2.28.0
From 64c8f32ebb624c1b58a0ab5683eed7577d38a29d Mon Sep 17 00:00:00 2001
From dd799e32d1e14eaebba8c6c6a91615f24695f8aa Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Jan 2016 21:01:19 +0100
Subject: Import Kevin Thacker patch for runtime relocation support.
Subject: Kevin Thacker's patch for runtime relocation support.
This patch is used to build the Contiki operating system for Z80
machines.
This version is modified for SDCC 4.2, the addresses are now internally
stored on 24 bits instead of 16 bits (to help support banked code), and
the code in the patch was adjusted for that.
diff --git a/sdas/linksrc/Makefile.in b/sdas/linksrc/Makefile.in
index 43e16f5..e37b167 100644
@@ -134,7 +118,7 @@ index 43e16f5..e37b167 100644
LKSOURCES = $(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c)
diff --git a/sdas/linksrc/aslink.h b/sdas/linksrc/aslink.h
index ebad061..7dce058 100644
index 94c2b7b..f898a19 100644
--- a/sdas/linksrc/aslink.h
+++ b/sdas/linksrc/aslink.h
@@ -1033,6 +1033,8 @@ extern int yflag; /* -y, enable SDCC Debug output
@@ -147,7 +131,7 @@ index ebad061..7dce058 100644
*/
extern int uflag; /* Listing relocation flag
diff --git a/sdas/linksrc/lkdata.c b/sdas/linksrc/lkdata.c
index e03cd6a..db7c8ff 100644
index 169e8c1..8686631 100644
--- a/sdas/linksrc/lkdata.c
+++ b/sdas/linksrc/lkdata.c
@@ -66,6 +66,9 @@ int oflag; /* Output file type flag
@@ -161,10 +145,10 @@ index e03cd6a..db7c8ff 100644
int jflag; /* NoICE output flag
*/
diff --git a/sdas/linksrc/lkmain.c b/sdas/linksrc/lkmain.c
index fcf7242..5535b95 100644
index daf5515..d690d46 100644
--- a/sdas/linksrc/lkmain.c
+++ b/sdas/linksrc/lkmain.c
@@ -233,6 +233,7 @@ main(int argc, char *argv[])
@@ -212,6 +212,7 @@ main(int argc, char *argv[])
startp->f_idp = "";
pflag = 1;
@@ -172,7 +156,7 @@ index fcf7242..5535b95 100644
for(i=1; i<argc; i++) {
ip = ib;
@@ -999,6 +1000,11 @@ parse()
@@ -979,6 +980,11 @@ parse()
}
return(0);
@@ -315,10 +299,10 @@ index b330184..0a83e0f 100644
lkfclose();
diff --git a/sdas/linksrc/lkrrel.c b/sdas/linksrc/lkrrel.c
new file mode 100644
index 0000000..e9e8383
index 0000000..0d9f943
--- /dev/null
+++ b/sdas/linksrc/lkrrel.c
@@ -0,0 +1,251 @@
@@ -0,0 +1,256 @@
+/* (c) Kevin Thacker, May 2005 */
+#include <stdio.h>
+#include <string.h>
@@ -445,12 +429,15 @@ index 0000000..e9e8383
+{
+ rtval[0] = addr&0x0ff;
+ rtval[1] = (addr>>8)&0x0ff;
+ rtval[2] = byte&0x0ff;
+ addr+=1;
+ rtval[2] = (addr>>16)&0x0ff;
+
+ rtval[3] = byte&0x0ff;
+ addr+=1;
+ rtflg[0] = 1;
+ rtflg[1] = 1;
+ rtflg[2] = 1;
+ rtcnt = 3;
+ rtflg[3] = 1;
+ rtcnt = 4;
+ ixx(1);
+ return addr;
+}
@@ -553,13 +540,15 @@ index 0000000..e9e8383
+ /* re-write offset to relocation records */
+ rtval[0] = 0;
+ rtval[1] = 0;
+ rtval[2] = areasize&0x0ff;
+ rtval[3] = (areasize>>8)&0x0ff;
+ rtval[2] = 0;
+ rtval[3] = areasize&0x0ff;
+ rtval[4] = (areasize>>8)&0x0ff;
+ rtflg[0] = 1;
+ rtflg[1] = 1;
+ rtflg[2] = 1;
+ rtflg[3] = 1;
+ rtcnt = 4;
+ rtflg[4] = 1;
+ rtcnt = 5;
+ ixx(1);
+
+
@@ -594,5 +583,134 @@ index 0000000..ca1cfd4
+void freerelrec();
+void relrecwrite();
--
2.28.0
2.37.3
From 02b6fcf8a92f183f742e1a55ab579dcd40ba1bdf Mon Sep 17 00:00:00 2001
From: PulkoMandy <pulkomandy@pulkomandy.tk>
Date: Mon, 1 May 2023 12:21:48 +0200
Subject: configure.ac: use -gdwarf-3 instead of -ggdb
This works better with Haiku's Debugger
diff --git a/configure.ac b/configure.ac
index cc5309e..7d3d1b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -388,10 +388,10 @@ if test "$ac_cv_c_compiler_gnu" = "yes"; then
rm -f _test_.*)
# This is the first time when CFLAGS are set/modified!!
- sdcc_IS_VALID_OPTION(-ggdb)
- if test "$sdcc_cv_c_ggdb" = "yes"; then
- CFLAGS="-ggdb ${CFLAGS}"
- CXXFLAGS="-ggdb ${CXXFLAGS}"
+ sdcc_IS_VALID_OPTION(-gdwarf-3)
+ if test "$sdcc_cv_c_gdwarf_3" = "yes"; then
+ CFLAGS="-gdwarf-3 ${CFLAGS}"
+ CXXFLAGS="-gdwarf-3 ${CXXFLAGS}"
fi
sdcc_IS_VALID_OPTION(-pipe)
--
2.37.3
From 970de68df98a204b81aa1eacd33ca24a9a1be6eb Mon Sep 17 00:00:00 2001
From: PulkoMandy <pulkomandy@pulkomandy.tk>
Date: Mon, 1 May 2023 12:23:55 +0200
Subject: Do not strip binaries when installing them
This is done already by Haiku packaging when creating the debuginfo
package.
diff --git a/sdas/linksrc/Makefile.in b/sdas/linksrc/Makefile.in
index e37b167..7e7f9ea 100644
--- a/sdas/linksrc/Makefile.in
+++ b/sdas/linksrc/Makefile.in
@@ -87,28 +87,22 @@ $(ASLINK): $(LKOBJECTS)
# ----------------------------------------------------
install: all installdirs
$(INSTALL) $(top_builddir)/bin/sdld$(EXEEXT) $(DESTDIR)$(bindir)/`echo 'sdld' | sed '$(transform)'`$(EXEEXT)
- $(STRIP) $(DESTDIR)$(bindir)/`echo 'sdld' | sed '$(transform)'`$(EXEEXT)
if [ "`grep stm8 $(top_builddir)/ports.build`" = "stm8" ]; \
then \
$(INSTALL) $(top_builddir)/bin/sdldstm8$(EXEEXT) $(DESTDIR)$(bindir)/`echo 'sdldstm8' | sed '$(transform)'`$(EXEEXT); \
- $(STRIP) $(DESTDIR)$(bindir)/`echo 'sdldstm8' | sed '$(transform)'`$(EXEEXT); \
fi
if [ "`grep hc08 $(top_builddir)/ports.build`" = "hc08" ]; \
then \
$(INSTALL) $(top_builddir)/bin/sdld6808$(EXEEXT) $(DESTDIR)$(bindir)/`echo 'sdld6808' | sed '$(transform)'`$(EXEEXT); \
- $(STRIP) $(DESTDIR)$(bindir)/`echo 'sdld6808' | sed '$(transform)'`$(EXEEXT); \
fi
if [ "`grep z80 $(top_builddir)/ports.build`" = "z80" ]; \
then \
$(INSTALL) $(top_builddir)/bin/sdldz80$(EXEEXT) $(DESTDIR)$(bindir)/`echo 'sdldz80' | sed '$(transform)'`$(EXEEXT); \
- $(STRIP) $(DESTDIR)$(bindir)/`echo 'sdldz80' | sed '$(transform)'`$(EXEEXT); \
$(INSTALL) $(top_builddir)/bin/sdldgb$(EXEEXT) $(DESTDIR)$(bindir)/`echo 'sdldgb' | sed '$(transform)'`$(EXEEXT); \
- $(STRIP) $(DESTDIR)$(bindir)/`echo 'sdldgb' | sed '$(transform)'`$(EXEEXT); \
fi
if [ "`grep pdk $(top_builddir)/ports.build`" = "pdk" ]; \
then \
$(INSTALL) $(top_builddir)/bin/sdldpdk$(EXEEXT) $(DESTDIR)$(bindir)/`echo 'sdldpdk' | sed '$(transform)'`$(EXEEXT); \
- $(STRIP) $(DESTDIR)$(bindir)/`echo 'sdldpdk' | sed '$(transform)'`$(EXEEXT); \
fi
# Deleting all the installed files
diff --git a/src/Makefile.in b/src/Makefile.in
index 1533d1f..8f2c2c6 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -69,7 +69,6 @@ $(top_builddir)/support/gc/libgc.a:
# ---------------------------------------------------
install: all installdirs
$(INSTALL) $(TARGET) $(DESTDIR)$(bindir)/`echo sdcc|sed '$(transform)'`$(EXEEXT)
- $(STRIP) $(DESTDIR)$(bindir)/`echo sdcc|sed '$(transform)'`$(EXEEXT)
# Deleting all the installed files
--
2.37.3
From ed45ed6c696d9f250c427d65379ddd1d7e37c52c Mon Sep 17 00:00:00 2001
From: PulkoMandy <pulkomandy@pulkomandy.tk>
Date: Mon, 1 May 2023 14:19:47 +0200
Subject: Backport upstream bugfix r13588
Fix for https://sourceforge.net/p/sdcc/bugs/3401
diff --git a/src/SDCCast.c b/src/SDCCast.c
index 04f2cc1..1dab15c 100644
--- a/src/SDCCast.c
+++ b/src/SDCCast.c
@@ -4060,10 +4060,11 @@ decorateType (ast *tree, RESULT_TYPE resultType, bool reduceTypeAllowed)
if (reduceTypeAllowed &&
IS_LITERAL (RTYPE (tree)) &&
IS_BOOLEAN (LTYPE (tree)) &&
- IS_INTEGRAL (RTYPE (tree)) &&
+ IS_AST_LIT_VALUE (tree->right) &&
resultType == RESULT_TYPE_BOOL &&
tree->opval.op == '^') /* the same source is used by 'bitwise or' */
{
+ wassert (tree->right->type == EX_VALUE);
unsigned long litval = AST_ULONG_VALUE (tree->right);
if (litval == 0 || litval == 1)
{
@@ -4077,11 +4078,11 @@ decorateType (ast *tree, RESULT_TYPE resultType, bool reduceTypeAllowed)
return decorateType (tree, resultType, reduceTypeAllowed);
}
}
-
+
/* OR / XOR char with literal integral, try to reduce integral to CHAR if it fits in a CHAR */
if (reduceTypeAllowed &&
!TARGET_PDK_LIKE && // Temporary fix to avoid bug #3259 - Wrong opcodes
- IS_LITERAL (RTYPE (tree)) &&
+ IS_AST_LIT_VALUE (tree->right) &&
IS_INTEGRAL (RTYPE (tree)) &&
!IS_CHAR (RTYPE (tree)) &&
IS_CHAR(LTYPE(tree)))
--
2.37.3

View File

@@ -9,11 +9,11 @@ other microprocessors."
HOMEPAGE="http://sdcc.sourceforge.net"
COPYRIGHT="1999-2022 Sandeep Dutta"
LICENSE="GNU GPL v2"
REVISION="1"
REVISION="2"
SOURCE_URI="http://sourceforge.net/projects/sdcc/files/sdcc/$portVersion/sdcc-src-$portVersion.tar.bz2"
SOURCE_DIR="sdcc-$portVersion"
CHECKSUM_SHA256="b49bae1d23bcd6057a82c4ffe5613f9cd0cbcfd1e940e9d84c4bfe9df0a8c053"
PATCHES="sdcc-4.0.0.patchset"
PATCHES="sdcc-4.2.0.patchset"
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
@@ -117,6 +117,71 @@ BUILD_PREREQUIRES="
cmd:makeinfo
"
defineDebugInfoPackage sdcc$secondaryArchSuffix \
$prefix/bin/makebin \
$prefix/bin/packihx \
$prefix/bin/s51 \
$prefix/bin/savr \
$prefix/bin/sdar \
$prefix/bin/sdas390 \
$prefix/bin/sdas6500 \
$prefix/bin/sdas6808 \
$prefix/bin/sdas8051 \
$prefix/bin/sdasgb \
$prefix/bin/sdaspdk13 \
$prefix/bin/sdaspdk14 \
$prefix/bin/sdaspdk15 \
$prefix/bin/sdaspdk16 \
$prefix/bin/sdasrab \
$prefix/bin/sdasstm8 \
$prefix/bin/sdastlcs90 \
$prefix/bin/sdasz80 \
$prefix/bin/sdcc \
$prefix/bin/sdcdb \
$prefix/bin/sdcpp \
$prefix/bin/sdld \
$prefix/bin/sdld6808 \
$prefix/bin/sdldgb \
$prefix/bin/sdldpdk \
$prefix/bin/sdldstm8 \
$prefix/bin/sdldz80 \
$prefix/bin/sdnm \
$prefix/bin/sdobjcopy \
$prefix/bin/sdranlib \
$prefix/bin/shc08 \
$prefix/bin/sm6800 \
$prefix/bin/sm6809 \
$prefix/bin/sm68hc08 \
$prefix/bin/sm68hc11 \
$prefix/bin/smos6502 \
$prefix/bin/sp1516 \
$prefix/bin/spblaze \
$prefix/bin/spdk \
$prefix/bin/srxk \
$prefix/bin/sst7 \
$prefix/bin/sstm8 \
$prefix/bin/stlcs \
$prefix/bin/sxa \
$prefix/bin/sz80 \
$prefix/bin/ucsim_51 \
$prefix/bin/ucsim_avr \
$prefix/bin/ucsim_hc08 \
$prefix/bin/ucsim_m6800 \
$prefix/bin/ucsim_m6809 \
$prefix/bin/ucsim_m68hc08 \
$prefix/bin/ucsim_m68hc11 \
$prefix/bin/ucsim_mcs6502 \
$prefix/bin/ucsim_mos6502 \
$prefix/bin/ucsim_p1516 \
$prefix/bin/ucsim_pblaze \
$prefix/bin/ucsim_pdk \
$prefix/bin/ucsim_rxk \
$prefix/bin/ucsim_st7 \
$prefix/bin/ucsim_stm8 \
$prefix/bin/ucsim_tlcs \
$prefix/bin/ucsim_xa \
$prefix/bin/ucsim_z80
BUILD()
{
pushd device/lib/pic16
@@ -139,11 +204,14 @@ BUILD()
autoconf
popd
autoconf
mkdir -p build
pushd build
CFLAGS="-DO_ASYNC=0" \
LDFLAGS="-lnetwork" \
export CFLAGS="-DO_ASYNC=0"
export LDFLAGS="-lnetwork"
runConfigure ../configure \
--bindir=$prefix/bin \
--enable-avr-port \