Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/tinycc: new aport

From: Steffen Nurpmeso <steffen_at_sdaoden.eu>
Date: Fri, 29 Sep 2017 20:34:36 +0200

http://www.tinycc.org
Tiny C Compiler
---
 .../0001-Adjust-va_list-to-work-with-musl.patch    |  46 ++++++
 ...IP-sysinclude-paths-which-are-always-sear.patch | 159 +++++++++++++++++++++
 testing/tinycc/APKBUILD                            |  48 +++++++
 3 files changed, 253 insertions(+)
 create mode 100644 testing/tinycc/0001-Adjust-va_list-to-work-with-musl.patch
 create mode 100644 testing/tinycc/0002-Introduce-VIP-sysinclude-paths-which-are-always-sear.patch
 create mode 100644 testing/tinycc/APKBUILD
diff --git a/testing/tinycc/0001-Adjust-va_list-to-work-with-musl.patch b/testing/tinycc/0001-Adjust-va_list-to-work-with-musl.patch
new file mode 100644
index 0000000..6626368
--- /dev/null
+++ b/testing/tinycc/0001-Adjust-va_list-to-work-with-musl.patch
_at_@ -0,0 +1,46 @@
+From a1c90513131164500f503108a845fee1e8632cc6 Mon Sep 17 00:00:00 2001
+Message-Id: <a1c90513131164500f503108a845fee1e8632cc6.1506781055.git.steffen_at_sdaoden.eu>
+From: Steffen Nurpmeso <steffen_at_sdaoden.eu>
+Date: Sat, 30 Sep 2017 00:11:59 +0200
+Subject: [PATCH 1/2] Adjust va_list to work with musl
+
+---
+ include/stdarg.h | 3 ++-
+ libtcc.c         | 6 +++++-
+ 2 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/include/stdarg.h b/include/stdarg.h
+index 9adfc61..a42acae 100644
+--- a/include/stdarg.h
++++ b/include/stdarg.h
+_at_@ -17,8 +17,9 @@ typedef struct {
+ } __va_list_struct;
+ 
+ /* Avoid conflicting definition for va_list on musl libc */
+-#ifndef __DEFINED_va_list
++#if !defined __DEFINED_va_list || defined __TCC_NEEDS_va_list
+ typedef __va_list_struct va_list[1];
++#undef __DEFINED_va_list
+ #define __DEFINED_va_list
+ #endif
+ 
+diff --git a/libtcc.c b/libtcc.c
+index 41c814d..dcc398f 100644
+--- a/libtcc.c
++++ b/libtcc.c
+_at_@ -854,7 +854,11 @@ LIBTCCAPI TCCState *tcc_new(void)
+ #endif
+ 
+ #if defined(TCC_MUSL)
+-    tcc_define_symbol(s, "__builtin_va_list", "void *");
++    tcc_define_symbol(s, "__TCC_NEEDS_va_list", "");
++    tcc_define_symbol(s, "__builtin_va_list", "va_list");
++    tcc_define_symbol(s, "__DEFINED_va_list", "");
++    tcc_define_symbol(s, "__DEFINED___isoc_va_list", "");
++    tcc_define_symbol(s, "__isoc_va_list", "void *");
+ #endif /* TCC_MUSL */
+ 
+ #ifdef TCC_TARGET_PE
+-- 
+2.14.2
+
diff --git a/testing/tinycc/0002-Introduce-VIP-sysinclude-paths-which-are-always-sear.patch b/testing/tinycc/0002-Introduce-VIP-sysinclude-paths-which-are-always-sear.patch
new file mode 100644
index 0000000..f0afa67
--- /dev/null
+++ b/testing/tinycc/0002-Introduce-VIP-sysinclude-paths-which-are-always-sear.patch
_at_@ -0,0 +1,159 @@
+From 804f5344785e8ba2153ded93b082d7e4d56da908 Mon Sep 17 00:00:00 2001
+Message-Id: <804f5344785e8ba2153ded93b082d7e4d56da908.1506781055.git.steffen_at_sdaoden.eu>
+In-Reply-To: <a1c90513131164500f503108a845fee1e8632cc6.1506781055.git.steffen_at_sdaoden.eu>
+References: <a1c90513131164500f503108a845fee1e8632cc6.1506781055.git.steffen_at_sdaoden.eu>
+From: Steffen Nurpmeso <steffen_at_sdaoden.eu>
+Date: Sat, 30 Sep 2017 00:13:05 +0200
+Subject: [PATCH 2/2] Introduce VIP sysinclude paths which are always searched
+ first
+
+---
+ libtcc.c | 11 ++++++++++-
+ libtcc.h |  3 +++
+ tcc.c    |  2 ++
+ tcc.h    | 18 +++++++++++++-----
+ tccpp.c  | 12 +++++++++---
+ 5 files changed, 37 insertions(+), 9 deletions(-)
+
+diff --git a/libtcc.c b/libtcc.c
+index dcc398f..876e3c4 100644
+--- a/libtcc.c
++++ b/libtcc.c
+_at_@ -906,6 +906,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
+ 
+     /* free include paths */
+     dynarray_reset(&s1->cached_includes, &s1->nb_cached_includes);
++    dynarray_reset(&s1->sysinclude_vip_paths, &s1->nb_sysinclude_vip_paths);
+     dynarray_reset(&s1->include_paths, &s1->nb_include_paths);
+     dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
+     dynarray_reset(&s1->cmd_include_files, &s1->nb_cmd_include_files);
+_at_@ -946,6 +947,7 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
+     if (!s->nostdinc) {
+         /* default include paths */
+         /* -isystem paths have already been handled */
++        tcc_add_sysinclude_vip_path(s, CONFIG_TCC_SYSINCLUDEVIPPATHS);
+         tcc_add_sysinclude_path(s, CONFIG_TCC_SYSINCLUDEPATHS);
+     }
+ 
+_at_@ -983,6 +985,13 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
+     return 0;
+ }
+ 
++LIBTCCAPI int tcc_add_sysinclude_vip_path(TCCState *s, const char *pathname)
++{
++    tcc_split_path(s, &s->sysinclude_vip_paths, &s->nb_sysinclude_vip_paths,
++        pathname);
++    return 0;
++}
++
+ LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname)
+ {
+     tcc_split_path(s, &s->include_paths, &s->nb_include_paths, pathname);
+_at_@ -1821,7 +1830,7 @@ reparse:
+             break;
+         case TCC_OPTION_iwithprefix:
+             snprintf(buf, sizeof buf, "{B}/%s", optarg);
+-            tcc_add_sysinclude_path(s, buf);
++            tcc_add_sysinclude_vip_path(s, buf);
+             break;
+ 	case TCC_OPTION_include:
+ 	    dynarray_add(&s->cmd_include_files,
+diff --git a/libtcc.h b/libtcc.h
+index a1b31e3..b06fb4c 100644
+--- a/libtcc.h
++++ b/libtcc.h
+_at_@ -32,6 +32,9 @@ LIBTCCAPI void tcc_set_options(TCCState *s, const char *str);
+ /*****************************/
+ /* preprocessor */
+ 
++/* add in system include path, searched before anything else */
++LIBTCCAPI int tcc_add_sysinclude_vip_path(TCCState *s, const char *pathname);
++
+ /* add include path */
+ LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
+ 
+diff --git a/tcc.c b/tcc.c
+index 4c7235a..b051ef3 100644
+--- a/tcc.c
++++ b/tcc.c
+_at_@ -181,6 +181,8 @@ static void print_search_dirs(TCCState *s)
+ {
+     printf("install: %s\n", s->tcc_lib_path);
+     /* print_dirs("programs", NULL, 0); */
++    print_dirs("include-first", s->sysinclude_vip_paths,
++        s->nb_sysinclude_vip_paths);
+     print_dirs("include", s->sysinclude_paths, s->nb_sysinclude_paths);
+     print_dirs("libraries", s->library_paths, s->nb_library_paths);
+ #ifndef TCC_TARGET_PE
+diff --git a/tcc.h b/tcc.h
+index c25d342..6534f4b 100644
+--- a/tcc.h
++++ b/tcc.h
+_at_@ -195,13 +195,18 @@ extern long double strtold (const char *__nptr, char **__endptr);
+ /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
+ 
+ /* system include paths */
+-#ifndef CONFIG_TCC_SYSINCLUDEPATHS
++#ifndef CONFIG_TCC_SYSINCLUDEVIPPATHS
+ # ifdef TCC_TARGET_PE
+-#  define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi"
++#  define CONFIG_TCC_SYSINCLUDEVIPPATHS "{B}/include;{B}/include/winapi"
+ # else
++#  define CONFIG_TCC_SYSINCLUDEVIPPATHS "{B}/include"
++# endif
++#endif
++
++#ifndef CONFIG_TCC_SYSINCLUDEPATHS
++# ifndef TCC_TARGET_PE
+ #  define CONFIG_TCC_SYSINCLUDEPATHS \
+-        "{B}/include" \
+-    ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
++    ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
+     ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
+ # endif
+ #endif
+_at_@ -715,7 +720,10 @@ struct TCCState {
+     DLLReference **loaded_dlls;
+     int nb_loaded_dlls;
+ 
+-    /* include paths */
++    /* include paths, search order */
++    char **sysinclude_vip_paths;
++    int nb_sysinclude_vip_paths;
++
+     char **include_paths;
+     int nb_include_paths;
+ 
+diff --git a/tccpp.c b/tccpp.c
+index 39386f4..c3cc5f4 100644
+--- a/tccpp.c
++++ b/tccpp.c
+_at_@ -1803,7 +1803,8 @@ ST_FUNC void preprocess(int is_bof)
+         /* store current file in stack, but increment stack later below */
+         *s1->include_stack_ptr = file;
+         i = tok == TOK_INCLUDE_NEXT ? file->include_next_index : 0;
+-        n = 2 + s1->nb_include_paths + s1->nb_sysinclude_paths;
++        n = 2 + s1->nb_sysinclude_vip_paths + s1->nb_include_paths +
++		s1->nb_sysinclude_paths;
+         for (; i < n; ++i) {
+             char buf1[sizeof file->filename];
+             CachedInclude *e;
+_at_@ -1825,8 +1826,13 @@ ST_FUNC void preprocess(int is_bof)
+ 
+             } else {
+                 /* search in all the include paths */
+-                int j = i - 2, k = j - s1->nb_include_paths;
+-                path = k < 0 ? s1->include_paths[j] : s1->sysinclude_paths[k];
++                int k, j = i - 2;
++		if (j < (k = s1->nb_sysinclude_vip_paths))
++			path = s1->sysinclude_vip_paths[j];
++		else if ((j -= k) < s1->nb_include_paths)
++			path = s1->include_paths[j];
++		else if ((j -= s1->nb_include_paths) < s1->nb_sysinclude_paths)
++			path = s1->sysinclude_paths[j];
+                 pstrcpy(buf1, sizeof(buf1), path);
+                 pstrcat(buf1, sizeof(buf1), "/");
+             }
+-- 
+2.14.2
+
diff --git a/testing/tinycc/APKBUILD b/testing/tinycc/APKBUILD
new file mode 100644
index 0000000..8c74957
--- /dev/null
+++ b/testing/tinycc/APKBUILD
_at_@ -0,0 +1,48 @@
+# Maintainer: Steffen Nurpmeso <steffen_at_sdaoden.eu>
+pkgname=tinycc
+pkgver=2017.09.25
+pkgsha=8deb05c
+pkgrel=0
+pkgdesc="Tiny C Compiler (mob)"
+url="http://www.tinycc.org"
+arch="all"
+license="LGPL2"
+depends=""
+makedepends="perl"
+subpackages="$pkgname-doc"
+source="$pkgname-$pkgver.tar.gz::http://repo.or.cz/tinycc.git/snapshot/8deb05c3e27bb21ad59131a498f197bb84966996.tar.gz
+	0001-Adjust-va_list-to-work-with-musl.patch
+	0002-Introduce-VIP-sysinclude-paths-which-are-always-sear.patch"
+
+builddir="$srcdir/$pkgname-$pkgsha"
+
+# LD_LIBRARY_PATH is included via -rpath, so use system defaults only.
+# And ensure no other paths sneak in.
+unset LIBRARY_PATH LD_RUN_PATH
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+C_INCLUDE_PATH=/usr/include
+LD_LIBRARY_PATH=/lib:/usr/lib
+export PATH C_INCLUDE_PATH LD_LIBRARY_PATH
+
+build() {
+	cd "$builddir"
+	./configure --prefix=/usr --config-musl --with-selinux || return 1
+	sed -E -i'' -e 's/^(.*)makeinfo(.*)/\1: > \2/' Makefile || return 1
+	make
+}
+
+check() {
+	cd "$builddir"
+	make tests
+}
+
+package() {
+	cd "$builddir"
+	make DESTDIR="$pkgdir" install
+
+	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+sha512sums="35690fe3e5b7cfc04cbe0bc7ded6fe84c6ad518b3baff69a5cf10b1f62f9fff7b9684155ce6fecb7a323d802b343649fb225c0d3ed0eb47f39ddb6822c5de8c6  tinycc-2017.09.25.tar.gz
+7f2172fc6195e54786d3b9a9f6cf47d00267688a64846b71df121ea396087d513afac2f30aeb419974a251b974d9c5ec304b8df22fe3fc578dd3b48add4ba869  0001-Adjust-va_list-to-work-with-musl.patch
+0870c002e21ed307703ff2e28ece750a488e297d7e71490473a211f6825a87cfcc6f7bbea67ee3acf9916d0fa434d524adea1f9c5c7538cd75aca57183f2b2a2  0002-Introduce-VIP-sysinclude-paths-which-are-always-sear.patch"
-- 
2.14.2
--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Sat Sep 30 2017 - 16:44:45 GMT