minimal-bootstrap.tinycc-musl: 0.9.27 -> unstable-2023-04-20

latest tinycc is able to build gcc 4.6.4
This commit is contained in:
Emily Trau 2023-09-24 20:39:58 -07:00
parent c9ba05b20d
commit 0173d3bd90
4 changed files with 71 additions and 34 deletions

View file

@ -0,0 +1,13 @@
--- tccelf.c
+++ tccelf.c
@@ -710,8 +710,9 @@ ST_FUNC int set_elf_sym(Section *s, addr_t value, unsigned long size,
#if 0
printf("new_bind=%x new_shndx=%x new_vis=%x old_bind=%x old_shndx=%x old_vis=%x\n",
sym_bind, shndx, new_vis, esym_bind, esym->st_shndx, esym_vis);
-#endif
tcc_error_noabort("'%s' defined twice", name);
+#endif
+ goto do_patch;
}
} else {
esym->st_other = other;

View file

@ -0,0 +1,21 @@
--- tccgen.c
+++ tccgen.c
@@ -4941,7 +4941,7 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
next();
n = -1;
t1 = 0;
- if (td & TYPE_PARAM) while (1) {
+ while (1) {
/* XXX The optional type-quals and static should only be accepted
in parameter decls. The '*' as well, and then even only
in prototypes (not function defs). */
@@ -4972,7 +4972,8 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
}
break;
- } else if (tok != ']') {
+ }
+ if (tok != ']') {
if (!local_stack || (storage & VT_STATIC))
vpushi(expr_const());
else {

View file

@ -1,9 +1,3 @@
# Build steps adapted from https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/tcc-0.9.27/tcc-musl-pass1.sh
#
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{ lib
, fetchurl
, callPackage
@ -12,38 +6,27 @@
, musl
, gnupatch
, gnutar
, bzip2
, gzip
}:
let
pname = "tinycc-musl";
version = "0.9.27";
version = "unstable-2023-04-20";
rev = "86f3d8e33105435946383aee52487b5ddf918140";
src = fetchurl {
url = "https://download.savannah.gnu.org/releases/tinycc/tcc-${version}.tar.bz2";
hash = "sha256-3iOvePypDOMt/y3UWzQysjNHQLubt7Bb9g/b/Dls65w=";
url = "https://repo.or.cz/tinycc.git/snapshot/${rev}.tar.gz";
hash = "sha256-V3XBXYyzHi9f4JSYGeQwz6+1biUp7cwGaEE+x9fOLYY=";
};
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/424aa5be38a3023aa6842883a3954599b1597986/sysa/tcc-0.9.27/tcc-musl-pass1.sh
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/424aa5be38a3023aa6842883a3954599b1597986/sysa/tcc-0.9.27";
patches = [
(fetchurl {
url = "${liveBootstrap}/patches/ignore-duplicate-symbols.patch";
hash = "sha256-6Js8HkzjYlA8ETxeEYRWu+03OJI60NvR5h1QPkcMTlQ=";
})
(fetchurl {
url = "${liveBootstrap}/patches/ignore-static-inside-array.patch";
hash = "sha256-IF4RevLGjzRBuYqhuyG7+x6SVljzMAsYRKicNsmtbDY=";
})
(fetchurl {
url = "${liveBootstrap}/patches/static-link.patch";
hash = "sha256-gX/hJ9a/0Zg29KIBUme+mOA8WrPQvp0SvojP8DN9mSI=";
})
./ignore-duplicate-symbols.patch
./ignore-static-inside-array.patch
./static-link.patch
];
meta = with lib; {
description = "Small, fast, and embeddable C compiler and interpreter";
homepage = "http://savannah.nongnu.org/projects/tinycc";
homepage = "https://repo.or.cz/w/tinycc.git";
license = licenses.lgpl21Only;
maintainers = teams.minimal-bootstrap.members;
platforms = [ "i686-linux" ];
@ -56,15 +39,12 @@ let
tinycc-bootstrappable.compiler
gnupatch
gnutar
bzip2
gzip
];
} ''
# Unpack
cp ${src} tinycc.tar.bz2
bunzip2 tinycc.tar.bz2
tar xf tinycc.tar
rm tinycc.tar
cd tcc-${version}
tar xzf ${src}
cd tinycc-${builtins.substring 0 7 rev}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
@ -77,6 +57,13 @@ let
# but when linked with musl it is.
ln -s ${musl}/lib/libtcc1.a ./libtcc1.a
tcc \
-B ${tinycc-bootstrappable.libs}/lib \
-DC2STR \
-o c2str \
conftest.c
./c2str include/tccdefs.h tccdefs_.h
tcc -v \
-static \
-o tcc-musl \
@ -92,6 +79,9 @@ let
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \
-B ${tinycc-bootstrappable.libs}/lib \
tcc.c
@ -117,14 +107,17 @@ let
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \
-B ${musl}/lib \
tcc.c
# libtcc1.a
rm -f libtcc1.a
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca86.S
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca86.o
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca.S
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o
# Install
install -D tcc-musl $out/bin/tcc

View file

@ -0,0 +1,10 @@
--- libtcc.c
+++ libtcc.c
@@ -793,6 +793,7 @@ LIBTCCAPI TCCState *tcc_new(void)
s->gnu_ext = 1;
s->tcc_ext = 1;
+ s->static_link = 1;
s->nocommon = 1;
s->dollars_in_identifiers = 1; /*on by default like in gcc/clang*/
s->cversion = 199901; /* default unless -std=c11 is supplied */