commit: aa31fbc95b76afe356fa96882061138c1c1c9f1e
parent 246cc10ab5a8378e7c50b86d2ae726bd02bf8385
Author: Andrius Štikonas <andrius@stikonas.eu>
Date: Sun, 28 Mar 2021 00:18:30 +0000
Patch tcc to ignore static inside array.
Diffstat:
11 files changed, 72 insertions(+), 118 deletions(-)
diff --git a/sysa/musl-1.1.24/patches-pass3/tcc_static.patch b/sysa/musl-1.1.24/patches-pass3/tcc_static.patch
@@ -1 +0,0 @@
-../patches/tcc_static.patch
-\ No newline at end of file
diff --git a/sysa/musl-1.1.24/patches/tcc_static.patch b/sysa/musl-1.1.24/patches/tcc_static.patch
@@ -1,112 +0,0 @@
-SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
-SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
-
-SPDX-License-Identifier: MIT
-
-tinycc-0.9.27 does not support the use of the static keyword within an array length or index.
-diff -U3 -r src/internal/syscall.h src/internal/syscall.h
---- src/internal/syscall.h 2019-10-13 22:58:27.000000000 +0100
-+++ src/internal/syscall.h 2021-02-01 00:24:02.099200492 +0000
-@@ -331,7 +331,7 @@
- #define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp,,__VA_ARGS__)
- #define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__))
-
--hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned);
-+hidden void __procfdname(char __buf[15+3*sizeof(int)], unsigned);
-
- hidden void *__vdsosym(const char *, const char *);
-
-diff -U3 -r src/network/lookup.h src/network/lookup.h
---- src/network/lookup.h 2019-10-13 22:58:27.000000000 +0100
-+++ src/network/lookup.h 2021-02-01 00:27:42.695155110 +0000
-@@ -43,9 +43,9 @@
- #define MAXADDRS 48
- #define MAXSERVS 2
-
--hidden int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags);
--hidden int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags);
--hidden int __lookup_ipliteral(struct address buf[static 1], const char *name, int family);
-+hidden int __lookup_serv(struct service buf[MAXSERVS], const char *name, int proto, int socktype, int flags);
-+hidden int __lookup_name(struct address buf[MAXADDRS], char canon[256], const char *name, int family, int flags);
-+hidden int __lookup_ipliteral(struct address buf[1], const char *name, int family);
-
- hidden int __get_resolv_conf(struct resolvconf *, char *, size_t);
- hidden int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *);
-diff -U3 -r src/network/lookup_ipliteral.c src/network/lookup_ipliteral.c
---- src/network/lookup_ipliteral.c 2019-10-13 22:58:27.000000000 +0100
-+++ src/network/lookup_ipliteral.c 2021-02-01 00:27:59.955620933 +0000
-@@ -9,7 +9,7 @@
- #include <ctype.h>
- #include "lookup.h"
-
--int __lookup_ipliteral(struct address buf[static 1], const char *name, int family)
-+int __lookup_ipliteral(struct address buf[1], const char *name, int family)
- {
- struct in_addr a4;
- struct in6_addr a6;
-diff -U3 -r src/network/lookup_name.c src/network/lookup_name.c
---- src/network/lookup_name.c 2019-10-13 22:58:27.000000000 +0100
-+++ src/network/lookup_name.c 2021-02-01 00:28:56.117136509 +0000
-@@ -23,7 +23,7 @@
- return !*s;
- }
-
--static int name_from_null(struct address buf[static 2], const char *name, int family, int flags)
-+static int name_from_null(struct address buf[2], const char *name, int family, int flags)
- {
- int cnt = 0;
- if (name) return 0;
-@@ -41,12 +41,12 @@
- return cnt;
- }
-
--static int name_from_numeric(struct address buf[static 1], const char *name, int family)
-+static int name_from_numeric(struct address buf[1], const char *name, int family)
- {
- return __lookup_ipliteral(buf, name, family);
- }
-
--static int name_from_hosts(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
-+static int name_from_hosts(struct address buf[MAXADDRS], char canon[256], const char *name, int family)
- {
- char line[512];
- size_t l = strlen(name);
-@@ -130,7 +130,7 @@
- return 0;
- }
-
--static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf)
-+static int name_from_dns(struct address buf[MAXADDRS], char canon[256], const char *name, int family, const struct resolvconf *conf)
- {
- unsigned char qbuf[2][280], abuf[2][512];
- const unsigned char *qp[2] = { qbuf[0], qbuf[1] };
-@@ -166,7 +166,7 @@
- return EAI_FAIL;
- }
-
--static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
-+static int name_from_dns_search(struct address buf[MAXADDRS], char canon[256], const char *name, int family)
- {
- char search[256];
- struct resolvconf conf;
-@@ -284,7 +284,7 @@
- return b->sortkey - a->sortkey;
- }
-
--int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags)
-+int __lookup_name(struct address buf[MAXADDRS], char canon[256], const char *name, int family, int flags)
- {
- int cnt = 0, i, j;
-
-diff -U3 -r src/network/lookup_serv.c src/network/lookup_serv.c
---- src/network/lookup_serv.c 2019-10-13 22:58:27.000000000 +0100
-+++ src/network/lookup_serv.c 2021-02-01 00:29:10.357520778 +0000
-@@ -9,7 +9,7 @@
- #include "lookup.h"
- #include "stdio_impl.h"
-
--int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags)
-+int __lookup_serv(struct service buf[MAXSERVS], const char *name, int proto, int socktype, int flags)
- {
- char line[128];
- int cnt = 0;
diff --git a/sysa/tcc-0.9.27/checksums/tcc-musl-pass1 b/sysa/tcc-0.9.27/checksums/tcc-musl-pass1
@@ -1,2 +1,2 @@
-9819c29a2c8259883b4a97d6b57f2fdac87b9807ba9594f7c063601a7fe84af9 /after/bin/tcc-musl
+6a14de323f7c1e7ae473107a607231f89cf60064c09e83a02362369917a1f483 /after/bin/tcc-musl
dd2f569a10a5bce7a8d264a9a04a86be9c3c1293df64c907370a8d5088c21e65 /after/lib/musl/tcc/libtcc1.a
diff --git a/sysa/tcc-0.9.27/checksums/tcc-musl-pass2 b/sysa/tcc-0.9.27/checksums/tcc-musl-pass2
@@ -1,2 +1,2 @@
-0075b156a9dc64b63150b3cc020692f2242e1b4fffebccc743651e0bda4b5ca4 /after/bin/tcc-musl
+c65633cb875609df7aab2225a24334b5853a0b3e097bdb3ba8a0ae80c1bf5bf0 /after/bin/tcc-musl
a650b13efc65073fb851e9db89728089d8845c401f85faaa09801874ab058089 /after/lib/tcc/libtcc1.a
diff --git a/sysa/tcc-0.9.27/checksums/tcc-musl-pass3 b/sysa/tcc-0.9.27/checksums/tcc-musl-pass3
@@ -1,2 +1,2 @@
-fd8fdc967f227f3a8ef4f51226ac8a45b6be78eb0b127d2cdf0a9df0e19451b0 /after/bin/tcc-musl
+068384be93b6654d6ad555881eaf24d221cc3edf229465f050fec30c30648047 /after/bin/tcc-musl
a650b13efc65073fb851e9db89728089d8845c401f85faaa09801874ab058089 /after/lib/tcc/libtcc1.a
diff --git a/sysa/tcc-0.9.27/checksums/tcc-patched b/sysa/tcc-0.9.27/checksums/tcc-patched
@@ -1 +1 @@
-d9dd8e605c8dfd584216e94df4759b1aeb894bdd3d99937bf0eba28cf875e25a /after/bin/tcc
+0bd8c89f8eee4b8e185b404308a79b3cd315a2143f864d7c250a8f088ae1149d /after/bin/tcc
diff --git a/sysa/tcc-0.9.27/patches/ignore-static-inside-array.patch b/sysa/tcc-0.9.27/patches/ignore-static-inside-array.patch
@@ -0,0 +1,59 @@
+SPDX-FileCopyrightText: 2018 Petr Skocik <pskocik@gmail.com>
+
+SPDX-License-Identifier: LGPL-2.0-or-later
+
+From ef668aae1ee2b8bc904c50a13bf58df613b2f0b0 Mon Sep 17 00:00:00 2001
+From: Petr Skocik <pskocik@gmail.com>
+Date: Fri, 23 Mar 2018 13:19:58 +0100
+Subject: [PATCH 1/1] Don't fail on const/restrict/static/* inside []
+
+This patch makes tcc ignore them.
+
+Normally (as per the C standard), They should
+be only applicable inside parameter arrays
+and affect (const/restrict) the pointer the
+array gets converted to.
+
+[matz: fix formatting, add volatile handling, add testcase,
+add comment about above deficiency]
+---
+ tccgen.c | 19 +++++++++++++++++--
+ tests/tests2/100_c99array-decls.c | 34 ++++++++++++++++++++++++++++++++++
+ tests/tests2/100_c99array-decls.expect | 0
+ 3 files changed, 51 insertions(+), 2 deletions(-)
+ create mode 100644 tests/tests2/100_c99array-decls.c
+ create mode 100644 tests/tests2/100_c99array-decls.expect
+
+diff --git tccgen.c tccgen.c
+index 7ed89ac..6ef40e4 100644
+--- tccgen.c
++++ tccgen.c
+@@ -4335,8 +4335,23 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
+ int saved_nocode_wanted = nocode_wanted;
+ /* array definition */
+ next();
+- if (tok == TOK_RESTRICT1)
+- next();
++ 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). */
++ switch (tok) {
++ case TOK_RESTRICT1: case TOK_RESTRICT2: case TOK_RESTRICT3:
++ case TOK_CONST1:
++ case TOK_VOLATILE1:
++ case TOK_STATIC:
++ case '*':
++ next();
++ continue;
++ default:
++ break;
++ }
++ break;
++ }
+ n = -1;
+ t1 = 0;
+ if (tok != ']') {
+--
+2.11.4.GIT
+
diff --git a/sysa/tcc-0.9.27/tcc-musl-pass1.sh b/sysa/tcc-0.9.27/tcc-musl-pass1.sh
@@ -7,6 +7,8 @@ src_unpack() {
}
src_prepare() {
+ # Note that tcc includes static-link and ignore-static-inside-array patches
+ # since we do not build from clean checkout.
patch -Np0 -i ../../patches/ignore-duplicate-symbols.patch
}
diff --git a/sysa/tcc-0.9.27/tcc-musl-pass2.sh b/sysa/tcc-0.9.27/tcc-musl-pass2.sh
@@ -8,6 +8,9 @@ src_unpack() {
}
src_prepare() {
+ # Note that tcc includes static-link and ignore-static-inside-array patches
+ # since we do not build from clean checkout.
+
patch -Np0 -i ../../patches/ignore-duplicate-symbols.patch
}
diff --git a/sysa/tcc-0.9.27/tcc-musl-pass3.sh b/sysa/tcc-0.9.27/tcc-musl-pass3.sh
@@ -8,6 +8,9 @@ src_unpack() {
}
src_prepare() {
+ # Note that tcc includes static-link and ignore-static-inside-array patches
+ # since we do not build from clean checkout.
+
:
}
diff --git a/sysa/tcc-0.9.27/tcc-patched.kaem b/sysa/tcc-0.9.27/tcc-patched.kaem
@@ -11,6 +11,7 @@ cd src/tcc-0.9.27
# Patch
patch -Np0 -i ../../patches/static-link.patch
+patch -Np0 -i ../../patches/ignore-static-inside-array.patch
# Compile
## We have to use 0.9.26 to recompile 0.9.27, 0.9.27 is not self-hosting for