diff options
author | davidovski <david@davidovski.xyz> | 2022-05-31 11:05:19 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-05-31 11:05:19 +0100 |
commit | 48ca75555522716f0f686dcae3dd6cf3d8ad714d (patch) | |
tree | 00c0f58550ba4661e87376f2f02c8001c69bae44 /repo/gcc | |
parent | 871b2b573f01c1b3176a0f65458b3d281b41c437 (diff) |
removed idea of repos
Diffstat (limited to 'repo/gcc')
40 files changed, 3151 insertions, 0 deletions
diff --git a/repo/gcc/0001-posix_memalign.patch b/repo/gcc/0001-posix_memalign.patch new file mode 100644 index 0000000..50d489d --- /dev/null +++ b/repo/gcc/0001-posix_memalign.patch @@ -0,0 +1,42 @@ +From 0f6c64b962bb3bf75f15aec350a9d6f8997fa814 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy <nsz@port70.net> +Date: Fri, 26 Jan 2018 20:32:50 +0000 +Subject: [PATCH] posix_memalign + +--- + gcc/config/i386/pmm_malloc.h | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h +index 87344d9383f..ece428df487 100644 +--- a/gcc/config/i386/pmm_malloc.h ++++ b/gcc/config/i386/pmm_malloc.h +@@ -27,12 +27,13 @@ + #include <stdlib.h> + + /* We can't depend on <stdlib.h> since the prototype of posix_memalign +- may not be visible. */ ++ may not be visible and we can't pollute the namespace either. */ + #ifndef __cplusplus +-extern int posix_memalign (void **, size_t, size_t); ++extern int _mm_posix_memalign (void **, size_t, size_t) + #else +-extern "C" int posix_memalign (void **, size_t, size_t) throw (); ++extern "C" int _mm_posix_memalign (void **, size_t, size_t) throw () + #endif ++__asm__("posix_memalign"); + + static __inline void * + _mm_malloc (size_t __size, size_t __alignment) +@@ -42,7 +43,7 @@ _mm_malloc (size_t __size, size_t __alignment) + return malloc (__size); + if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4)) + __alignment = sizeof (void *); +- if (posix_memalign (&__ptr, __alignment, __size) == 0) ++ if (_mm_posix_memalign (&__ptr, __alignment, __size) == 0) + return __ptr; + else + return NULL; +-- +2.31.1 + diff --git a/repo/gcc/0003-Turn-on-Wl-z-relro-z-now-by-default.patch b/repo/gcc/0003-Turn-on-Wl-z-relro-z-now-by-default.patch new file mode 100644 index 0000000..334d17e --- /dev/null +++ b/repo/gcc/0003-Turn-on-Wl-z-relro-z-now-by-default.patch @@ -0,0 +1,39 @@ +From ef512b8fcf9c7628267ff2dbb127aa094f6754f3 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:45:49 +0000 +Subject: [PATCH] Turn on -Wl,-z,relro,-z,now by default. + +--- + gcc/doc/invoke.texi | 3 +++ + gcc/gcc.c | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index cd31b522e42..17d371ef432 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -14663,6 +14663,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the + linker. When using the GNU linker, you can also get the same effect with + @option{-Wl,-Map=output.map}. + ++NOTE: In Alpine Linux, for LDFLAGS, the option ++@option{-Wl,-z,relro,now} is used. To disable, use @option{-Wl,-z,norelro}. ++ + @item -u @var{symbol} + @opindex u + Pretend the symbol @var{symbol} is undefined, to force linking of +diff --git a/gcc/gcc.c b/gcc/gcc.c +index b2200c5185a..625c9ab7902 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -1039,6 +1039,7 @@ proper position among the other output files. */ + "%{flto|flto=*:%<fcompare-debug*} \ + %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ ++ "-z relro -z now " \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ + %{Wno-poison-system-directories:--no-poison-system-directories} \ +-- +2.31.1 + diff --git a/repo/gcc/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch b/repo/gcc/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch new file mode 100644 index 0000000..4b87403 --- /dev/null +++ b/repo/gcc/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch @@ -0,0 +1,46 @@ +From 3c848f2fbde81db336ec97d9be7a5a4a05015eef Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:46:22 +0000 +Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC, + ObjC++, if the optimization level is > 0 + +--- + gcc/c-family/c-cppbuiltin.c | 4 ++++ + gcc/doc/invoke.texi | 6 ++++++ + 2 files changed, 10 insertions(+) + +diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c +index db91a36794a..ed976c71404 100644 +--- a/gcc/c-family/c-cppbuiltin.c ++++ b/gcc/c-family/c-cppbuiltin.c +@@ -1385,6 +1385,10 @@ c_cpp_builtins (cpp_reader *pfile) + builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); + builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); + ++ /* Fortify Source enabled by default for optimization levels > 0 */ ++ if (optimize) ++ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2); ++ + /* Misc. */ + if (flag_gnu89_inline) + cpp_define (pfile, "__GNUC_GNU_INLINE__"); +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 17d371ef432..fe793ac08db 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -9230,6 +9230,12 @@ also turns on the following optimization flags: + Please note the warning under @option{-fgcse} about + invoking @option{-O2} on programs that use computed gotos. + ++NOTE: In Alpine Linux, @option{-D_FORTIFY_SOURCE=2} is ++set by default, and is activated when @option{-O} is set to 2 or higher. ++This enables additional compile-time and run-time checks for several libc ++functions. To disable, specify either @option{-U_FORTIFY_SOURCE} or ++@option{-D_FORTIFY_SOURCE=0}. ++ + @item -O3 + @opindex O3 + Optimize yet more. @option{-O3} turns on all optimizations specified +-- +2.31.1 + diff --git a/repo/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch b/repo/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch new file mode 100644 index 0000000..aca0075 --- /dev/null +++ b/repo/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch @@ -0,0 +1,34 @@ +From 44b1a01cbe3932122112f38e06a21b1c9efad568 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:47:43 +0000 +Subject: [PATCH] Enable -Wformat and -Wformat-security by default. + +--- + gcc/c-family/c.opt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt +index c49da99d395..93f25319005 100644 +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -599,7 +599,7 @@ Warn about function calls with format strings that write past the end + of the destination region. Same as -Wformat-overflow=1. + + Wformat-security +-C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) ++C ObjC C++ ObjC++ Var(warn_format_security) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) + Warn about possible security problems with format functions. + + Wformat-signedness +@@ -620,7 +620,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ + Warn about zero-length formats. + + Wformat= +-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) ++C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) + Warn about printf/scanf/strftime/strfmon format string anomalies. + + Wformat-overflow= +-- +2.31.1 + diff --git a/repo/gcc/0007-Enable-Wtrampolines-by-default.patch b/repo/gcc/0007-Enable-Wtrampolines-by-default.patch new file mode 100644 index 0000000..515d5e0 --- /dev/null +++ b/repo/gcc/0007-Enable-Wtrampolines-by-default.patch @@ -0,0 +1,25 @@ +From 5679adc04a200e3a1a8dd77466eb79d03da8bf8a Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:48:24 +0000 +Subject: [PATCH] Enable -Wtrampolines by default. + +--- + gcc/common.opt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index ca942863064..0a0ab6195ee 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -774,7 +774,7 @@ Common Var(warn_system_headers) Warning + Do not suppress warnings from system headers. + + Wtrampolines +-Common Var(warn_trampolines) Warning ++Common Var(warn_trampolines) Init(1) Warning + Warn whenever a trampoline is generated. + + Wtype-limits +-- +2.31.1 + diff --git a/repo/gcc/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch b/repo/gcc/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch new file mode 100644 index 0000000..c4cd1fe --- /dev/null +++ b/repo/gcc/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch @@ -0,0 +1,54 @@ +From 27863679bde671cdd354cba398ef71a956873e6a Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:50:33 +0000 +Subject: [PATCH] Ensure that msgfmt doesn't encounter problems during gcc + bootstrapping. + +Solves error messages like the following: + +msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6) + +The libgcc_s.so used during build doesn't satisfy the needs of the +libstdc++.so that msgfmt is linked against. On the other hand, msgfmt +is used as a stand-alone application here, and what library it uses +behind the scenes is of no concern to the gcc build process. +Therefore, simply invoking it "as usual", i.e. without any special +library path, will make it work as expected here. + +2011-09-19 Martin von Gagern + +References: +https://bugs.gentoo.org/372377 +https://bugs.gentoo.org/295480 +--- + libstdc++-v3/po/Makefile.am | 1 + + libstdc++-v3/po/Makefile.in | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/libstdc++-v3/po/Makefile.am b/libstdc++-v3/po/Makefile.am +index a9391d8d167..f7eee24dc8c 100644 +--- a/libstdc++-v3/po/Makefile.am ++++ b/libstdc++-v3/po/Makefile.am +@@ -38,6 +38,7 @@ MSGFMT = msgfmt + EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN) + + .po.mo: ++ env --unset=LD_LIBRARY_PATH \ + $(MSGFMT) -o $@ $< + + all-local: all-local-$(USE_NLS) +diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in +index a0f84b0cfa0..ab24a47a2fd 100644 +--- a/libstdc++-v3/po/Makefile.in ++++ b/libstdc++-v3/po/Makefile.in +@@ -548,6 +548,7 @@ uninstall-am: + + + .po.mo: ++ env --unset=LD_LIBRARY_PATH \ + $(MSGFMT) -o $@ $< + + all-local: all-local-$(USE_NLS) +-- +2.31.1 + diff --git a/repo/gcc/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch b/repo/gcc/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch new file mode 100644 index 0000000..4fbd367 --- /dev/null +++ b/repo/gcc/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch @@ -0,0 +1,28 @@ +From 953779008f2caa78c55f80c2d6096bf627080016 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:52:07 +0000 +Subject: [PATCH] Don't declare asprintf if defined as a macro. + +--- + include/libiberty.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/include/libiberty.h b/include/libiberty.h +index 141cb886a85..fa0e78eb62f 100644 +--- a/include/libiberty.h ++++ b/include/libiberty.h +@@ -645,8 +645,11 @@ extern int pwait (int, int *, int); + /* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. */ + ++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */ ++#ifndef asprintf + extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2; + #endif ++#endif + + /* Like asprintf but allocates memory without fail. This works like + xmalloc. */ +-- +2.31.1 + diff --git a/repo/gcc/0012-libitm-disable-FORTIFY.patch b/repo/gcc/0012-libitm-disable-FORTIFY.patch new file mode 100644 index 0000000..0f262f2 --- /dev/null +++ b/repo/gcc/0012-libitm-disable-FORTIFY.patch @@ -0,0 +1,33 @@ +From 10f38bef9af2e3d6a32253ca18d5ae0123e25e1b Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:53:36 +0000 +Subject: [PATCH] libitm: disable FORTIFY + +--- + libitm/configure.tgt | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/libitm/configure.tgt b/libitm/configure.tgt +index d1beb5c9ec8..c2b50b95c01 100644 +--- a/libitm/configure.tgt ++++ b/libitm/configure.tgt +@@ -47,6 +47,16 @@ if test "$gcc_cv_have_tls" = yes ; then + esac + fi + ++# FIXME: error: inlining failed in call to always_inline ++# ‘int vfprintf(FILE*, const char*, __va_list_tag*)’ ++# : function body can be overwritten at link time ++# Disable Fortify in libitm for now. #508852 ++case "${target}" in ++ *-*-linux*) ++ XCFLAGS="${XCFLAGS} -U_FORTIFY_SOURCE" ++ ;; ++esac ++ + # Map the target cpu to an ARCH sub-directory. At the same time, + # work out any special compilation flags as necessary. + case "${target_cpu}" in +-- +2.31.1 + diff --git a/repo/gcc/0013-libgcc_s.patch b/repo/gcc/0013-libgcc_s.patch new file mode 100644 index 0000000..5569221 --- /dev/null +++ b/repo/gcc/0013-libgcc_s.patch @@ -0,0 +1,57 @@ +From 3614b3586d4a0f75e454943895977a9df1b734d5 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy <nsz@port70.net> +Date: Sat, 24 Oct 2015 20:09:53 +0000 +Subject: [PATCH] libgcc_s + +--- + gcc/config/i386/i386-expand.c | 4 ++-- + libgcc/config/i386/cpuinfo.c | 6 +++--- + libgcc/config/i386/t-linux | 2 +- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c +index 47d52550e5e..9cb8cc7950e 100644 +--- a/gcc/config/i386/i386-expand.c ++++ b/gcc/config/i386/i386-expand.c +@@ -10976,10 +10976,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, + { + case IX86_BUILTIN_CPU_INIT: + { +- /* Make it call __cpu_indicator_init in libgcc. */ ++ /* Make it call __cpu_indicator_init_local in libgcc.a. */ + tree call_expr, fndecl, type; + type = build_function_type_list (integer_type_node, NULL_TREE); +- fndecl = build_fn_decl ("__cpu_indicator_init", type); ++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type); + call_expr = build_call_expr (fndecl, 0); + return expand_expr (call_expr, target, mode, EXPAND_NORMAL); + } +diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c +index 83301a1445f..89fdc7eb587 100644 +--- a/libgcc/config/i386/cpuinfo.c ++++ b/libgcc/config/i386/cpuinfo.c +@@ -516,7 +516,7 @@ __cpu_indicator_init (void) + return 0; + } + +-#if defined SHARED && defined USE_ELF_SYMVER +-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); +-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); ++#ifndef SHARED ++int __cpu_indicator_init_local (void) ++ __attribute__ ((weak, alias ("__cpu_indicator_init"))); + #endif +diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux +index 8506a635790..564296f788e 100644 +--- a/libgcc/config/i386/t-linux ++++ b/libgcc/config/i386/t-linux +@@ -3,5 +3,5 @@ + # t-slibgcc-elf-ver and t-linux + SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver + +-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS) ++HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) + CRTSTUFF_T_CFLAGS += $(CET_FLAGS) +-- +2.31.1 + diff --git a/repo/gcc/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch b/repo/gcc/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch new file mode 100644 index 0000000..b36fa1e --- /dev/null +++ b/repo/gcc/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch @@ -0,0 +1,25 @@ +From c5ee6bb497f640877be668428292487eb026d79e Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:57:09 +0000 +Subject: [PATCH] libffi: use __linux__ instead of __gnu_linux__ for musl + +--- + libffi/src/closures.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libffi/src/closures.c b/libffi/src/closures.c +index 721ff00ea43..22a699c6340 100644 +--- a/libffi/src/closures.c ++++ b/libffi/src/closures.c +@@ -34,7 +34,7 @@ + #include <ffi_common.h> + + #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE +-# if __gnu_linux__ && !defined(__ANDROID__) ++# if __linux__ && !defined(__ANDROID__) + /* This macro indicates it may be forbidden to map anonymous memory + with both write and execute permission. Code compiled when this + option is defined will attempt to map such pages once, but if it +-- +2.31.1 + diff --git a/repo/gcc/0016-dlang-update-zlib-binding.patch b/repo/gcc/0016-dlang-update-zlib-binding.patch new file mode 100644 index 0000000..8a99d5c --- /dev/null +++ b/repo/gcc/0016-dlang-update-zlib-binding.patch @@ -0,0 +1,425 @@ +From b2e1bf216169f470ced86f1f3e95c89debf606cd Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:57:51 +0000 +Subject: [PATCH] dlang: update zlib binding + +--- + libphobos/src/std/zlib.d | 266 ++++++++++++++++++++++++++++----------- + 1 file changed, 196 insertions(+), 70 deletions(-) + +diff --git a/libphobos/src/std/zlib.d b/libphobos/src/std/zlib.d +index e6cce240fd5..bd2fe37ebec 100644 +--- a/libphobos/src/std/zlib.d ++++ b/libphobos/src/std/zlib.d +@@ -1,7 +1,7 @@ + // Written in the D programming language. + + /** +- * Compress/decompress data using the $(HTTP www._zlib.net, _zlib library). ++ * Compress/decompress data using the $(HTTP www.zlib.net, zlib library). + * + * Examples: + * +@@ -43,12 +43,12 @@ + * References: + * $(HTTP en.wikipedia.org/wiki/Zlib, Wikipedia) + * +- * Copyright: Copyright Digital Mars 2000 - 2011. ++ * Copyright: Copyright The D Language Foundation 2000 - 2011. + * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + * Authors: $(HTTP digitalmars.com, Walter Bright) +- * Source: $(PHOBOSSRC std/_zlib.d) ++ * Source: $(PHOBOSSRC std/zlib.d) + */ +-/* Copyright Digital Mars 2000 - 2011. ++/* Copyright The D Language Foundation 2000 - 2011. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) +@@ -75,9 +75,9 @@ enum + + class ZlibException : Exception + { +- this(int errnum) +- { string msg; +- ++ private static string getmsg(int errnum) nothrow @nogc pure @safe ++ { ++ string msg; + switch (errnum) + { + case Z_STREAM_END: msg = "stream end"; break; +@@ -90,7 +90,12 @@ class ZlibException : Exception + case Z_VERSION_ERROR: msg = "version error"; break; + default: msg = "unknown error"; break; + } +- super(msg); ++ return msg; ++ } ++ ++ this(int errnum) ++ { ++ super(getmsg(errnum)); + } + } + +@@ -104,7 +109,7 @@ class ZlibException : Exception + * buf = buffer containing input data + * + * Returns: +- * A $(D uint) checksum for the provided input data and starting checksum ++ * A `uint` checksum for the provided input data and starting checksum + * + * See_Also: + * $(LINK http://en.wikipedia.org/wiki/Adler-32) +@@ -147,7 +152,7 @@ uint adler32(uint adler, const(void)[] buf) + * buf = buffer containing input data + * + * Returns: +- * A $(D uint) checksum for the provided input data and starting checksum ++ * A `uint` checksum for the provided input data and starting checksum + * + * See_Also: + * $(LINK http://en.wikipedia.org/wiki/Cyclic_redundancy_check) +@@ -191,13 +196,14 @@ uint crc32(uint crc, const(void)[] buf) + ubyte[] compress(const(void)[] srcbuf, int level) + in + { +- assert(-1 <= level && level <= 9); ++ assert(-1 <= level && level <= 9, "Compression level needs to be within [-1, 9]."); + } +-body ++do + { + import core.memory : GC; ++ import std.array : uninitializedArray; + auto destlen = srcbuf.length + ((srcbuf.length + 1023) / 1024) + 12; +- auto destbuf = new ubyte[destlen]; ++ auto destbuf = uninitializedArray!(ubyte[])(destlen); + auto err = etc.c.zlib.compress2(destbuf.ptr, &destlen, cast(ubyte *) srcbuf.ptr, srcbuf.length, level); + if (err) + { +@@ -276,7 +282,7 @@ void[] uncompress(const(void)[] srcbuf, size_t destlen = 0u, int winbits = 15) + throw new ZlibException(err); + } + } +- assert(0); ++ assert(0, "Unreachable code"); + } + + @system unittest +@@ -370,9 +376,9 @@ class Compress + this(int level, HeaderFormat header = HeaderFormat.deflate) + in + { +- assert(1 <= level && level <= 9); ++ assert(1 <= level && level <= 9, "Legal compression level are in [1, 9]."); + } +- body ++ do + { + this.level = level; + this.gzip = header == HeaderFormat.gzip; +@@ -406,6 +412,7 @@ class Compress + const(void)[] compress(const(void)[] buf) + { + import core.memory : GC; ++ import std.array : uninitializedArray; + int err; + ubyte[] destbuf; + +@@ -420,7 +427,7 @@ class Compress + inited = 1; + } + +- destbuf = new ubyte[zs.avail_in + buf.length]; ++ destbuf = uninitializedArray!(ubyte[])(zs.avail_in + buf.length); + zs.next_out = destbuf.ptr; + zs.avail_out = to!uint(destbuf.length); + +@@ -461,9 +468,10 @@ class Compress + void[] flush(int mode = Z_FINISH) + in + { +- assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH); ++ assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH, ++ "Mode must be either Z_FINISH, Z_SYNC_FLUSH or Z_FULL_FLUSH."); + } +- body ++ do + { + import core.memory : GC; + ubyte[] destbuf; +@@ -523,6 +531,7 @@ class UnCompress + z_stream zs; + int inited; + int done; ++ bool inputEnded; + size_t destbufsize; + + HeaderFormat format; +@@ -571,16 +580,16 @@ class UnCompress + const(void)[] uncompress(const(void)[] buf) + in + { +- assert(!done); ++ assert(!done, "Buffer has been flushed."); + } +- body ++ do + { ++ if (inputEnded || !buf.length) ++ return null; ++ + import core.memory : GC; ++ import std.array : uninitializedArray; + int err; +- ubyte[] destbuf; +- +- if (buf.length == 0) +- return null; + + if (!inited) + { +@@ -598,26 +607,152 @@ class UnCompress + + if (!destbufsize) + destbufsize = to!uint(buf.length) * 2; +- destbuf = new ubyte[zs.avail_in * 2 + destbufsize]; +- zs.next_out = destbuf.ptr; +- zs.avail_out = to!uint(destbuf.length); +- +- if (zs.avail_in) +- buf = zs.next_in[0 .. zs.avail_in] ~ cast(ubyte[]) buf; ++ auto destbuf = uninitializedArray!(ubyte[])(destbufsize); ++ size_t destFill; + + zs.next_in = cast(ubyte*) buf.ptr; + zs.avail_in = to!uint(buf.length); + +- err = inflate(&zs, Z_NO_FLUSH); +- if (err != Z_STREAM_END && err != Z_OK) ++ while (true) + { +- GC.free(destbuf.ptr); +- error(err); ++ auto oldAvailIn = zs.avail_in; ++ ++ zs.next_out = destbuf[destFill .. $].ptr; ++ zs.avail_out = to!uint(destbuf.length - destFill); ++ ++ err = inflate(&zs, Z_NO_FLUSH); ++ if (err == Z_STREAM_END) ++ { ++ inputEnded = true; ++ break; ++ } ++ else if (err != Z_OK) ++ { ++ GC.free(destbuf.ptr); ++ error(err); ++ } ++ else if (!zs.avail_in) ++ break; ++ ++ /* ++ According to the zlib manual inflate() stops when either there's ++ no more data to uncompress or the output buffer is full ++ So at this point, the output buffer is too full ++ */ ++ ++ destFill = destbuf.length; ++ ++ if (destbuf.capacity) ++ { ++ if (destbuf.length < destbuf.capacity) ++ destbuf.length = destbuf.capacity; ++ else ++ { ++ auto newLength = GC.extend(destbuf.ptr, destbufsize, destbufsize); ++ ++ if (newLength && destbuf.length < destbuf.capacity) ++ destbuf.length = destbuf.capacity; ++ else ++ destbuf.length += destbufsize; ++ } ++ } ++ else ++ destbuf.length += destbufsize; + } ++ + destbuf.length = destbuf.length - zs.avail_out; + return destbuf; + } + ++ // Test for issues 3191 and 9505 ++ @system unittest ++ { ++ import std.algorithm.comparison; ++ import std.array; ++ import std.file; ++ import std.zlib; ++ ++ // Data that can be easily compressed ++ ubyte[1024] originalData; ++ ++ // This should yield a compression ratio of at least 1/2 ++ auto compressedData = compress(originalData, 9); ++ assert(compressedData.length < originalData.length / 2, ++ "The compression ratio is too low to accurately test this situation"); ++ ++ auto chunkSize = compressedData.length / 4; ++ assert(chunkSize < compressedData.length, ++ "The length of the compressed data is too small to accurately test this situation"); ++ ++ auto decompressor = new UnCompress(); ++ ubyte[originalData.length] uncompressedData; ++ ubyte[] reusedBuf; ++ int progress; ++ ++ reusedBuf.length = chunkSize; ++ ++ for (int i = 0; i < compressedData.length; i += chunkSize) ++ { ++ auto len = min(chunkSize, compressedData.length - i); ++ // simulate reading from a stream in small chunks ++ reusedBuf[0 .. len] = compressedData[i .. i + len]; ++ ++ // decompress using same input buffer ++ auto chunk = decompressor.uncompress(reusedBuf); ++ assert(progress + chunk.length <= originalData.length, ++ "The uncompressed result is bigger than the original data"); ++ ++ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[]; ++ progress += chunk.length; ++ } ++ ++ auto chunk = decompressor.flush(); ++ assert(progress + chunk.length <= originalData.length, ++ "The uncompressed result is bigger than the original data"); ++ ++ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[]; ++ progress += chunk.length; ++ ++ assert(progress == originalData.length, ++ "The uncompressed and the original data sizes differ"); ++ assert(originalData[] == uncompressedData[], ++ "The uncompressed and the original data differ"); ++ } ++ ++ @system unittest ++ { ++ ubyte[1024] invalidData; ++ auto decompressor = new UnCompress(); ++ ++ try ++ { ++ auto uncompressedData = decompressor.uncompress(invalidData); ++ } ++ catch (ZlibException e) ++ { ++ assert(e.msg == "data error"); ++ return; ++ } ++ ++ assert(false, "Corrupted data didn't result in an error"); ++ } ++ ++ @system unittest ++ { ++ ubyte[2014] originalData = void; ++ auto compressedData = compress(originalData, 9); ++ ++ auto decompressor = new UnCompress(); ++ auto uncompressedData = decompressor.uncompress(compressedData ~ cast(ubyte[]) "whatever"); ++ ++ assert(originalData.length == uncompressedData.length, ++ "The uncompressed and the original data sizes differ"); ++ assert(originalData[] == uncompressedData[], ++ "The uncompressed and the original data differ"); ++ assert(!decompressor.uncompress("whatever").length, ++ "Compression continued after the end"); ++ } ++ + /** + * Decompress and return any remaining data. + * The returned data should be appended to that returned by uncompress(). +@@ -626,49 +761,40 @@ class UnCompress + void[] flush() + in + { +- assert(!done); ++ assert(!done, "Buffer has been flushed before."); + } + out + { +- assert(done); ++ assert(done, "Flushing failed."); + } +- body ++ do + { +- import core.memory : GC; +- ubyte[] extra; +- ubyte[] destbuf; +- int err; +- + done = 1; +- if (!inited) +- return null; ++ return null; ++ } + +- L1: +- destbuf = new ubyte[zs.avail_in * 2 + 100]; +- zs.next_out = destbuf.ptr; +- zs.avail_out = to!uint(destbuf.length); ++ /// Returns true if all input data has been decompressed and no further data ++ /// can be decompressed (inflate() returned Z_STREAM_END) ++ @property bool empty() const ++ { ++ return inputEnded; ++ } + +- err = etc.c.zlib.inflate(&zs, Z_NO_FLUSH); +- if (err == Z_OK && zs.avail_out == 0) +- { +- extra ~= destbuf; +- goto L1; +- } +- if (err != Z_STREAM_END) +- { +- GC.free(destbuf.ptr); +- if (err == Z_OK) +- err = Z_BUF_ERROR; +- error(err); +- } +- destbuf = destbuf.ptr[0 .. zs.next_out - destbuf.ptr]; +- err = etc.c.zlib.inflateEnd(&zs); +- inited = 0; +- if (err) +- error(err); +- if (extra.length) +- destbuf = extra ~ destbuf; +- return destbuf; ++ /// ++ @system unittest ++ { ++ // some random data ++ ubyte[1024] originalData = void; ++ ++ // append garbage data (or don't, this works in both cases) ++ auto compressedData = cast(ubyte[]) compress(originalData) ~ cast(ubyte[]) "whatever"; ++ ++ auto decompressor = new UnCompress(); ++ auto uncompressedData = decompressor.uncompress(compressedData); ++ ++ assert(uncompressedData[] == originalData[], ++ "The uncompressed and the original data differ"); ++ assert(decompressor.empty, "The UnCompressor reports not being done"); + } + } + +-- +2.31.1 + diff --git a/repo/gcc/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch b/repo/gcc/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch new file mode 100644 index 0000000..b10008f --- /dev/null +++ b/repo/gcc/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch @@ -0,0 +1,51 @@ +From 76c7eb27b9dfe96f2f1db4fa6f29ce28715ad2a4 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:58:22 +0000 +Subject: [PATCH] dlang: fix fcntl on mips, add libucontext dep + +--- + libphobos/configure.tgt | 1 + + libphobos/libdruntime/core/sys/posix/fcntl.d | 15 +++++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt +index 94e42bf5509..73f2e4b7f01 100644 +--- a/libphobos/configure.tgt ++++ b/libphobos/configure.tgt +@@ -35,6 +35,7 @@ case "${target}" in + ;; + mips*-*-linux*) + LIBPHOBOS_SUPPORTED=yes ++ LIBDRUNTIME_NEEDS_UCONTEXT=yes + ;; + power*-*-linux*) + LIBPHOBOS_SUPPORTED=yes +diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d +index 9febcff849b..cb34e2108bd 100644 +--- a/libphobos/libdruntime/core/sys/posix/fcntl.d ++++ b/libphobos/libdruntime/core/sys/posix/fcntl.d +@@ -870,6 +870,21 @@ else version (CRuntime_Musl) + F_SETLKW = 7, + } + } ++ else version (MIPS_Any) ++ { ++ enum ++ { ++ O_DIRECTORY = 0x010000, // octal 0200000 ++ O_NOFOLLOW = 0x020000, // octal 0400000 ++ O_DIRECT = 0x008000, // octal 0100000 ++ O_LARGEFILE = 0x002000, // octal 0020000 ++ O_TMPFILE = 0x410000, // octal 020200000 ++ ++ F_GETLK = 33, ++ F_SETLK = 34, ++ F_SETLKW = 35, ++ } ++ } + else + static assert(0, "Platform not supported"); + +-- +2.31.1 + diff --git a/repo/gcc/0018-ada-fix-shared-linking.patch b/repo/gcc/0018-ada-fix-shared-linking.patch new file mode 100644 index 0000000..83cd1d5 --- /dev/null +++ b/repo/gcc/0018-ada-fix-shared-linking.patch @@ -0,0 +1,42 @@ +From 95fee2cfb1a6a32b7e671861b58ee93978ba16b8 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:59:16 +0000 +Subject: [PATCH] ada: fix shared linking + +--- + gcc/ada/link.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/gcc/ada/link.c b/gcc/ada/link.c +index 02c413a412f..f0e52a87d6e 100644 +--- a/gcc/ada/link.c ++++ b/gcc/ada/link.c +@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir = "lib"; + || defined (__NetBSD__) || defined (__OpenBSD__) \ + || defined (__QNX__) + const char *__gnat_object_file_option = "-Wl,@"; +-const char *__gnat_run_path_option = "-Wl,-rpath,"; +-char __gnat_shared_libgnat_default = STATIC; +-char __gnat_shared_libgcc_default = STATIC; ++const char *__gnat_run_path_option = ""; ++char __gnat_shared_libgnat_default = SHARED; ++char __gnat_shared_libgcc_default = SHARED; + int __gnat_link_max = 8192; + unsigned char __gnat_objlist_file_supported = 1; + const char *__gnat_object_library_extension = ".a"; +@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir = "lib"; + + #elif defined (__linux__) || defined (__GLIBC__) + const char *__gnat_object_file_option = "-Wl,@"; +-const char *__gnat_run_path_option = "-Wl,-rpath,"; +-char __gnat_shared_libgnat_default = STATIC; +-char __gnat_shared_libgcc_default = STATIC; ++const char *__gnat_run_path_option = ""; ++char __gnat_shared_libgnat_default = SHARED; ++char __gnat_shared_libgcc_default = SHARED; + int __gnat_link_max = 8192; + unsigned char __gnat_objlist_file_supported = 1; + const char *__gnat_object_library_extension = ".a"; +-- +2.31.1 + diff --git a/repo/gcc/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch b/repo/gcc/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch new file mode 100644 index 0000000..34c2da1 --- /dev/null +++ b/repo/gcc/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch @@ -0,0 +1,24 @@ +From aa0311c59892d7fbc4ffa9e2f0520391521cc4dd Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 06:59:43 +0000 +Subject: [PATCH] build: fix CXXFLAGS_FOR_BUILD passing + +--- + Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makefile.in b/Makefile.in +index 36e369df6e7..63627db68cf 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -170,6 +170,7 @@ BUILD_EXPORTS = \ + # built for the build system to override those in BASE_FLAGS_TO_PASS. + EXTRA_BUILD_FLAGS = \ + CFLAGS="$(CFLAGS_FOR_BUILD)" \ ++ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ + LDFLAGS="$(LDFLAGS_FOR_BUILD)" + + # This is the list of directories to built for the host system. +-- +2.31.1 + diff --git a/repo/gcc/0020-add-fortify-headers-paths.patch b/repo/gcc/0020-add-fortify-headers-paths.patch new file mode 100644 index 0000000..f445401 --- /dev/null +++ b/repo/gcc/0020-add-fortify-headers-paths.patch @@ -0,0 +1,25 @@ +From 39e86416709d3d34f46da7cd7b8a3e5a8f0ff7cd Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 07:01:06 +0000 +Subject: [PATCH] add fortify-headers paths + +--- + gcc/config/linux.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gcc/config/linux.h b/gcc/config/linux.h +index 95654bcdb5a..d88df8f154a 100644 +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -167,6 +167,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + #ifdef NATIVE_SYSTEM_HEADER_DIR + #define INCLUDE_DEFAULTS_MUSL_NATIVE \ ++ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 2 }, \ ++ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 0 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, + #else +-- +2.31.1 + diff --git a/repo/gcc/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch b/repo/gcc/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch new file mode 100644 index 0000000..073d56f --- /dev/null +++ b/repo/gcc/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch @@ -0,0 +1,31 @@ +From c6b54651688cf062ae48ca3402d6d2e08b70ceed Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Fri, 21 Aug 2020 07:03:00 +0000 +Subject: [PATCH] Alpine musl package provides libssp_nonshared.a. We link to + it unconditionally, as otherwise we get link failures if some objects are + -fstack-protector built and final link happens with -fno-stack-protector. + This seems to be the common case when bootstrapping gcc, the piepatches do + not seem to fully fix the crosstoolchain and bootstrap sequence wrt. + stack-protector flag usage. + +--- + gcc/gcc.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index daeb4d0c8ea..6920bec0fa0 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -894,8 +894,7 @@ proper position among the other output files. */ + + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP +-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +- "|fstack-protector-strong|fstack-protector-explicit:}" ++#define LINK_SSP_SPEC "-lssp_nonshared" + #else + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ +-- +2.31.1 + diff --git a/repo/gcc/0023-Pure-64-bit-MIPS.patch b/repo/gcc/0023-Pure-64-bit-MIPS.patch new file mode 100644 index 0000000..c8f9c98 --- /dev/null +++ b/repo/gcc/0023-Pure-64-bit-MIPS.patch @@ -0,0 +1,47 @@ +From 720c0d7094d27b6cbfe9669c4f65e2021debcb07 Mon Sep 17 00:00:00 2001 +From: Nils Andreas Svee <me@lochnair.net> +Date: Thu, 21 Dec 2017 03:14:33 +0100 +Subject: [PATCH] Pure 64-bit MIPS + +--- + gcc/config/mips/mips.h | 8 ++++---- + gcc/config/mips/t-linux64 | 6 +++--- + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h +index 3ce0c19a29a..b9920b49167 100644 +--- a/gcc/config/mips/mips.h ++++ b/gcc/config/mips/mips.h +@@ -3424,11 +3424,11 @@ struct GTY(()) machine_function { + /* If we are *not* using multilibs and the default ABI is not ABI_32 we + need to change these from /lib and /usr/lib. */ + #if MIPS_ABI_DEFAULT == ABI_N32 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib32/" +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib32/" ++#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" + #elif MIPS_ABI_DEFAULT == ABI_64 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib64/" +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib64/" ++#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" + #endif + + /* Load store bonding is not supported by micromips and fix_24k. The +diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 +index ceb58d3b5f3..8116e23ebba 100644 +--- a/gcc/config/mips/t-linux64 ++++ b/gcc/config/mips/t-linux64 +@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64 + MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el) + MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft) + MULTILIB_OSDIRNAMES = \ +- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \ +- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \ +- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT)) ++ ../lib \ ++ ../lib32 \ ++ ../lib +-- +2.31.1 + diff --git a/repo/gcc/0024-use-pure-64-bit-configuration-where-appropriate.patch b/repo/gcc/0024-use-pure-64-bit-configuration-where-appropriate.patch new file mode 100644 index 0000000..eb592dc --- /dev/null +++ b/repo/gcc/0024-use-pure-64-bit-configuration-where-appropriate.patch @@ -0,0 +1,121 @@ +From c60bb23972769f687dcac689ddf00f88e46b8bb7 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 07:04:40 +0000 +Subject: [PATCH] use pure 64-bit configuration where appropriate + +--- + gcc/config/aarch64/t-aarch64-linux | 2 +- + gcc/config/i386/t-linux64 | 4 ++-- + gcc/config/rs6000/t-linux | 6 ++++-- + gcc/config/rs6000/t-linux64 | 4 ++-- + gcc/config/rs6000/t-linux64bele | 4 ++-- + gcc/config/rs6000/t-linux64lebe | 4 ++-- + gcc/config/s390/t-linux64 | 4 ++-- + 7 files changed, 15 insertions(+), 13 deletions(-) + +diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux +index 83e59e33b85..6ec56fdf6a8 100644 +--- a/gcc/config/aarch64/t-aarch64-linux ++++ b/gcc/config/aarch64/t-aarch64-linux +@@ -22,7 +22,7 @@ LIB1ASMSRC = aarch64/lib1funcs.asm + LIB1ASMFUNCS = _aarch64_sync_cache_range + + AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) +-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) ++MULTILIB_OSDIRNAMES = mabi.lp64=../lib + MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) + + MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) +diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 +index 1171e218578..256f8c079ba 100644 +--- a/gcc/config/i386/t-linux64 ++++ b/gcc/config/i386/t-linux64 +@@ -33,6 +33,6 @@ + comma=, + MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) + MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu) +-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 + MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) +diff --git a/gcc/config/rs6000/t-linux b/gcc/config/rs6000/t-linux +index aeb7440c492..ab14c455d8d 100644 +--- a/gcc/config/rs6000/t-linux ++++ b/gcc/config/rs6000/t-linux +@@ -2,7 +2,8 @@ + # or soft-float. + ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float))) + ifneq (,$(findstring powerpc64,$(target))) +-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + else + MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu) + endif +@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target))) + MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME)) + endif + ifneq (,$(findstring powerpc64le,$(target))) +-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES)) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + endif + endif + +diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 +index 264a7e27524..d1e460811cc 100644 +--- a/gcc/config/rs6000/t-linux64 ++++ b/gcc/config/rs6000/t-linux64 +@@ -28,8 +28,8 @@ + MULTILIB_OPTIONS := m64/m32 + MULTILIB_DIRNAMES := 64 32 + MULTILIB_EXTRA_OPTS := +-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu) +-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + + rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c + $(COMPILE) $< +diff --git a/gcc/config/rs6000/t-linux64bele b/gcc/config/rs6000/t-linux64bele +index 97c1ee6fb4d..08d72639cb6 100644 +--- a/gcc/config/rs6000/t-linux64bele ++++ b/gcc/config/rs6000/t-linux64bele +@@ -2,6 +2,6 @@ + + MULTILIB_OPTIONS += mlittle + MULTILIB_DIRNAMES += le +-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES)))))) +-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES))) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 + MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} +diff --git a/gcc/config/rs6000/t-linux64lebe b/gcc/config/rs6000/t-linux64lebe +index 2e63bdb9fc9..c6e1c5db65d 100644 +--- a/gcc/config/rs6000/t-linux64lebe ++++ b/gcc/config/rs6000/t-linux64lebe +@@ -2,6 +2,6 @@ + + MULTILIB_OPTIONS += mbig + MULTILIB_DIRNAMES += be +-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES)))))) +-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES))) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} +diff --git a/gcc/config/s390/t-linux64 b/gcc/config/s390/t-linux64 +index cc6ab367072..7f498ee1cdc 100644 +--- a/gcc/config/s390/t-linux64 ++++ b/gcc/config/s390/t-linux64 +@@ -7,5 +7,5 @@ + + MULTILIB_OPTIONS = m64/m31 + MULTILIB_DIRNAMES = 64 32 +-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu) +-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 +-- +2.31.1 + diff --git a/repo/gcc/0025-always-build-libgcc_eh.a.patch b/repo/gcc/0025-always-build-libgcc_eh.a.patch new file mode 100644 index 0000000..65324ab --- /dev/null +++ b/repo/gcc/0025-always-build-libgcc_eh.a.patch @@ -0,0 +1,51 @@ +From 00917df4274ea2fb33b08c963a97cf1b28f59dd3 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 07:05:41 +0000 +Subject: [PATCH] always build libgcc_eh.a + +highly inspired by: + http://landley.net/hg/aboriginal/file/7e0747a665ab/sources/patches/gcc-core-libgcceh.patch +--- + libgcc/Makefile.in | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in +index 851e7657d07..99ec513a1a6 100644 +--- a/libgcc/Makefile.in ++++ b/libgcc/Makefile.in +@@ -956,8 +956,9 @@ ifneq ($(LIBUNWIND),) + all: libunwind.a + endif + ++all: libgcc_eh.a + ifeq ($(enable_shared),yes) +-all: libgcc_eh.a libgcc_s$(SHLIB_EXT) ++all: libgcc_s$(SHLIB_EXT) + ifneq ($(LIBUNWIND),) + all: libunwind$(SHLIB_EXT) + libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +@@ -1159,10 +1160,6 @@ install-libunwind: + install-shared: + $(mkinstalldirs) $(DESTDIR)$(inst_libdir) + +- $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ +- chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a +- $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a +- + $(subst @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_base_name@,libgcc_s,$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL)))) +@@ -1179,6 +1176,10 @@ ifeq ($(enable_gcov),yes) + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a + endif + ++ $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ ++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a ++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a ++ + parts="$(INSTALL_PARTS)"; \ + for file in $$parts; do \ + rm -f $(DESTDIR)$(inst_libdir)/$$file; \ +-- +2.31.1 + diff --git a/repo/gcc/0027-ada-musl-support-fixes.patch b/repo/gcc/0027-ada-musl-support-fixes.patch new file mode 100644 index 0000000..0f4ef64 --- /dev/null +++ b/repo/gcc/0027-ada-musl-support-fixes.patch @@ -0,0 +1,223 @@ +From 21692d89e7876dcaecea3e3c961c6504be4a83e9 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Fri, 21 Aug 2020 07:07:48 +0000 +Subject: [PATCH] ada: musl support fixes + +--- + gcc/ada/Makefile.rtl | 10 +++++----- + gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- + gcc/ada/adaint.h | 10 ++++------ + gcc/ada/terminals.c | 8 ++++---- + 4 files changed, 32 insertions(+), 30 deletions(-) + +diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl +index 55ff9b0f3d5..0fadf4e4b79 100644 +--- a/gcc/ada/Makefile.rtl ++++ b/gcc/ada/Makefile.rtl +@@ -1533,7 +1533,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) + s-intman.adb<libgnarl/s-intman__posix.adb \ + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + a-exetim.adb<libgnarl/a-exetim__posix.adb \ + a-exetim.ads<libgnarl/a-exetim__default.ads \ + s-linux.ads<libgnarl/s-linux.ads \ +@@ -2083,7 +2083,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) + s-osinte.adb<libgnarl/s-osinte__posix.adb \ + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.ads<libgnat/system-linux-ppc.ads +@@ -2112,7 +2112,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) + endif + + # ARM linux, GNU eabi +-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),) ++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),) + LIBGNAT_TARGET_PAIRS = \ + a-intnam.ads<libgnarl/a-intnam__linux.ads \ + s-inmaop.adb<libgnarl/s-inmaop__posix.adb \ +@@ -2305,7 +2305,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.ads<libgnat/system-linux-ia64.ads +@@ -2401,7 +2401,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + s-taspri.ads<libgnarl/s-taspri__posix.ads \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(X86_64_TARGET_PAIRS) \ + system.ads<libgnat/system-linux-x86.ads +diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c +index 595abf87d65..00858c24f53 100644 +--- a/gcc/ada/adaint.c ++++ b/gcc/ada/adaint.c +@@ -90,6 +90,11 @@ + #include <sys/param.h> + #include <sys/pstat.h> + #endif ++ ++#if defined (linux) ++#define _GNU_SOURCE 1 ++#include <sched.h> ++#endif + + #ifdef __PikeOS__ + #define __BSD_VISIBLE 1 +@@ -3308,7 +3313,6 @@ __gnat_lwp_self (void) + #endif + + #if defined (__linux__) +-#include <sched.h> + + /* glibc versions earlier than 2.7 do not define the routines to handle + dynamically allocated CPU sets. For these targets, we use the static +@@ -3318,7 +3322,7 @@ __gnat_lwp_self (void) + + /* Dynamic cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count) + { + return CPU_ALLOC (count); +@@ -3331,33 +3335,33 @@ __gnat_cpu_alloc_size (size_t count) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { +- CPU_FREE (set); ++ CPU_FREE ((cpu_set_t *) set); + } + + void +-__gnat_cpu_zero (size_t count, cpu_set_t *set) ++__gnat_cpu_zero (size_t count, void *set) + { +- CPU_ZERO_S (count, set); ++ CPU_ZERO_S (count, (cpu_set_t *) set); + } + + void +-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET_S (cpu - 1, count, set); ++ CPU_SET_S (cpu - 1, count, (cpu_set_t *) set); + } + + #else /* !CPU_ALLOC */ + + /* Static cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) + { +- return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); ++ return xmalloc (sizeof (cpu_set_t)); + } + + size_t +@@ -3367,23 +3371,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { + free (set); + } + + void +-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) + { +- CPU_ZERO (set); ++ CPU_ZERO ((cpu_set_t *) set); + } + + void +-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET (cpu - 1, set); ++ CPU_SET (cpu - 1, (cpu_set_t *) set); + } + #endif /* !CPU_ALLOC */ + #endif /* __linux__ */ +diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h +index 311e240dfcc..1c4d0050103 100644 +--- a/gcc/ada/adaint.h ++++ b/gcc/ada/adaint.h +@@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void); + + /* Routines for interface to required CPU set primitives */ + +-#include <sched.h> +- +-extern cpu_set_t *__gnat_cpu_alloc (size_t); ++extern void * __gnat_cpu_alloc (size_t); + extern size_t __gnat_cpu_alloc_size (size_t); +-extern void __gnat_cpu_free (cpu_set_t *); +-extern void __gnat_cpu_zero (size_t, cpu_set_t *); +-extern void __gnat_cpu_set (int, size_t, cpu_set_t *); ++extern void __gnat_cpu_free (void *); ++extern void __gnat_cpu_zero (size_t, void *); ++extern void __gnat_cpu_set (int, size_t, void *); + #endif + + #if defined (_WIN32) +diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c +index af4417fab90..bab6bf3ca87 100644 +--- a/gcc/ada/terminals.c ++++ b/gcc/ada/terminals.c +@@ -1145,7 +1145,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns) + /* POSIX does not specify how to open the master side of a terminal.Several + methods are available (system specific): + 1- using a cloning device (USE_CLONE_DEVICE) +- 2- getpt (USE_GETPT) ++ 2- posix_openpt (USE_POSIX_OPENPT) + 3- openpty (USE_OPENPTY) + + When using the cloning device method, the macro USE_CLONE_DEVICE should +@@ -1159,7 +1159,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns) + #if defined (__APPLE__) || defined (BSD) + #define USE_OPENPTY + #elif defined (__linux__) +-#define USE_GETPT ++#define USE_POSIX_OPENPT + #elif defined (__sun__) + #define USE_CLONE_DEVICE "/dev/ptmx" + #elif defined (_AIX) +@@ -1208,8 +1208,8 @@ allocate_pty_desc (pty_desc **desc) { + int master_fd = -1; + char *slave_name = NULL; + +-#ifdef USE_GETPT +- master_fd = getpt (); ++#if defined(USE_POSIX_OPENPT) ++ master_fd = posix_openpt(O_RDWR | O_NOCTTY); + #elif defined (USE_OPENPTY) + status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); + #elif defined (USE_CLONE_DEVICE) +-- +2.31.1 + diff --git a/repo/gcc/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch b/repo/gcc/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch new file mode 100644 index 0000000..2932ce7 --- /dev/null +++ b/repo/gcc/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch @@ -0,0 +1,48 @@ +From 1852ae06e733180f090b58c267bde8fb9501a41e Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Sun, 30 Aug 2020 17:58:08 +0200 +Subject: [PATCH] gcc-go: Use _off_t type instead of _loff_t +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/go/syscall/libcall_linux.go | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go +index 88286c07b6e..f8f5cfb5011 100644 +--- a/libgo/go/syscall/libcall_linux.go ++++ b/libgo/go/syscall/libcall_linux.go +@@ -206,19 +206,19 @@ func Gettid() (tid int) { + //sys Setxattr(path string, attr string, data []byte, flags int) (err error) + //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int + +-//sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error) +-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t ++//sys splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error) ++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t + func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { +- var lroff _loff_t +- var plroff *_loff_t ++ var lroff _off_t ++ var plroff *_off_t + if roff != nil { +- lroff = _loff_t(*roff) ++ lroff = _off_t(*roff) + plroff = &lroff + } +- var lwoff _loff_t +- var plwoff *_loff_t ++ var lwoff _off_t ++ var plwoff *_off_t + if woff != nil { +- lwoff = _loff_t(*woff) ++ lwoff = _off_t(*woff) + plwoff = &lwoff + } + n, err = splice(rfd, plroff, wfd, plwoff, len, flags) +-- +2.31.1 + diff --git a/repo/gcc/0029-gcc-go-Don-t-include-sys-user.h.patch b/repo/gcc/0029-gcc-go-Don-t-include-sys-user.h.patch new file mode 100644 index 0000000..5f2cb2d --- /dev/null +++ b/repo/gcc/0029-gcc-go-Don-t-include-sys-user.h.patch @@ -0,0 +1,30 @@ +From 40322de36043aaa3cbb98d7f01037f53fc1b5a98 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Sun, 30 Aug 2020 17:58:21 +0200 +Subject: [PATCH] gcc-go: Don't include sys/user.h +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/sysinfo.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c +index 0692fd41eb7..c8d987358d9 100644 +--- a/libgo/sysinfo.c ++++ b/libgo/sysinfo.c +@@ -73,9 +73,6 @@ + #include <sys/times.h> + #include <sys/wait.h> + #include <sys/un.h> +-#if defined(HAVE_SYS_USER_H) +-#include <sys/user.h> +-#endif + #if defined(HAVE_SYS_UTSNAME_H) + #include <sys/utsname.h> + #endif +-- +2.31.1 + diff --git a/repo/gcc/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch b/repo/gcc/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch new file mode 100644 index 0000000..37fa522 --- /dev/null +++ b/repo/gcc/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch @@ -0,0 +1,29 @@ +From f1503cf97b5a5c6f9466145f5eb1ed3b5f200119 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Sun, 30 Aug 2020 17:59:22 +0200 +Subject: [PATCH] gcc-go: Fix ucontext_t on PPC64 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/runtime/go-signal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c +index b429fdb2403..fd1c885f043 100644 +--- a/libgo/runtime/go-signal.c ++++ b/libgo/runtime/go-signal.c +@@ -224,7 +224,7 @@ getSiginfo(siginfo_t *info, void *context __attribute__((unused))) + #elif defined(__alpha__) && defined(__linux__) + ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.sc_pc; + #elif defined(__PPC__) && defined(__linux__) +- ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip; ++ ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gp_regs[32]; + #elif defined(__PPC__) && defined(_AIX) + ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.jmp_context.iar; + #elif defined(__aarch64__) && defined(__linux__) +-- +2.31.1 + diff --git a/repo/gcc/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch b/repo/gcc/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch new file mode 100644 index 0000000..dca7043 --- /dev/null +++ b/repo/gcc/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch @@ -0,0 +1,43 @@ +From fc950e32b9ebc2bae09604ebe630df6df454151d Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Sun, 30 Aug 2020 17:59:45 +0200 +Subject: [PATCH] gcc-go: Fix handling of signal 34 on musl +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/mksigtab.sh | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/libgo/mksigtab.sh b/libgo/mksigtab.sh +index 11e4ec436bd..fe866eacb27 100644 +--- a/libgo/mksigtab.sh ++++ b/libgo/mksigtab.sh +@@ -82,7 +82,7 @@ checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}' + checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}' + checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}' + checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}' +-checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' ++#checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' + checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}' + checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}' + checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}' +@@ -95,10 +95,12 @@ checksig _SIGLOST ' {_SigNotify, "SIGLOST: resource lost (Sun); server died (G + + # Special handling of signals 32 and 33 on GNU/Linux systems, + # because they are special to glibc. ++# Signal 34 is additionally special to Linux systems with musl. + if test "${GOOS}" = "linux"; then +- SIGLIST=$SIGLIST"_32__33_" ++ SIGLIST=$SIGLIST"_32__33__34_" + echo ' 32: {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */' + echo ' 33: {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */' ++ echo ' 34: {_SigSetStack + _SigUnblock, "signal 34"}, /* see issue 30062 */' + fi + + if test "${GOOS}" = "aix"; then +-- +2.31.1 + diff --git a/repo/gcc/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch b/repo/gcc/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch new file mode 100644 index 0000000..918d6b0 --- /dev/null +++ b/repo/gcc/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch @@ -0,0 +1,38 @@ +From 3be2284d92c560204e9eddb20db56d57fe584360 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Sun, 30 Aug 2020 18:01:03 +0200 +Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/go/runtime/mem_gccgo.go | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go +index ba38ebaa9ab..3c9e5ce9461 100644 +--- a/libgo/go/runtime/mem_gccgo.go ++++ b/libgo/go/runtime/mem_gccgo.go +@@ -15,7 +15,7 @@ import ( + //go:linkname sysFree + + //extern mmap +-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer ++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer + + //extern munmap + func munmap(addr unsafe.Pointer, length uintptr) int32 +@@ -37,7 +37,7 @@ func init() { + } + } + +-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { ++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) { + p := sysMmap(addr, n, prot, flags, fd, off) + if uintptr(p) == _MAP_FAILED { + return nil, errno() +-- +2.31.1 + diff --git a/repo/gcc/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch b/repo/gcc/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch new file mode 100644 index 0000000..abb3f3f --- /dev/null +++ b/repo/gcc/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch @@ -0,0 +1,30 @@ +From 382d4516db8a7c183e9d7b5ec16a9bc175523ac9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Sun, 30 Aug 2020 19:26:53 +0200 +Subject: [PATCH] gcc-go: Prefer _off_t over _off64_t + +musl does not seem to have _off64_t. +--- + libgo/mksysinfo.sh | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 972e2c379bc..8d6da15f983 100755 +--- a/libgo/mksysinfo.sh ++++ b/libgo/mksysinfo.sh +@@ -379,11 +379,7 @@ fi + # Some basic types. + echo 'type Size_t _size_t' >> ${OUT} + echo "type Ssize_t _ssize_t" >> ${OUT} +-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then +- echo "type Offset_t _off64_t" >> ${OUT} +-else +- echo "type Offset_t _off_t" >> ${OUT} +-fi ++echo "type Offset_t _off_t" >> ${OUT} + echo "type Mode_t _mode_t" >> ${OUT} + echo "type Pid_t _pid_t" >> ${OUT} + echo "type Uid_t _uid_t" >> ${OUT} +-- +2.31.1 + diff --git a/repo/gcc/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch b/repo/gcc/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch new file mode 100644 index 0000000..0e17708 --- /dev/null +++ b/repo/gcc/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch @@ -0,0 +1,27 @@ +From 79d8ab42aefb1d3c5f794f51df643ab040c30e30 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Sun, 30 Aug 2020 19:27:51 +0200 +Subject: [PATCH] gcc-go: undef SETCONTEXT_CLOBBERS_TLS in proc.c + +--- + libgo/runtime/proc.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c +index 6f7d2e27996..5afd7902497 100644 +--- a/libgo/runtime/proc.c ++++ b/libgo/runtime/proc.c +@@ -66,6 +66,10 @@ static void gscanstack(G*); + + __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); + ++/* libucontext does not seem to support tlsbase, undef the macro ++ * here to make sure we define initcontext and fixcontext as dummies. */ ++#undef SETCONTEXT_CLOBBERS_TLS ++ + #ifndef SETCONTEXT_CLOBBERS_TLS + + static inline void +-- +2.31.1 + diff --git a/repo/gcc/0037-gcc-go-link-to-libucontext.patch b/repo/gcc/0037-gcc-go-link-to-libucontext.patch new file mode 100644 index 0000000..b81d8bf --- /dev/null +++ b/repo/gcc/0037-gcc-go-link-to-libucontext.patch @@ -0,0 +1,25 @@ +From d42de24395e4f07cf6412896d4cd8c7f83a9b875 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Mon, 31 Aug 2020 08:59:40 +0200 +Subject: [PATCH] gcc-go: link to libucontext + +--- + Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 63627db68cf..c7f1f84d683 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -48823,7 +48823,7 @@ configure-target-libgo: + esac; \ + module_srcdir=libgo; \ + rm -f no-such-file || : ; \ +- CONFIG_SITE=no-such-file $(SHELL) \ ++ CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \ + $$s/$$module_srcdir/configure \ + --srcdir=$${topdir}/$$module_srcdir \ + $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +-- +2.31.1 + diff --git a/repo/gcc/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch b/repo/gcc/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch new file mode 100644 index 0000000..15acfdb --- /dev/null +++ b/repo/gcc/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch @@ -0,0 +1,26 @@ +From 570cd2b596daf12e8dfe1a444fe405a7c26fc2bc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Mon, 31 Aug 2020 20:26:56 +0200 +Subject: [PATCH] gcc-go: Disable printing of unaccessible ppc64 struct members + +These struct members do not seem to exist on musl. +--- + libgo/runtime/go-signal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c +index fd1c885f043..e845e453332 100644 +--- a/libgo/runtime/go-signal.c ++++ b/libgo/runtime/go-signal.c +@@ -333,7 +333,7 @@ dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((u + runtime_printf("sp %X\n", m->sc_regs[30]); + runtime_printf("pc %X\n", m->sc_pc); + } +-#elif defined(__PPC__) && defined(__LITTLE_ENDIAN__) && defined(__linux__) ++#elif defined(__PPC__) && defined(__LITTLE_ENDIAN__) && defined(__GLIBC__) + { + mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext; + int i; +-- +2.31.1 + diff --git a/repo/gcc/0041-Use-generic-errstr.go-implementation-on-musl.patch b/repo/gcc/0041-Use-generic-errstr.go-implementation-on-musl.patch new file mode 100644 index 0000000..222513d --- /dev/null +++ b/repo/gcc/0041-Use-generic-errstr.go-implementation-on-musl.patch @@ -0,0 +1,48 @@ +From 70d70a1106b31ab840dbf5361312af221a2d5f04 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Mon, 19 Apr 2021 07:21:41 +0200 +Subject: [PATCH] Use generic errstr.go implementation on musl + +glibc provides two version of strerror_r() depending on a feature test +macro. The first is the XSI-compliant version which returns an int, the +second is GNU-specific and returns a char pointer. + +Similarity, gcc's libgo provides two implementations of Errstr() both of +which use strerror_r(). On Linux, it is assumed that the GNU-specific +strerror_r version is used. However, musl only provides the +XSI-compliant version of strerror_r. This patch enables the generic +Errstr() implementation which also uses the XSI-compliant version of +strerror_r. +--- + libgo/go/syscall/errstr.go | 1 - + libgo/go/syscall/errstr_glibc.go | 2 +- + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go +index 6c2441d364d..8f7c5538163 100644 +--- a/libgo/go/syscall/errstr.go ++++ b/libgo/go/syscall/errstr.go +@@ -5,7 +5,6 @@ + // license that can be found in the LICENSE file. + + // +build !hurd +-// +build !linux + + package syscall + +diff --git a/libgo/go/syscall/errstr_glibc.go b/libgo/go/syscall/errstr_glibc.go +index 5b19e6f202d..8dc60172186 100644 +--- a/libgo/go/syscall/errstr_glibc.go ++++ b/libgo/go/syscall/errstr_glibc.go +@@ -7,7 +7,7 @@ + // We use this rather than errstr.go because on GNU/Linux sterror_r + // returns a pointer to the error message, and may not use buf at all. + +-// +build hurd linux ++// +build hurd !linux + + package syscall + +-- +2.31.1 + diff --git a/repo/gcc/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch b/repo/gcc/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch new file mode 100644 index 0000000..96deb51 --- /dev/null +++ b/repo/gcc/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch @@ -0,0 +1,21 @@ +From: Alpine Linux community +From: Olsken (updated patches) +Date: Sat, 21 Aug 2021 08:51:52 +0000 + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index bc1bd1686..b5c83977f 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -1005,6 +1005,12 @@ proper position among the other output files. */ + #define NO_SSP_SPEC "" + #endif + ++#ifdef ENABLE_DEFAULT_SSP ++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} " ++#else ++#define NO_SSP_SPEC "" ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ diff --git a/repo/gcc/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch b/repo/gcc/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch new file mode 100644 index 0000000..762c6ef --- /dev/null +++ b/repo/gcc/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch @@ -0,0 +1,21 @@ +From: Alpine Linux community +From: Olsken (updated patches) +Date: Sat, 21 Aug 2021 08:51:52 +0000 + +diff --git a/gcc/config.in b/gcc/config.in +index d0287d4cc..8c10816c4 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -112,6 +112,12 @@ + #endif + + ++/* Define if libatomic should always be linked. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_AUTOLINK_LIBATOMIC ++#endif ++ ++ + /* Define to 1 to specify that we are using the BID decimal floating point + format instead of DPD */ + #ifndef USED_FOR_TARGET diff --git a/repo/gcc/gcc.xibuild b/repo/gcc/gcc.xibuild new file mode 100644 index 0000000..a5e294d --- /dev/null +++ b/repo/gcc/gcc.xibuild @@ -0,0 +1,202 @@ +#!/bin/sh + +MAKEDEPS="grep make dejagnu flex" +DEPS="zstd musl binutils mpc mpfr gmp libstdc++ libgcc" + + +PKG_VER=11.2.0 +SOURCE=https://ftp.gnu.org/gnu/gcc/gcc-$PKG_VER/gcc-$PKG_VER.tar.xz + +ISL_VER=0.24 +PATCH_SRC="https://raw.githubusercontent.com/dslm4515/Musl-LFS/master/patches/gcc-alpine" + +ADDITIONAL=" + https://libisl.sourceforge.io/isl-$ISL_VER.tar.xz + + 0001-posix_memalign.patch + 0003-Turn-on-Wl-z-relro-z-now-by-default.patch + 0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch + 0006-Enable-Wformat-and-Wformat-security-by-default.patch + 0007-Enable-Wtrampolines-by-default.patch + 0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch + 0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch + 0012-libitm-disable-FORTIFY.patch + 0013-libgcc_s.patch + 0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch + 0016-dlang-update-zlib-binding.patch + 0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch + 0018-ada-fix-shared-linking.patch + 0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch + 0020-add-fortify-headers-paths.patch + 0023-Pure-64-bit-MIPS.patch + 0024-use-pure-64-bit-configuration-where-appropriate.patch + 0025-always-build-libgcc_eh.a.patch + 0027-ada-musl-support-fixes.patch + 0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch + 0029-gcc-go-Don-t-include-sys-user.h.patch + 0030-gcc-go-Fix-ucontext_t-on-PPC64.patch + 0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch + 0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch + 0035-gcc-go-Prefer-_off_t-over-_off64_t.patch + 0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch + 0037-gcc-go-link-to-libucontext.patch + 0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch + 0041-Use-generic-errstr.go-implementation-on-musl.patch + 0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch + 0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch + 0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch + getconf.1 + getconf.c + getent.1 + getent.c + iconv.c +" + +DESC="The GNU Compiler Collection - C and C++ frontends" + +prepare () { + export languages="c,c++,lto" + + case $(uname -m) in + x86_64) export TRUPLE="x86_64-linux-musl" + export EXTRA_CONFIG=" --with-arch=x86-64" + ;; + i686) export TRUPLE="i686-linux-musl" + export EXTRA_CONFIG=" --with-arch=pentium3 --with-tune=pentium-m" + ;; + armv7l) export TRUPLE="armv7l-linux-musleabihf" + export EXTRA_CONFIG=" --with-arch=armv7-a --with-tune=generic-armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-abi=aapcs-linux --with-mode=thumb" + ;; + armv6l) export TRUPLE="armv6l-linux-musleabihf" + export EXTRA_CONFIG=" --with-arch=armv6zk --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard --with-abi=aapcs-linux" + ;; + aarch64) export TRUPLE="aarch64-linux-musleabihf" + export EXTRA_CONFIG=" --with-arch=armv8-a --with-abi=lp64 --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419" + sed -i '/m64=/s/lib64/lib/' gcc/config/aarch64/t-aarch64-linux + ;; + esac + + tar xf isl-$ISL_VER.tar.xz + mv isl-$ISL_VER isl + + apply_patches +} + +build () { + mkdir build + cd build + + export NOFF="--disable-libstdcxx-pch + --disable-nls + --disable-multilib + --disable-bootstrap + --disable-symvers + --disable-libsanitizer + --disable-libmpx + --disable-libmudflap + --disable-fixed-point + --disable-sjlj-exceptions + --disable-werror " + + # Enable graphite + export XCONFIG="--with-ppl=yes --with-cloog=yes " + + # Enable features for x86_64 + export XTRA86="--with-arch=x86-64 " + + # Enable features + export FON="--enable-threads=posix + --enable-clocale=generic + --enable-tls + --enable-libstdcxx-time + --enable-fully-dynamic-string + --enable-linker-build-id + --enable-checking=release + --enable-cloog-backend + --enable-__cxa_atexit + --enable-lto + --enable-plugins + --with-system-zlib + --with-linker-hash-style=gnu " + #export FON+="--with-isl " + + # Configure source + SED=sed libat_cv_have_ifunc=no \ + ../configure --prefix=/usr \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --with-pkgversion="XiLinux $PKG_VER" \ + --enable-checking=release \ + --disable-fixed-point \ + --disable-libstdcxx-pch \ + --disable-multilib \ + --disable-nls \ + --disable-werror \ + --enable-__cxa_atexit \ + --enable-default-pie \ + --enable-cloog-backend \ + --enable-languages=$languages \ + --with-system-zlib \ + --target=${TRUPLE} \ + $NOFF $XTRA86 $XCONFIG $FON && + + make && + + cd .. && + cc getent.c -o getent && + cc getconf.c -o getconf && + cc iconv.c -o iconv +} + +check () { + cd build + if id -u tester; then + chown -R tester . + su tester -c "PATH=$PATH make $MAKEFLAGS -k check" || true + ../contrib/test_summary | grep -A7 Summ || true + fi + cd .. +} + + +package () { + + # create specsfile + export SPECFILE=$PKG_DEST`dirname $(gcc -print-libgcc-file-name)`/specs +gcc -dumpspecs | sed -e 's@/tools@@g' \ + -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ + -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > tempspecfile + mv -f tempspecfile $SPECFILE && + unset SPECFILE MLFS_TARGET + + + + install -dm755 $PKG_DEST/usr/bin + install -dm755 $PKG_DEST/usr/share/man + install -dm755 $PKG_DEST/usr/lib/bfd-plugins + + cd build + make DESTDIR=$PKG_DEST install + cd .. + + cp getent $PKG_DEST/usr/bin/ + cp getconf $PKG_DEST/usr/bin/ + cp iconv $PKG_DEST/usr/bin/ + cp getent.1 $PKG_DEST/usr/share/man/man1/ + cp getconf.1 $PKG_DEST/usr/share/man/man1/ + + ln -s ../bin/cpp $PKG_DEST/usr/lib + ln -s gcc $PKG_DEST/usr/bin/cc + + ln -sf ../../libexec/gcc/$(gcc -dumpmachine)/$PKG_VER/liblto_plugin.so \ + $PKG_VER/usr/lib/bfd-plugins/ + + mkdir -p $PKG_DEST/usr/share/gdb/auto-load/usr/lib + #mv $PKG_DEST/usr/lib/*gdb.py $PKG_DEST/usr/share/gdb/auto-load/usr/lib + + for p in gcov gcc-ar gcc gcc-ranlib c++ g++ gcc-nm lto-dump gcov-tools gcov-dump cpp; do + ln -s $TRUPLE-$p $PKG_DEST/usr/bin/$p + done + + +} diff --git a/repo/gcc/getconf.1 b/repo/gcc/getconf.1 new file mode 100644 index 0000000..520a688 --- /dev/null +++ b/repo/gcc/getconf.1 @@ -0,0 +1,94 @@ +.\" $NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $ +.\" +.\" Copyright (c) 1996 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by J.T. Conklin. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd August 9, 2011 +.Dt GETCONF 1 +.Os +.Sh NAME +.Nm getconf +.Nd get configuration values +.Sh SYNOPSIS +.Nm +.Ar system_var +.Nm +.Fl a +.Nm +.Ar path_var +.Ar pathname +.Nm +.Fl a +.Ar pathname +.Sh DESCRIPTION +The +.Nm +utility writes the current value of a configurable system limit or +option variable to the standard output. +.Pp +The +.Ar system_var +argument specifies the system variable to be queried. +The names of the system variables are from +.Xr sysconf 3 +with the leading +.Dq Li _SC_ +removed. +.Pp +The +.Ar path_var +argument specifies the pathname variable to be queried for the specified +.Ar pathname +argument. +The names of the pathname variables are from +.Xr pathconf 2 +with the leading +.Dq Li _PC_ +removed. +.Pp +When invoked with the option +.Fl a , +.Nm +writes a list of all applicable variables and their values to the +standard output, in the format +.Do +.Va name += +.Va value +.Dc . +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr pathconf 2 , +.Xr confstr 3 , +.Xr limits 3 , +.Xr sysconf 3 +.Sh STANDARDS +The +.Nm +utility conforms to +.St -p1003.2-92 . diff --git a/repo/gcc/getconf.c b/repo/gcc/getconf.c new file mode 100644 index 0000000..c423524 --- /dev/null +++ b/repo/gcc/getconf.c @@ -0,0 +1,338 @@ +/*- + * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by J.T. Conklin. + * + * Mostly rewritten to be used in Alpine Linux (with musl c-library) + * by Timo Teräs. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <err.h> +#include <errno.h> +#include <values.h> +#include <limits.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +struct conf_variable { + const char *name; + enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, UCONSTANT, NUM_TYPES } type; + long value; +}; + +static const struct conf_variable conf_table[] = { +{ "PATH", CONFSTR, _CS_PATH }, + +/* Utility Limit Minimum Values */ +{ "POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX }, +{ "POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX }, +{ "POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX }, +{ "POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX }, +{ "POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX }, +{ "POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX }, +{ "POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX }, +{ "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX }, +{ "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION }, + +/* POSIX.1 Minimum Values */ +{ "_POSIX_AIO_LISTIO_MAX", CONSTANT, _POSIX_AIO_LISTIO_MAX }, +{ "_POSIX_AIO_MAX", CONSTANT, _POSIX_AIO_MAX }, +{ "_POSIX_ARG_MAX", CONSTANT, _POSIX_ARG_MAX }, +{ "_POSIX_CHILD_MAX", CONSTANT, _POSIX_CHILD_MAX }, +{ "_POSIX_LINK_MAX", CONSTANT, _POSIX_LINK_MAX }, +{ "_POSIX_MAX_CANON", CONSTANT, _POSIX_MAX_CANON }, +{ "_POSIX_MAX_INPUT", CONSTANT, _POSIX_MAX_INPUT }, +{ "_POSIX_MQ_OPEN_MAX", CONSTANT, _POSIX_MQ_OPEN_MAX }, +{ "_POSIX_MQ_PRIO_MAX", CONSTANT, _POSIX_MQ_PRIO_MAX }, +{ "_POSIX_NAME_MAX", CONSTANT, _POSIX_NAME_MAX }, +{ "_POSIX_NGROUPS_MAX", CONSTANT, _POSIX_NGROUPS_MAX }, +{ "_POSIX_OPEN_MAX", CONSTANT, _POSIX_OPEN_MAX }, +{ "_POSIX_PATH_MAX", CONSTANT, _POSIX_PATH_MAX }, +{ "_POSIX_PIPE_BUF", CONSTANT, _POSIX_PIPE_BUF }, +{ "_POSIX_SSIZE_MAX", CONSTANT, _POSIX_SSIZE_MAX }, +{ "_POSIX_STREAM_MAX", CONSTANT, _POSIX_STREAM_MAX }, +{ "_POSIX_TZNAME_MAX", CONSTANT, _POSIX_TZNAME_MAX }, + +/* Symbolic Utility Limits */ +{ "BC_BASE_MAX", SYSCONF, _SC_BC_BASE_MAX }, +{ "BC_DIM_MAX", SYSCONF, _SC_BC_DIM_MAX }, +{ "BC_SCALE_MAX", SYSCONF, _SC_BC_SCALE_MAX }, +{ "BC_STRING_MAX", SYSCONF, _SC_BC_STRING_MAX }, +{ "COLL_WEIGHTS_MAX", SYSCONF, _SC_COLL_WEIGHTS_MAX }, +{ "EXPR_NEST_MAX", SYSCONF, _SC_EXPR_NEST_MAX }, +{ "LINE_MAX", SYSCONF, _SC_LINE_MAX }, +{ "RE_DUP_MAX", SYSCONF, _SC_RE_DUP_MAX }, + +/* Optional Facility Configuration Values */ +{ "_POSIX2_C_BIND", SYSCONF, _SC_2_C_BIND }, +{ "POSIX2_C_DEV", SYSCONF, _SC_2_C_DEV }, +{ "POSIX2_CHAR_TERM", SYSCONF, _SC_2_CHAR_TERM }, +{ "POSIX2_FORT_DEV", SYSCONF, _SC_2_FORT_DEV }, +{ "POSIX2_FORT_RUN", SYSCONF, _SC_2_FORT_RUN }, +{ "POSIX2_LOCALEDEF", SYSCONF, _SC_2_LOCALEDEF }, +{ "POSIX2_SW_DEV", SYSCONF, _SC_2_SW_DEV }, +{ "POSIX2_UPE", SYSCONF, _SC_2_UPE }, + +/* POSIX.1 Configurable System Variables */ +{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX }, +{ "AIO_MAX", SYSCONF, _SC_AIO_MAX }, +{ "ARG_MAX", SYSCONF, _SC_ARG_MAX }, +{ "CHILD_MAX", SYSCONF, _SC_CHILD_MAX }, +{ "CLK_TCK", SYSCONF, _SC_CLK_TCK }, +{ "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX }, +{ "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX }, +{ "NGROUPS_MAX", SYSCONF, _SC_NGROUPS_MAX }, +{ "OPEN_MAX", SYSCONF, _SC_OPEN_MAX }, +{ "STREAM_MAX", SYSCONF, _SC_STREAM_MAX }, +{ "TZNAME_MAX", SYSCONF, _SC_TZNAME_MAX }, +{ "_POSIX_JOB_CONTROL", SYSCONF, _SC_JOB_CONTROL }, +{ "_POSIX_SAVED_IDS", SYSCONF, _SC_SAVED_IDS }, +{ "_POSIX_VERSION", SYSCONF, _SC_VERSION }, + +{ "LINK_MAX", PATHCONF, _PC_LINK_MAX }, +{ "MAX_CANON", PATHCONF, _PC_MAX_CANON }, +{ "MAX_INPUT", PATHCONF, _PC_MAX_INPUT }, +{ "NAME_MAX", PATHCONF, _PC_NAME_MAX }, +{ "PATH_MAX", PATHCONF, _PC_PATH_MAX }, +{ "PIPE_BUF", PATHCONF, _PC_PIPE_BUF }, +{ "_POSIX_CHOWN_RESTRICTED", PATHCONF, _PC_CHOWN_RESTRICTED }, +{ "_POSIX_NO_TRUNC", PATHCONF, _PC_NO_TRUNC }, +{ "_POSIX_VDISABLE", PATHCONF, _PC_VDISABLE }, + +/* POSIX.1b Configurable System Variables */ +{ "PAGESIZE", SYSCONF, _SC_PAGESIZE }, +{ "_POSIX_ASYNCHRONOUS_IO", SYSCONF, _SC_ASYNCHRONOUS_IO }, +{ "_POSIX_FSYNC", SYSCONF, _SC_FSYNC }, +{ "_POSIX_MAPPED_FILES", SYSCONF, _SC_MAPPED_FILES }, +{ "_POSIX_MEMLOCK", SYSCONF, _SC_MEMLOCK }, +{ "_POSIX_MEMLOCK_RANGE", SYSCONF, _SC_MEMLOCK_RANGE }, +{ "_POSIX_MEMORY_PROTECTION", SYSCONF, _SC_MEMORY_PROTECTION }, +{ "_POSIX_MESSAGE_PASSING", SYSCONF, _SC_MESSAGE_PASSING }, +{ "_POSIX_MONOTONIC_CLOCK", SYSCONF, _SC_MONOTONIC_CLOCK }, +{ "_POSIX_PRIORITY_SCHEDULING", SYSCONF, _SC_PRIORITY_SCHEDULING }, +{ "_POSIX_SEMAPHORES", SYSCONF, _SC_SEMAPHORES }, +{ "_POSIX_SHARED_MEMORY_OBJECTS", SYSCONF, _SC_SHARED_MEMORY_OBJECTS }, +{ "_POSIX_SYNCHRONIZED_IO", SYSCONF, _SC_SYNCHRONIZED_IO }, +{ "_POSIX_TIMERS", SYSCONF, _SC_TIMERS }, + +{ "_POSIX_SYNC_IO", PATHCONF, _PC_SYNC_IO }, + +/* POSIX.1c Configurable System Variables */ +{ "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX }, +{ "_POSIX_THREADS", SYSCONF, _SC_THREADS }, + +/* POSIX.1j Configurable System Variables */ +{ "_POSIX_BARRIERS", SYSCONF, _SC_BARRIERS }, +{ "_POSIX_READER_WRITER_LOCKS", SYSCONF, _SC_READER_WRITER_LOCKS }, +{ "_POSIX_SPIN_LOCKS", SYSCONF, _SC_SPIN_LOCKS }, + +/* XPG4.2 Configurable System Variables */ +{ "IOV_MAX", SYSCONF, _SC_IOV_MAX }, +{ "PAGE_SIZE", SYSCONF, _SC_PAGE_SIZE }, +{ "_XOPEN_SHM", SYSCONF, _SC_XOPEN_SHM }, + +/* X/Open CAE Spec. Issue 5 Version 2 Configurable System Variables */ +{ "FILESIZEBITS", PATHCONF, _PC_FILESIZEBITS }, + +/* POSIX.1-2001 XSI Option Group Configurable System Variables */ +{ "ATEXIT_MAX", SYSCONF, _SC_ATEXIT_MAX }, + +/* POSIX.1-2001 TSF Configurable System Variables */ +{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX }, +{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX }, + +/* Commonly provided extensions */ +{ "_PHYS_PAGES", SYSCONF, _SC_PHYS_PAGES }, +{ "_AVPHYS_PAGES", SYSCONF, _SC_AVPHYS_PAGES }, +{ "_NPROCESSORS_CONF", SYSCONF, _SC_NPROCESSORS_CONF }, +{ "_NPROCESSORS_ONLN", SYSCONF, _SC_NPROCESSORS_ONLN }, + +/* Data type related extensions */ +{ "CHAR_BIT", CONSTANT, CHAR_BIT }, +{ "CHAR_MAX", CONSTANT, CHAR_MAX }, +{ "CHAR_MIN", CONSTANT, CHAR_MIN }, +{ "INT_MAX", CONSTANT, INT_MAX }, +{ "INT_MIN", CONSTANT, INT_MIN }, +{ "LONG_BIT", CONSTANT, LONG_BIT }, +{ "LONG_MAX", CONSTANT, LONG_MAX }, +{ "LONG_MIN", CONSTANT, LONG_MIN }, +{ "SCHAR_MAX", CONSTANT, SCHAR_MAX }, +{ "SCHAR_MIN", CONSTANT, SCHAR_MIN }, +{ "SHRT_MAX", CONSTANT, SHRT_MAX }, +{ "SHRT_MIN", CONSTANT, SHRT_MIN }, +{ "SSIZE_MAX", CONSTANT, SSIZE_MAX }, +{ "UCHAR_MAX", UCONSTANT, (long) UCHAR_MAX }, +{ "UINT_MAX", UCONSTANT, (long) UINT_MAX }, +{ "ULONG_MAX", UCONSTANT, (long) ULONG_MAX }, +{ "USHRT_MAX", UCONSTANT, (long) USHRT_MAX }, +{ "WORD_BIT", CONSTANT, WORD_BIT }, + +{ NULL, CONSTANT, 0L } +}; + +static int all = 0; + +static void usage(const char *p) +{ + (void)fprintf(stderr, "Usage: %s system_var\n\t%s -a\n" + "\t%s path_var pathname\n\t%s -a pathname\n", p, p, p, p); + exit(EXIT_FAILURE); +} + +static void print_long(const char *name, long val) +{ + if (all) printf("%s = %ld\n", name, val); + else printf("%ld\n", val); +} + +static void print_ulong(const char *name, unsigned long val) +{ + if (all) printf("%s = %lu\n", name, val); + else printf("%lu\n", val); +} + +static void print_string(const char *name, const char *val) +{ + if (all) printf("%s = %s\n", name, val); + else printf("%s\n", val); +} + +static int print_constant(const struct conf_variable *cp, const char *pathname) +{ + print_long(cp->name, cp->value); + return 0; +} + +static int print_uconstant(const struct conf_variable *cp, const char *pathname) +{ + print_ulong(cp->name, (unsigned long) cp->value); + return 0; +} + +static int print_sysconf(const struct conf_variable *cp, const char *pathname) +{ + long val; + + errno = 0; + if ((val = sysconf((int)cp->value)) == -1) { + if (errno != 0) err(EXIT_FAILURE, "sysconf(%ld)", cp->value); + return -1; + } + print_long(cp->name, val); + return 0; +} + +static int print_confstr(const struct conf_variable *cp, const char *pathname) +{ + size_t len; + char *val; + + errno = 0; + if ((len = confstr((int)cp->value, NULL, 0)) == 0) goto error; + if ((val = malloc(len)) == NULL) err(EXIT_FAILURE, "Can't allocate %zu bytes", len); + errno = 0; + if (confstr((int)cp->value, val, len) == 0) goto error; + print_string(cp->name, val); + free(val); + return 0; +error: + if (errno != EINVAL) err(EXIT_FAILURE, "confstr(%ld)", cp->value); + return -1; +} + +static int print_pathconf(const struct conf_variable *cp, const char *pathname) +{ + long val; + + errno = 0; + if ((val = pathconf(pathname, (int)cp->value)) == -1) { + if (all && errno == EINVAL) return 0; + if (errno != 0) err(EXIT_FAILURE, "pathconf(%s, %ld)", pathname, cp->value); + return -1; + } + print_long(cp->name, val); + return 0; +} + +typedef int (*handler_t)(const struct conf_variable *cp, const char *pathname); +static const handler_t type_handlers[NUM_TYPES] = { + [SYSCONF] = print_sysconf, + [CONFSTR] = print_confstr, + [PATHCONF] = print_pathconf, + [CONSTANT] = print_constant, + [UCONSTANT] = print_uconstant, +}; + +int main(int argc, char **argv) +{ + const char *progname = argv[0]; + const struct conf_variable *cp; + const char *varname, *pathname; + int ch, found = 0; + + (void)setlocale(LC_ALL, ""); + while ((ch = getopt(argc, argv, "a")) != -1) { + switch (ch) { + case 'a': + all = 1; + break; + case '?': + default: + usage(progname); + } + } + argc -= optind; + argv += optind; + + if (!all) { + if (argc == 0) + usage(progname); + varname = argv[0]; + argc--; + argv++; + } else + varname = NULL; + + if (argc > 1) + usage(progname); + pathname = argv[0]; /* may be NULL */ + + for (cp = conf_table; cp->name != NULL; cp++) { + if (!all && strcmp(varname, cp->name) != 0) continue; + if ((cp->type == PATHCONF) == (pathname != NULL)) { + if (type_handlers[cp->type](cp, pathname) < 0) + print_string(cp->name, "undefined"); + found = 1; + } else if (!all) + errx(EXIT_FAILURE, "%s: invalid variable type", cp->name); + } + if (!all && !found) errx(EXIT_FAILURE, "%s: unknown variable", varname); + (void)fflush(stdout); + return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/repo/gcc/getent.1 b/repo/gcc/getent.1 new file mode 100644 index 0000000..0e07058 --- /dev/null +++ b/repo/gcc/getent.1 @@ -0,0 +1,145 @@ +.\" $NetBSD: getent.1,v 1.23 2011/10/11 20:39:40 wiz Exp $ +.\" +.\" Copyright (c) 2004 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Luke Mewburn. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd October 11, 2011 +.Dt GETENT 1 +.Os +.Sh NAME +.Nm getent +.Nd get entries from administrative databases +.Sh SYNOPSIS +.Nm getent +.Ar database +.Op Ar key ... +.Nm getcap +.Ar database +.Op Ar key ... +.Sh DESCRIPTION +The +.Nm +program retrieves and displays entries from the administrative +database specified by +.Ar database , +using the lookup order specified in +.Xr nsswitch.conf 5 . +The display format for a given +.Ar database +is as per the +.Dq traditional +file format for that database. +.Pp +.Ar database +may be one of: +.Bl -column "protocols" "user:passwd:uid:gid:gecos:home_dir:shell" -offset indent -compact +.It Sy Database Ta Sy Display format +.It disktab Ta entry +.It ethers Ta address name +.It gettytab Ta entry +.It group Ta group:passwd:gid:[member[,member]...] +.It hosts Ta address name [alias ...] +.It netgroup Ta (host,user,domain) [...] +.It networks Ta name network [alias ...] +.It passwd Ta user:passwd:uid:gid:gecos:home_dir:shell +.It printcap Ta entry +.It protocols Ta name protocol [alias ...] +.It rpc Ta name number [alias ...] +.It services Ta name port/protocol [alias ...] +.It shells Ta /path/to/shell +.El +.Pp +If one or more +.Ar key +arguments are provided, they will be looked up in +.Ar database +using the appropriate function. +For example, +.Sy passwd +supports a numeric UID or user name; +.Sy hosts +supports an IPv4 address, IPv6 address, or host name; +and +.Sy services +supports a service name, service name/protocol name, numeric port, or +numeric port/protocol name. +.Pp +If no +.Ar key +is provided and +.Ar database +supports enumeration, all entries for +.Ar database +will be retrieved using the appropriate enumeration function and printed. +.Pp +For +.Xr cgetcap 3 +style databases +.Sy ( disktab , +.Sy printcap ) +specifying a key, lists the entry for that key, and specifying more arguments +after the key are used as fields in that key, and only the values of the keys +are returned. +For boolean keys +.Dv true +is returned if the key is found. +If a key is not found, then +.Dv false +is always +returned. +.Sh DIAGNOSTICS +.Nm +exits 0 on success, +1 if there was an error in the command syntax, +2 if one of the specified key names was not found in +.Ar database , +or 3 if there is no support for enumeration on +.Ar database . +.Sh SEE ALSO +.Xr cgetcap 3 , +.Xr disktab 5 , +.Xr ethers 5 , +.Xr gettytab 5 , +.Xr group 5 , +.Xr hosts 5 , +.Xr networks 5 , +.Xr nsswitch.conf 5 , +.Xr passwd 5 , +.Xr printcap 5 , +.Xr protocols 5 , +.Xr rpc 5 , +.Xr services 5 , +.Xr shells 5 +.Sh HISTORY +A +.Nm +command appeared in +.Nx 3.0 . +It was based on the command of the same name in +.Tn Solaris +and +.Tn Linux . diff --git a/repo/gcc/getent.c b/repo/gcc/getent.c new file mode 100644 index 0000000..939b46c --- /dev/null +++ b/repo/gcc/getent.c @@ -0,0 +1,437 @@ +/*- + * Copyright (c) 2004-2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * Timo Teräs cleaned up the code for use in Alpine Linux with musl libc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/socket.h> +#include <sys/param.h> +#include <ctype.h> +#include <errno.h> +#include <limits.h> +#include <netdb.h> +#include <pwd.h> +#include <grp.h> +#include <stdio.h> +#include <stdarg.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <paths.h> +#include <err.h> + +#include <arpa/inet.h> +#include <arpa/nameser.h> + +#include <net/if.h> +#include <net/ethernet.h> +#include <netinet/ether.h> +#include <netinet/in.h> + +enum { + RV_OK = 0, + RV_USAGE = 1, + RV_NOTFOUND = 2, + RV_NOENUM = 3 +}; + +static int usage(const char *); + +static int parsenum(const char *word, unsigned long *result) +{ + unsigned long num; + char *ep; + + if (!isdigit((unsigned char)word[0])) + return 0; + errno = 0; + num = strtoul(word, &ep, 10); + if (num == ULONG_MAX && errno == ERANGE) + return 0; + if (*ep != '\0') + return 0; + *result = num; + return 1; +} + +/* + * printfmtstrings -- + * vprintf(format, ...), + * then the aliases (beginning with prefix, separated by sep), + * then a newline + */ +__attribute__ ((format (printf, 4, 5))) +static void printfmtstrings(char *strings[], const char *prefix, const char *sep, + const char *fmt, ...) +{ + va_list ap; + const char *curpref; + size_t i; + + va_start(ap, fmt); + (void)vprintf(fmt, ap); + va_end(ap); + + curpref = prefix; + for (i = 0; strings[i] != NULL; i++) { + (void)printf("%s%s", curpref, strings[i]); + curpref = sep; + } + (void)printf("\n"); +} + +static int ethers(int argc, char *argv[]) +{ + char hostname[MAXHOSTNAMELEN + 1], *hp; + struct ether_addr ea, *eap; + int i, rv; + + if (argc == 2) { + warnx("Enumeration not supported on ethers"); + return RV_NOENUM; + } + + rv = RV_OK; + for (i = 2; i < argc; i++) { + if ((eap = ether_aton(argv[i])) == NULL) { + eap = &ea; + hp = argv[i]; + if (ether_hostton(hp, eap) != 0) { + rv = RV_NOTFOUND; + break; + } + } else { + hp = hostname; + if (ether_ntohost(hp, eap) != 0) { + rv = RV_NOTFOUND; + break; + } + } + (void)printf("%-17s %s\n", ether_ntoa(eap), hp); + } + return rv; +} + +static void groupprint(const struct group *gr) +{ + printfmtstrings(gr->gr_mem, ":", ",", "%s:%s:%u", + gr->gr_name, gr->gr_passwd, gr->gr_gid); +} + +static int group(int argc, char *argv[]) +{ + struct group *gr; + unsigned long id; + int i, rv; + + rv = RV_OK; + if (argc == 2) { + while ((gr = getgrent()) != NULL) + groupprint(gr); + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + gr = getgrgid((gid_t)id); + else + gr = getgrnam(argv[i]); + if (gr == NULL) { + rv = RV_NOTFOUND; + break; + } + groupprint(gr); + } + } + endgrent(); + return rv; +} + +static void hostsprint(const struct hostent *he) +{ + char buf[INET6_ADDRSTRLEN]; + + if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL) + (void)strlcpy(buf, "# unknown", sizeof(buf)); + printfmtstrings(he->h_aliases, " ", " ", "%-16s %s", buf, he->h_name); +} + +static int hosts(int argc, char *argv[]) +{ + struct hostent *he; + char addr[IN6ADDRSZ]; + int i, rv; + + sethostent(1); + rv = RV_OK; + if (argc == 2) { + while ((he = gethostent()) != NULL) + hostsprint(he); + } else { + for (i = 2; i < argc; i++) { + if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) + he = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6); + else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0) + he = gethostbyaddr(addr, INADDRSZ, AF_INET); + else + he = gethostbyname(argv[i]); + if (he == NULL) { + rv = RV_NOTFOUND; + break; + } + hostsprint(he); + } + } + endhostent(); + return rv; +} + +static void networksprint(const struct netent *ne) +{ + char buf[INET6_ADDRSTRLEN]; + struct in_addr ianet; + + ianet = inet_makeaddr(ne->n_net, 0); + if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL) + (void)strlcpy(buf, "# unknown", sizeof(buf)); + printfmtstrings(ne->n_aliases, " ", " ", "%-16s %s", ne->n_name, buf); +} + +static int networks(int argc, char *argv[]) +{ + struct netent *ne; + in_addr_t net; + int i, rv; + + setnetent(1); + rv = RV_OK; + if (argc == 2) { + while ((ne = getnetent()) != NULL) + networksprint(ne); + } else { + for (i = 2; i < argc; i++) { + net = inet_network(argv[i]); + if (net != INADDR_NONE) + ne = getnetbyaddr(net, AF_INET); + else + ne = getnetbyname(argv[i]); + if (ne == NULL) { + rv = RV_NOTFOUND; + break; + } + networksprint(ne); + } + } + endnetent(); + return rv; +} + +static void passwdprint(struct passwd *pw) +{ + (void)printf("%s:%s:%u:%u:%s:%s:%s\n", + pw->pw_name, pw->pw_passwd, pw->pw_uid, + pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell); +} + +static int passwd(int argc, char *argv[]) +{ + struct passwd *pw; + unsigned long id; + int i, rv; + + rv = RV_OK; + if (argc == 2) { + while ((pw = getpwent()) != NULL) + passwdprint(pw); + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + pw = getpwuid((uid_t)id); + else + pw = getpwnam(argv[i]); + if (pw == NULL) { + rv = RV_NOTFOUND; + break; + } + passwdprint(pw); + } + } + endpwent(); + return rv; +} + +static void protocolsprint(struct protoent *pe) +{ + printfmtstrings(pe->p_aliases, " ", " ", + "%-16s %5d", pe->p_name, pe->p_proto); +} + +static int protocols(int argc, char *argv[]) +{ + struct protoent *pe; + unsigned long id; + int i, rv; + + setprotoent(1); + rv = RV_OK; + if (argc == 2) { + while ((pe = getprotoent()) != NULL) + protocolsprint(pe); + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + pe = getprotobynumber((int)id); + else + pe = getprotobyname(argv[i]); + if (pe == NULL) { + rv = RV_NOTFOUND; + break; + } + protocolsprint(pe); + } + } + endprotoent(); + return rv; +} + +static void servicesprint(struct servent *se) +{ + printfmtstrings(se->s_aliases, " ", " ", + "%-16s %5d/%s", + se->s_name, ntohs(se->s_port), se->s_proto); + +} + +static int services(int argc, char *argv[]) +{ + struct servent *se; + unsigned long id; + char *proto; + int i, rv; + + setservent(1); + rv = RV_OK; + if (argc == 2) { + while ((se = getservent()) != NULL) + servicesprint(se); + } else { + for (i = 2; i < argc; i++) { + proto = strchr(argv[i], '/'); + if (proto != NULL) + *proto++ = '\0'; + if (parsenum(argv[i], &id)) + se = getservbyport(htons(id), proto); + else + se = getservbyname(argv[i], proto); + if (se == NULL) { + rv = RV_NOTFOUND; + break; + } + servicesprint(se); + } + } + endservent(); + return rv; +} + +static int shells(int argc, char *argv[]) +{ + const char *sh; + int i, rv; + + setusershell(); + rv = RV_OK; + if (argc == 2) { + while ((sh = getusershell()) != NULL) + (void)printf("%s\n", sh); + } else { + for (i = 2; i < argc; i++) { + setusershell(); + while ((sh = getusershell()) != NULL) { + if (strcmp(sh, argv[i]) == 0) { + (void)printf("%s\n", sh); + break; + } + } + if (sh == NULL) { + rv = RV_NOTFOUND; + break; + } + } + } + endusershell(); + return rv; +} + +static struct getentdb { + const char *name; + int (*callback)(int, char *[]); +} databases[] = { + { "ethers", ethers, }, + { "group", group, }, + { "hosts", hosts, }, + { "networks", networks, }, + { "passwd", passwd, }, + { "protocols", protocols, }, + { "services", services, }, + { "shells", shells, }, + + { NULL, NULL, }, +}; + +static int usage(const char *arg0) +{ + struct getentdb *curdb; + size_t i; + + (void)fprintf(stderr, "Usage: %s database [key ...]\n", arg0); + (void)fprintf(stderr, "\tdatabase may be one of:"); + for (i = 0, curdb = databases; curdb->name != NULL; curdb++, i++) { + if (i % 7 == 0) + (void)fputs("\n\t\t", stderr); + (void)fprintf(stderr, "%s%s", i % 7 == 0 ? "" : " ", + curdb->name); + } + (void)fprintf(stderr, "\n"); + exit(RV_USAGE); + /* NOTREACHED */ +} + +int +main(int argc, char *argv[]) +{ + struct getentdb *curdb; + + if (argc < 2) + usage(argv[0]); + for (curdb = databases; curdb->name != NULL; curdb++) + if (strcmp(curdb->name, argv[1]) == 0) + return (*curdb->callback)(argc, argv); + + warn("Unknown database `%s'", argv[1]); + usage(argv[0]); + /* NOTREACHED */ +} diff --git a/repo/gcc/iconv.c b/repo/gcc/iconv.c new file mode 100644 index 0000000..f5d5ce2 --- /dev/null +++ b/repo/gcc/iconv.c @@ -0,0 +1,110 @@ +/* + * iconv.c + * Implementation of SUSv4 XCU iconv utility + * Copyright © 2011 Rich Felker + * Licensed under the terms of the GNU General Public License, v2 or later + */ + +#include <stdlib.h> +#include <stdio.h> +#include <iconv.h> +#include <locale.h> +#include <langinfo.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +int main(int argc, char **argv) +{ + const char *from=0, *to=0; + int b; + iconv_t cd; + char buf[BUFSIZ]; + char outbuf[BUFSIZ*4]; + char *in, *out; + size_t inb; + size_t l; + size_t unitsize=0; + int err=0; + FILE *f; + + while ((b = getopt(argc, argv, "f:t:csl")) != EOF) switch(b) { + case 'l': + puts("UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF32-LE, UCS-2BE, UCS-2LE, WCHAR_T,\n" + "US_ASCII, ISO8859-1, ISO8859-2, ISO8859-3, ISO8859-4, ISO8859-5,\n" + "ISO8859-6, ISO8859-7, ..."); + exit(0); + case 'c': case 's': break; + case 'f': from=optarg; break; + case 't': to=optarg; break; + default: exit(1); + } + + if (!from || !to) { + setlocale(LC_CTYPE, ""); + if (!to) to = nl_langinfo(CODESET); + if (!from) from = nl_langinfo(CODESET); + } + cd = iconv_open(to, from); + if (cd == (iconv_t)-1) { + if (iconv_open(to, "WCHAR_T") == (iconv_t)-1) + fprintf(stderr, "iconv: destination charset %s: ", to); + else + fprintf(stderr, "iconv: source charset %s: ", from); + perror(""); + exit(1); + } + if (optind == argc) argv[argc++] = "-"; + + for (; optind < argc; optind++) { + if (argv[optind][0]=='-' && !argv[optind][1]) { + f = stdin; + argv[optind] = "(stdin)"; + } else if (!(f = fopen(argv[optind], "rb"))) { + fprintf(stderr, "iconv: %s: ", argv[optind]); + perror(""); + err = 1; + continue; + } + inb = 0; + for (;;) { + in = buf; + out = outbuf; + l = fread(buf+inb, 1, sizeof(buf)-inb, f); + inb += l; + if (!inb) break; + if (iconv(cd, &in, &inb, &out, (size_t [1]){sizeof outbuf})==-1 + && errno == EILSEQ) { + if (!unitsize) { + wchar_t wc='0'; + char dummy[4], *dummyp=dummy; + iconv_t cd2 = iconv_open(from, "WCHAR_T"); + if (cd == (iconv_t)-1) { + unitsize = 1; + } else { + iconv(cd2, + (char *[1]){(char *)&wc}, + (size_t[1]){1}, + &dummyp, (size_t[1]){4}); + unitsize = dummyp-dummy; + if (!unitsize) unitsize=1; + } + } + inb-=unitsize; + in+=unitsize; + } + if (inb && !l && errno==EINVAL) break; + if (out>outbuf && !fwrite(outbuf, out-outbuf, 1, stdout)) { + perror("iconv: write error"); + exit(1); + } + if (inb) memmove(buf, in, inb); + } + if (ferror(f)) { + fprintf(stderr, "iconv: %s: ", argv[optind]); + perror(""); + err = 1; + } + } + return err; +} diff --git a/repo/gcc/libgcc.xibuild b/repo/gcc/libgcc.xibuild new file mode 100644 index 0000000..d9f28bf --- /dev/null +++ b/repo/gcc/libgcc.xibuild @@ -0,0 +1,8 @@ +#!/bin/sh + +DEPS="musl" +DESC="GNU C compiler runtime libraries" + +package () { + add_from_main "usr/lib/libgcc_s.so*" +} diff --git a/repo/gcc/libstdc++.xibuild b/repo/gcc/libstdc++.xibuild new file mode 100644 index 0000000..3115e0c --- /dev/null +++ b/repo/gcc/libstdc++.xibuild @@ -0,0 +1,8 @@ +#!/bin/sh + +DEPS="musl" +DESC="GNU C++ standard library" + +package () { + add_from_main "usr/lib/libstdc++.so*" +} |