cross/{gcc-ppc64le,musl-ppc64le}: Generate with aportgen (MR 5774)

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/5774>
This commit is contained in:
Jens Reidel 2024-11-08 23:20:19 +01:00 committed by The Friendly Merge Bot
parent 5ce8ad66ce
commit ed1039bc18
No known key found for this signature in database
43 changed files with 3628 additions and 0 deletions

View file

@ -0,0 +1,42 @@
From 94cf7d2b3514ed3a4401861a519ead450e022afc 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 d1d79a32fc9..069c3bb8324 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.50.1

View file

@ -0,0 +1,258 @@
From 0d5e04099a3d2609105719f7396a4ff941b873b6 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 23 Jan 2025 17:12:51 -0800
Subject: [PATCH] gcc: poison-system-directories
Add /sw/include and /opt/include based on the original
zecke-no-host-includes.patch patch. The original patch checked for
/usr/include, /sw/include and /opt/include and then triggered a failure and
aborted.
Instead, we add the two missing items to the current scan. If the user
wants this to be a failure, they can add "-Werror=poison-system-directories".
Upstream-Status: Inappropriate [OE configuration]
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: sunil dora <sunilkumar.dora@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
gcc/common.opt | 4 ++++
gcc/config.in | 10 ++++++++++
gcc/configure | 19 +++++++++++++++++++
gcc/configure.ac | 16 ++++++++++++++++
gcc/doc/invoke.texi | 9 +++++++++
gcc/gcc.cc | 12 ++++++++++--
gcc/incpath.cc | 25 +++++++++++++++++++++++++
7 files changed, 93 insertions(+), 2 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index e3fa0dacec4..bea1adc0940 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -729,6 +729,10 @@ Wreturn-local-addr
Common Var(warn_return_local_addr) Init(1) Warning
Warn about returning a pointer/reference to a local or temporary variable.
+Wpoison-system-directories
+Common Var(flag_poison_system_directories) Init(1) Warning
+Warn for -I and -L options using system directories if cross compiling
+
Wshadow
Common Var(warn_shadow) Warning
Warn when one variable shadows another. Same as -Wshadow=global.
diff --git a/gcc/config.in b/gcc/config.in
index a79c51adb2b..8a531ed591c 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -249,6 +249,16 @@
#endif
+/* Define to warn for use of native system header directories */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
+#endif
+/* Define to warn for use of native system header directories */
+#ifndef USED_FOR_TARGET
+#undef POISON_BY_DEFAULT
+#endif
+
+
/* Define if you want all operations on RTL (the basic data structure of the
optimizer and back end) to be checked for dynamic type safety at runtime.
This is quite expensive. */
diff --git a/gcc/configure b/gcc/configure
index 16965953f05..0f4a5d52c30 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -1051,6 +1051,7 @@ enable_maintainer_mode
enable_link_mutex
enable_link_serialization
enable_version_specific_runtime_libs
+enable_poison_system_directories
enable_plugin
enable_host_shared
enable_host_pie
@@ -1828,6 +1829,8 @@ Optional Features:
--enable-version-specific-runtime-libs
specify that runtime libraries should be installed
in a compiler-specific directory
+ --enable-poison-system-directories
+ warn for use of native system header directories
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
--enable-host-pie build host code as PIE
@@ -34027,6 +34030,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
fi
+# Check whether --enable-poison-system-directories was given.
+if test "${enable_poison_system_directories+set}" = set; then :
+ enableval=$enable_poison_system_directories;
+else
+ enable_poison_system_directories=no
+fi
+
+if test "x${enable_poison_system_directories}" != "xno"; then
+
+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
+if test "$enable_poison_system_directories" = "error"; then
+$as_echo "#define POISON_BY_DEFAULT 1" >>confdefs.h
+fi
+
+fi
+
# Substitute configuration variables
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 9f67e62950a..b0e3615e5aa 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7502,6 +7502,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
[specify that runtime libraries should be
installed in a compiler-specific directory])])
+AC_ARG_ENABLE([poison-system-directories],
+ AS_HELP_STRING([--enable-poison-system-directories],
+ [warn for use of native system header directories (no/yes/error)]),,
+ [enable_poison_system_directories=no])
+AC_MSG_NOTICE([poisoned directories $enable_poison_system_directories])
+if test "x${enable_poison_system_directories}" != "xno"; then
+ AC_MSG_NOTICE([poisoned directories enabled])
+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
+ [1],
+ [Define to warn for use of native system header directories])
+ if test $enable_poison_system_directories = "error"; then
+ AC_MSG_NOTICE([poisoned directories are fatal])
+ AC_DEFINE([POISON_BY_DEFAULT], [1], [Define to make poison warnings errors])
+ fi
+fi
+
# Substitute configuration variables
AC_SUBST(subdirs)
AC_SUBST(srcdir)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 72009c33cd0..29aea724731 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -405,6 +405,7 @@ Objective-C and Objective-C++ Dialects}.
-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
-Wparentheses -Wno-pedantic-ms-format
-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
+-Wno-poison-system-directories
-Wno-pragmas -Wno-pragma-once-outside-header -Wno-prio-ctor-dtor
-Wno-psabi
-Wredundant-decls -Wrestrict
@@ -10727,6 +10728,14 @@ an error. @option{Wint-to-pointer-cast} is enabled by default.
Suppress warnings from casts from a pointer to an integer type of a
different size.
+@opindex Wno-poison-system-directories
+@item -Wno-poison-system-directories
+Do not warn for @option{-I} or @option{-L} options using system
+directories such as @file{/usr/include} when cross compiling. This
+option is intended for use in chroot environments when such
+directories contain the correct headers and libraries for the target
+system rather than the host.
+
@opindex Winvalid-pch
@opindex Wno-invalid-pch
@item -Winvalid-pch
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 4fd87f2c4a1..79d4920a047 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -909,6 +909,12 @@ proper position among the other output files. */
#define ASM_MAP ""
#endif
+#ifdef POISON_BY_DEFAULT
+#define POISON_IS_ERROR " -Werror=poison-system-directories"
+#else
+#define POISON_IS_ERROR
+#endif
+
/* Assembler options for compressed debug sections. */
#if HAVE_LD_COMPRESS_DEBUG == 0
/* Reject if the linker cannot write compressed debug sections. */
@@ -1166,6 +1172,8 @@ proper position among the other output files. */
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
"%X %{o*} %{e*} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
+ %{Wno-poison-system-directories:--no-poison-system-directories} \
+ %{Werror=poison-system-directories:--error-poison-system-directories} \
%{static|no-pie|static-pie:} %@{L*} %(link_libgcc) " \
VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
@@ -1268,7 +1276,7 @@ static const char *cpp_options =
"%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
%{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
%{!fno-working-directory:-fworking-directory}}} %{O*}\
- %{undef} %{save-temps*:-fpch-preprocess}";
+ %{undef} %{save-temps*:-fpch-preprocess}" POISON_IS_ERROR;
/* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
@@ -1297,7 +1305,7 @@ static const char *cc1_options =
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
- %{pthread:-fprofile-update=prefer-atomic}}}";
+ %{pthread:-fprofile-update=prefer-atomic}}}" POISON_IS_ERROR;
static const char *asm_options =
"%{-target-help:%:print-asm-header()} "
diff --git a/gcc/incpath.cc b/gcc/incpath.cc
index c1bbfd3872a..2cdbebc4c50 100644
--- a/gcc/incpath.cc
+++ b/gcc/incpath.cc
@@ -26,6 +26,7 @@
#include "intl.h"
#include "incpath.h"
#include "cppdefault.h"
+#include "diagnostic-core.h"
/* Microsoft Windows does not natively support inodes.
VMS has non-numeric inodes. */
@@ -273,6 +274,10 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
cur->name, xstrerror (errno));
reason = REASON_NOENT;
}
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
+ pcur = &cur->next;
+ continue;
+#endif
}
else if (!S_ISDIR (st.st_mode))
cpp_error_with_line (pfile, CPP_DL_WARNING, 0, 0,
@@ -411,6 +416,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
fprintf (stderr, _("End of #embed search list.\n"));
}
}
+
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
+ if (flag_poison_system_directories)
+ {
+ struct cpp_dir *p;
+
+ for (p = heads[INC_QUOTE]; p; p = p->next)
+ {
+ if ((!strncmp (p->name, "/usr/include", 12))
+ || (!strncmp (p->name, "/usr/local/include", 18))
+ || (!strncmp (p->name, "/usr/X11R6/include", 18))
+ || (!strncmp (p->name, "/sw/include", 11))
+ || (!strncmp (p->name, "/opt/include", 12)))
+ warning (OPT_Wpoison_system_directories,
+ "include location \"%s\" is unsafe for "
+ "cross-compilation",
+ p->name);
+ }
+ }
+#endif
}
/* Use given -I paths for #include "..." but not #include <...>, and
--
2.50.1

View file

@ -0,0 +1,44 @@
From 90e8697dd88fd99ce2cf8739e95494853005377e Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:45:49 +0000
Subject: [PATCH] specs: turn on -Wl,-z,now by default
Previously, we also used to turn on -z relro here, but we now build
binutils with --enable-relro, which is functionally equivalent.
Binutils does not appear to have a similar option for enabling -z
now by default.
---
gcc/doc/invoke.texi | 3 +++
gcc/gcc.cc | 1 +
2 files changed, 4 insertions(+)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 29aea724731..6fb3ab70cc7 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -19477,6 +19477,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,now} is used. To disable, use @option{-Wl,-z,nonow}.
+
@opindex u
@item -u @var{symbol}
Pretend the symbol @var{symbol} is undefined, to force linking of
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 79d4920a047..74a356fdf5e 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1170,6 +1170,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 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.50.1

View file

@ -0,0 +1,46 @@
From 17c9cf9272077bc7ac784daffd4c68ba1ce67a0d 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.cc | 4 ++++
gcc/doc/invoke.texi | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 4589ee4a3a6..9edf095384c 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1581,6 +1581,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 6fb3ab70cc7..799ce073dbf 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12840,6 +12840,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}.
+
@opindex O3
@item -O3
Optimize yet more. @option{-O3} turns on all optimizations specified
--
2.50.1

View file

@ -0,0 +1,286 @@
From 95d8fac6247b2cba1142261cc95c21063539112a Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:46:56 +0000
Subject: [PATCH] On linux targets pass --as-needed by default to the linker,
but always link the sanitizer libraries with --no-as-needed.
---
gcc/config/aarch64/aarch64-linux.h | 1 +
gcc/config/alpha/linux-elf.h | 2 +-
gcc/config/arm/linux-elf.h | 1 +
gcc/config/gnu-user.h | 6 +++---
gcc/config/i386/gnu-user.h | 2 +-
gcc/config/i386/gnu-user64.h | 1 +
gcc/config/ia64/linux.h | 2 +-
gcc/config/loongarch/gnu-user.h | 2 +-
gcc/config/mips/gnu-user.h | 1 +
gcc/config/riscv/linux.h | 1 +
gcc/config/rs6000/linux64.h | 4 ++--
gcc/config/rs6000/sysv4.h | 2 +-
gcc/config/s390/linux.h | 2 +-
gcc/config/sparc/linux.h | 2 +-
gcc/gcc.cc | 28 ++++++++++++++++++++--------
15 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 116bb4e69f3..daf99f8dce9 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -39,6 +39,7 @@
#define CPP_SPEC "%{pthread:-D_REENTRANT}"
#define LINUX_TARGET_LINK_SPEC "%{h*} \
+ --as-needed \
%{static:-Bstatic} \
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
index 3fd3b831166..0b4c2dccebe 100644
--- a/gcc/config/alpha/linux-elf.h
+++ b/gcc/config/alpha/linux-elf.h
@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. If not see
#define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER
-#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
+#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \
%{O*:-O3} %{!O*:-O1} \
%{shared:-shared} \
%{!shared: \
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index d4d389e2aa8..adccc0b11c2 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -70,6 +70,7 @@
%{rdynamic:-export-dynamic} \
%{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
-X \
+ --as-needed \
%{mbig-endian:-EB} %{mlittle-endian:-EL}" \
SUBTARGET_EXTRA_LINK_SPEC
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 4c4e31efa39..3c17ac6eade 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
"%{static-libasan:%{!shared:" \
LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
- LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
+ LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
#undef LIBHWASAN_EARLY_SPEC
#define LIBHWASAN_EARLY_SPEC "%{!shared:libhwasan_preinit%O%s} " \
"%{static-libhwasan:%{!shared:" \
@@ -146,12 +146,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
"%{static-libtsan:%{!shared:" \
LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
- LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
+ LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
#undef LIBLSAN_EARLY_SPEC
#define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
"%{static-liblsan:%{!shared:" \
LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
- LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
+ LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
#endif
#undef TARGET_F951_OPTIONS
diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 7abfda53049..ceb8f855b7d 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3. If not see
{ "link_emulation", GNU_USER_LINK_EMULATION },\
{ "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
-#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
+#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \
%{!shared: \
%{!static: \
%{!static-pie: \
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index abe714711bf..3ca128a79f5 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
"%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
%{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
%{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
+ --as-needed \
%{shared:-shared} \
%{!shared: \
%{!static: \
diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h
index a2494c214c4..e1a5d530cdf 100644
--- a/gcc/config/ia64/linux.h
+++ b/gcc/config/ia64/linux.h
@@ -58,7 +58,7 @@ do { \
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
#undef LINK_SPEC
-#define LINK_SPEC "\
+#define LINK_SPEC " --as-needed \
%{shared:-shared} \
%{!shared: \
%{!static: \
diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h
index fbc75a90ad5..adbc4b7733f 100644
--- a/gcc/config/loongarch/gnu-user.h
+++ b/gcc/config/loongarch/gnu-user.h
@@ -44,7 +44,7 @@ along with GCC; see the file COPYING3. If not see
#undef GNU_USER_TARGET_LINK_SPEC
#define GNU_USER_TARGET_LINK_SPEC \
- "%{G*} %{shared} -m " GNU_USER_LINK_EMULATION \
+ "%{G*} %{shared} --as-needed -m " GNU_USER_LINK_EMULATION \
"%{!shared: %{static} " \
"%{!static: %{!static-pie: %{rdynamic:-export-dynamic} " \
"-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} " \
diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h
index 5a82508c113..6eee7cdc603 100644
--- a/gcc/config/mips/gnu-user.h
+++ b/gcc/config/mips/gnu-user.h
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
#undef GNU_USER_TARGET_LINK_SPEC
#define GNU_USER_TARGET_LINK_SPEC "\
%{G*} %{EB} %{EL} %{mips*} %{shared} \
+ -as-needed \
%{!shared: \
%{!static: \
%{rdynamic:-export-dynamic} \
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 9060c940a44..282c77b6a7b 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
"%{mabi=ilp32:_ilp32}"
#define LINK_SPEC "\
+-as-needed \
-melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
%{mno-relax:--no-relax} \
-X \
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 0316d8cb65d..139e1b6796c 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -378,13 +378,13 @@ extern int dot_symbols;
" -m elf64ppc")
#endif
-#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
+#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --as-needed %{!shared: %{!static: \
%{!static-pie: \
%{rdynamic:-export-dynamic} \
-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \
%(link_os_extra_spec32)"
-#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \
+#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --as-needed %{!shared: %{!static: \
%{!static-pie: \
%{rdynamic:-export-dynamic} \
-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index afb5c6ad867..b64638fb25b 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -781,7 +781,7 @@ GNU_USER_TARGET_CC1_SPEC
#define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
#endif
-#define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
+#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --as-needed %{!shared: %{!static: \
%{rdynamic:-export-dynamic} \
-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
index 2c3bca5dfcb..b90661247a4 100644
--- a/gcc/config/s390/linux.h
+++ b/gcc/config/s390/linux.h
@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3. If not see
#undef LINK_SPEC
#define LINK_SPEC \
- "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
+ "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \
%{shared:-shared} \
%{!shared: \
%{static:-static} \
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 6d928846895..3cc05bb7240 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
#undef LINK_SPEC
-#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
+#define LINK_SPEC "-m elf32_sparc --as-needed %{shared:-shared} \
%{!mno-relax:%{!r:-relax}} \
%{!shared: \
%{!static: \
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 74a356fdf5e..fc9c7d15b04 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -774,8 +774,11 @@ proper position among the other output files. */
#ifdef LIBASAN_EARLY_SPEC
#define LIBASAN_SPEC STATIC_LIBASAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
-#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \
- "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \
+#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \
+ " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " -lasan " \
+ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \
+ " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
STATIC_LIBASAN_LIBS
#else
#define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
@@ -810,8 +813,11 @@ proper position among the other output files. */
#ifdef LIBTSAN_EARLY_SPEC
#define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
-#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \
- "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
+#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \
+ " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " -ltsan " \
+ " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
+ " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
STATIC_LIBTSAN_LIBS
#else
#define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
@@ -828,8 +834,11 @@ proper position among the other output files. */
#ifdef LIBLSAN_EARLY_SPEC
#define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
-#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \
- "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
+#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \
+ " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " -llsan " \
+ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
+ " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
STATIC_LIBLSAN_LIBS
#else
#define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
@@ -844,8 +853,11 @@ proper position among the other output files. */
#define STATIC_LIBUBSAN_LIBS \
" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
#ifdef HAVE_LD_STATIC_DYNAMIC
-#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \
- "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
+#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \
+ " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " -lubsan " \
+ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
+ " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
STATIC_LIBUBSAN_LIBS
#else
#define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
--
2.50.1

View file

@ -0,0 +1,34 @@
From 58a94690d4dd7b34543d9d154abc96d2d90d3b32 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 75b6531860e..78830ce4b42 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -805,7 +805,7 @@ Warn about function calls with format strings that write past the end
of the destination region.
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
@@ -830,7 +830,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.
Wframe-address
--
2.50.1

View file

@ -0,0 +1,25 @@
From b2a755b671d88c34402290d7d769232e01aed350 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 01:44:20 -0700
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 bea1adc0940..e65a575d9f8 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -829,7 +829,7 @@ Common Var(warn_tautological_compare) Warning LangEnabledBy(C ObjC C++ ObjC++,Wa
Warn if a comparison always evaluates to true or false.
Wtrampolines
-Common Var(warn_trampolines) Warning
+Common Var(warn_trampolines) Init(1) Warning
Warn whenever a trampoline is generated.
Wtrivial-auto-var-init
--
2.50.1

View file

@ -0,0 +1,39 @@
From c355364231395090e7223ec00d8a16065903c2c5 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 01:49:03 -0700
Subject: [PATCH] gcc: disable SSP on -ffreestanding, -nostdlib and
-nodefaultlibs
---
gcc/gcc.cc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index fc9c7d15b04..7b0d3d2743b 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1009,6 +1009,12 @@ proper position among the other output files. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
#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" \
@@ -1314,7 +1320,7 @@ static const char *cc1_options =
%{-version:--version}\
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
- %{fsyntax-only:-o %j} %{-param*}\
+ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
--
2.50.1

View file

@ -0,0 +1,25 @@
From 5f09842c19d6db976724cd117190a8a6951acf9b Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 01:50:42 -0700
Subject: [PATCH] gcc: params: set default ssp-buffer-size to 4
---
gcc/params.opt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/params.opt b/gcc/params.opt
index 64e453d29b7..bba3fd574f2 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1064,7 +1064,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
The maximum number of SSA_NAME assignments to follow in determining a value.
-param=ssp-buffer-size=
-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
+Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
The lower bound for a buffer to be considered for stack smashing protection.
-param=stack-clash-protection-guard-size=
--
2.50.1

View file

@ -0,0 +1,54 @@
From ee0615536ae0d255f59070b904aa35d6de8fce49 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 7f84a99533e..a4c6284f788 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 8e93445acd2..d6ff06e5ddb 100644
--- a/libstdc++-v3/po/Makefile.in
+++ b/libstdc++-v3/po/Makefile.in
@@ -561,6 +561,7 @@ uninstall-am:
.po.mo:
+ env --unset=LD_LIBRARY_PATH \
$(MSGFMT) -o $@ $<
all-local: all-local-$(USE_NLS)
--
2.50.1

View file

@ -0,0 +1,28 @@
From 62966418472466142a9962892177f4b1f9f56944 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 d4e8791b14b..c074980ed80 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -678,8 +678,11 @@ extern void *bsearch_r (const void *, const void *,
/* 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.50.1

View file

@ -0,0 +1,24 @@
From 0351f4f3dd00bdece780ce5e24d972e97ca1b7ed Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:53:00 +0000
Subject: [PATCH] libiberty: copy PIC objects during build process
---
libiberty/Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index ce54d88278d..10c212a1ad3 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -266,6 +266,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
$(RANLIB) $(TARGETLIB); \
+ cp $(TARGETLIB) ../ ; \
cd ..; \
else true; fi
--
2.50.1

View file

@ -0,0 +1,57 @@
From bd7e32d5405b6b4f3994a212a77ff2cd33134c74 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.cc | 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.cc b/gcc/config/i386/i386-expand.cc
index cdfd94d3c73..a3a6c988833 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -13643,10 +13643,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 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 2484dc839bf..e980030ef23 100644
--- a/libgcc/config/i386/cpuinfo.c
+++ b/libgcc/config/i386/cpuinfo.c
@@ -63,7 +63,7 @@ __cpu_indicator_init (void)
__cpu_features2);
}
-#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.50.1

View file

@ -0,0 +1,85 @@
From c191dc86f4f7340542066f4156aa57be9cfbf876 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 7 Nov 2015 02:08:05 +0000
Subject: [PATCH] nopie
---
gcc/configure | 25 +++++++++++++++++++++++++
gcc/configure.ac | 11 +++++++++++
2 files changed, 36 insertions(+)
diff --git a/gcc/configure b/gcc/configure
index 0f4a5d52c30..343563c8948 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -34586,6 +34586,29 @@ rm -f core conftest.err conftest.$ac_objext \
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
$as_echo "$gcc_cv_no_pie" >&6; }
+# Check if -nopie works.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5
+$as_echo_n "checking for -nopie option... " >&6; }
+if ${gcc_cv_nopie+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -nopie"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) {return 0;}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ gcc_cv_nopie=yes
+else
+ gcc_cv_nopie=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$saved_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5
+$as_echo "$gcc_cv_nopie" >&6; }
if test x$enable_host_shared = xyes; then
PICFLAG=-fPIC
@@ -34603,6 +34626,8 @@ if test x$enable_host_pie = xyes; then
LD_PICFLAG=-pie
elif test x$gcc_cv_no_pie = xyes; then
LD_PICFLAG=-no-pie
+elif test x$gcc_cv_nopie = xyes; then
+ LD_PICFLAG=-nopie
else
LD_PICFLAG=
fi
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b0e3615e5aa..b3948469d17 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7802,6 +7802,15 @@ AC_CACHE_CHECK([for -no-pie option],
[gcc_cv_no_pie=yes],
[gcc_cv_no_pie=no])
LDFLAGS="$saved_LDFLAGS"])
+# Check if -nopie works.
+AC_CACHE_CHECK([for -nopie option],
+ [gcc_cv_nopie],
+ [saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -nopie"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
+ [gcc_cv_nopie=yes],
+ [gcc_cv_nopie=no])
+ LDFLAGS="$saved_LDFLAGS"])
if test x$enable_host_shared = xyes; then
PICFLAG=-fPIC
@@ -7819,6 +7828,8 @@ if test x$enable_host_pie = xyes; then
LD_PICFLAG=-pie
elif test x$gcc_cv_no_pie = xyes; then
LD_PICFLAG=-no-pie
+elif test x$gcc_cv_nopie = xyes; then
+ LD_PICFLAG=-nopie
else
LD_PICFLAG=
fi
--
2.50.1

View file

@ -0,0 +1,42 @@
From f1d6c0950e0f12fb8cf2429da570f478a1369286 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 9e3385ca94f..2c0cca6e480 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.50.1

View file

@ -0,0 +1,24 @@
From 8773e0cf880da9fe80de7f8a662359664bb0b234 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 b1ed67d3d4f..1e039c20550 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -179,6 +179,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.50.1

View file

@ -0,0 +1,25 @@
From 625b8095796f24389fdda5bb5bc6ff9fbb365813 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 d6280a4d4dd..ba69fb9fad7 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -159,6 +159,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.50.1

View file

@ -0,0 +1,31 @@
From c557286adc46536fe033df400c50a880b672cfd6 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.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 7b0d3d2743b..e46e976a2e8 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1017,8 +1017,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.50.1

View file

@ -0,0 +1,69 @@
From d698fead9d201ef032e2e978898864335a9ab513 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 07:03:42 +0000
Subject: [PATCH] DP: Use --push-state/--pop-state for gold as well when
linking libtsan.
---
gcc/gcc.cc | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index e46e976a2e8..607c8ca1d42 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -775,10 +775,10 @@ proper position among the other output files. */
#define LIBASAN_SPEC STATIC_LIBASAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \
- " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " %{!static-libasan:--push-state --no-as-needed}" \
" -lasan " \
" %{static-libasan:" LD_DYNAMIC_OPTION "}" \
- " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ " %{!static-libasan:--pop-state}" \
STATIC_LIBASAN_LIBS
#else
#define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
@@ -814,10 +814,10 @@ proper position among the other output files. */
#define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \
- " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " %{!static-libtsan:--push-state --no-as-needed}" \
" -ltsan " \
" %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
- " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ " %{!static-libtsan:--pop-state}" \
STATIC_LIBTSAN_LIBS
#else
#define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
@@ -835,10 +835,10 @@ proper position among the other output files. */
#define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \
- " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " %{!static-liblsan:--push-state --no-as-needed}" \
" -llsan " \
" %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
- " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ " %{!static-liblsan:--pop-state}" \
STATIC_LIBLSAN_LIBS
#else
#define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
@@ -854,10 +854,10 @@ proper position among the other output files. */
" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
#ifdef HAVE_LD_STATIC_DYNAMIC
#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \
- " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
+ " %{!static-libubsan:--push-state --no-as-needed}" \
" -lubsan " \
" %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
- " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ " %{!static-libubsan:--pop-state}" \
STATIC_LIBUBSAN_LIBS
#else
#define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
--
2.50.1

View file

@ -0,0 +1,26 @@
From 9cf1916bd52d61ea0fd7a8b6acebb1dc4a1f2488 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Thu, 6 Jan 2022 03:12:55 +0000
Subject: [PATCH] aarch64: disable multilib support
multilib is unsupported on Alpine GCC
---
gcc/config/aarch64/t-aarch64-linux | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux
index 70e36b3299e..e00c3becd3f 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)
--
2.50.1

View file

@ -0,0 +1,25 @@
From dc07fb7df8d4f997877d8f98ea9ef8292f738ed3 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Thu, 6 Jan 2022 03:13:59 +0000
Subject: [PATCH] s390x: disable multilib support
multilib is not supported on Alpine GCC at present
---
gcc/config/s390/t-linux64 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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.50.1

View file

@ -0,0 +1,81 @@
From 496067ded4a3698468412e240b899755d92b314c Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Thu, 6 Jan 2022 03:14:33 +0000
Subject: [PATCH] ppc64[le]: disable multilib support
multilib is not presently supported on Alpine GCC
---
gcc/config/rs6000/t-linux | 6 ++++--
gcc/config/rs6000/t-linux64 | 4 ++--
gcc/config/rs6000/t-linux64bele | 4 ++--
gcc/config/rs6000/t-linux64lebe | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/gcc/config/rs6000/t-linux b/gcc/config/rs6000/t-linux
index 4e371255533..128c75c7d39 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 f56b47c268e..c5f757a6284 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.cc
$(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}
--
2.50.1

View file

@ -0,0 +1,26 @@
From 3d0f96f3f53a7ff81532f077e9db69d7318db796 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Thu, 6 Jan 2022 03:14:54 +0000
Subject: [PATCH] x86_64: disable multilib support
multilib is not presently supported on Alpine GCC
---
gcc/config/i386/t-linux64 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
index 64a4a20e64f..9a8eb8dd8d1 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)
--
2.50.1

View file

@ -0,0 +1,78 @@
From b1ab523d6fa44aae8f3ec5f787a8f86f8686bf64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Mon, 3 Jan 2022 07:14:48 +0100
Subject: [PATCH] riscv: disable multilib support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From the musl wiki [1]:
musl does not support sharing an include directory between archs
[…], and thus is not compatible with GCC-style multilib. It is
recommended that distributions build GCC with multilib disabled,
and use library directories named lib, not lib64 or lib32.
For this reason, we patch existing GCC configuration files (gcc/config)
to pin MULTILIB_OSDIRNAMES to lib, there is also a corresponding GCC
upstream bug about this issue [2]. Avoiding the use of lib64 and lib32
directories is a bit more difficult on the RISC-V architecture. This is
due to the fact that the default RISC-V configuration does not only use
the lib64 and lib32 directories but also subdirectories within these
directories for different RISC-V ABIs (e.g. lp64d, lp64, …) [3].
This patch aligns the RISC-V configuration with other architectures by
pinning MULTILIB_OSDIRNAMES to lib for rv64gc (our default RISC-V
-march). Furthermore, this patch removes the ABI-specific startfile
prefix spec. Since both of these impact the default LIBRARY_PATH [4]
this patch thereby aligns the default RISC-V LIBRARY_PATH with that from
other Alpine architectures and thereby fixes #13369 [5].
Incidentally, this also fixes gccgo on riscv64, as without this patch
gccgo is otherwise not able to find the *.gox files for the Go standard
library.
[1]: https://wiki.musl-libc.org/guidelines-for-distributions.html#Multilib/multi_arch
[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
[3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889#c14
[4]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.c;h=d4c8746b0aa322286decf92aa72a12f0a393b655;hb=HEAD#l9122
[5]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13369
---
gcc/config/riscv/linux.h | 8 --------
gcc/config/riscv/t-linux | 7 +++++--
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 282c77b6a7b..07adae3d59c 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -61,11 +61,3 @@ along with GCC; see the file COPYING3. If not see
%{rdynamic:-export-dynamic} \
-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
%{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}"
-
-#define STARTFILE_PREFIX_SPEC \
- "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
- "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
- "/lib/ " \
- "/usr/lib/ "
-
-#define RISCV_USE_CUSTOMISED_MULTI_LIB select_by_abi
diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
index a6f64f88d25..f88776ec520 100644
--- a/gcc/config/riscv/t-linux
+++ b/gcc/config/riscv/t-linux
@@ -1,5 +1,8 @@
-# Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
+MULTILIB_OPTIONS := march=rv64gc
+MULTILIB_DIRNAMES := rv64gc
+
+MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib,$(MULTILIB_DIRNAMES)))
MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
+MULTILIB_MATCHES := march?rv64gc=march?rv64imafdc
MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
--
2.50.1

View file

@ -0,0 +1,51 @@
From ee64e5ead8938d5be6cedd674158a25d93711fe3 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 0719fd0615d..80bb8f1622f 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -971,8 +971,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)
@@ -1177,10 +1178,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))))
@@ -1197,6 +1194,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.50.1

View file

@ -0,0 +1,59 @@
From 5adfe740c027fb8dc9931053f55f7eae222e6bb4 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 02:09:02 -0700
Subject: [PATCH] ada: libgnarl: remove use of glibc-specific
pthread_rwlockattr_setkind_np
musl's thread library does not implement it
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
---
gcc/ada/libgnarl/s-osinte__linux.ads | 10 ----------
gcc/ada/libgnarl/s-taprop__linux.adb | 7 -------
2 files changed, 17 deletions(-)
diff --git a/gcc/ada/libgnarl/s-osinte__linux.ads b/gcc/ada/libgnarl/s-osinte__linux.ads
index 7aeb15da523..5551b701e5a 100644
--- a/gcc/ada/libgnarl/s-osinte__linux.ads
+++ b/gcc/ada/libgnarl/s-osinte__linux.ads
@@ -402,16 +402,6 @@ package System.OS_Interface is
(attr : access pthread_rwlockattr_t) return int;
pragma Import (C, pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy");
- PTHREAD_RWLOCK_PREFER_READER_NP : constant := 0;
- PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1;
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
-
- function pthread_rwlockattr_setkind_np
- (attr : access pthread_rwlockattr_t;
- pref : int) return int;
- pragma Import
- (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
-
function pthread_rwlock_init
(mutex : access pthread_rwlock_t;
attr : access pthread_rwlockattr_t) return int;
diff --git a/gcc/ada/libgnarl/s-taprop__linux.adb b/gcc/ada/libgnarl/s-taprop__linux.adb
index 8f4c835baa7..6df36c7d8f4 100644
--- a/gcc/ada/libgnarl/s-taprop__linux.adb
+++ b/gcc/ada/libgnarl/s-taprop__linux.adb
@@ -409,16 +409,9 @@ package body System.Task_Primitives.Operations is
Result : C.int;
begin
- -- Set the rwlock to prefer writer to avoid writers starvation
-
Result := pthread_rwlockattr_init (RWlock_Attr'Access);
pragma Assert (Result = 0);
- Result := pthread_rwlockattr_setkind_np
- (RWlock_Attr'Access,
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
- pragma Assert (Result = 0);
-
Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
pragma Assert (Result in 0 | ENOMEM);
--
2.50.1

View file

@ -0,0 +1,50 @@
From c8edb618208a854d121ff73c0d82d7cc467a3611 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 02:13:19 -0700
Subject: [PATCH] ada: libgnarl: use posix_openpt instead of glibc-specific
getpt to open a pty
musl only implements posix_openpt(3), not the older glibc-specific getpt()
and glibc implements both for ages.
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
---
gcc/ada/terminals.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c
index 89f887556c0..93557fe2631 100644
--- a/gcc/ada/terminals.c
+++ b/gcc/ada/terminals.c
@@ -1134,7 +1134,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
/* 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
@@ -1148,7 +1148,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
#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)
@@ -1197,8 +1197,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.50.1

View file

@ -0,0 +1,54 @@
From d3c515c40b9ec0133787388ae7df037e88a95f73 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 02:18:49 -0700
Subject: [PATCH] ada: libgnarl: adaint: fix sched.h inclusion for musl
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
---
gcc/ada/adaint.c | 6 +++++-
gcc/ada/adaint.h | 5 +++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 1fcfae165a7..67318e647ed 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -95,6 +95,11 @@
#include <sys/pstat.h>
#endif
+#if defined (linux) || defined(__linux__)
+#define _GNU_SOURCE 1
+#include <sched.h>
+#endif
+
#ifdef __PikeOS__
#define __BSD_VISIBLE 1
#endif
@@ -3476,7 +3481,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
diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h
index 3df12b5f956..26a489f2b78 100644
--- a/gcc/ada/adaint.h
+++ b/gcc/ada/adaint.h
@@ -40,6 +40,11 @@ extern "C" {
#include "mingw32.h"
#endif
+#if defined (linux) || defined(__linux__)
+#define _GNU_SOURCE 1
+#include <sched.h>
+#endif
+
#include <dirent.h>
/* Constants used for the form parameter encoding values */
--
2.50.1

View file

@ -0,0 +1,256 @@
From 3d13edda0134af3fbb802cdec6406c91003bbc33 Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Wed, 9 Dec 2020 07:42:06 +0000
Subject: [PATCH] configure: Add --enable-autolink-libatomic, use in
LINK_GCC_C_SEQUENCE_SPEC [PR81358]
This fixes issues with RISC-V.
---
Makefile.in | 1 +
gcc/config.in | 6 ++++++
gcc/config/gnu-user.h | 12 +++++++++++-
gcc/configure | 31 ++++++++++++++++++++++++++++++-
gcc/configure.ac | 21 +++++++++++++++++++++
gcc/doc/install.texi | 8 ++++++++
gcc/doc/tm.texi | 8 +++++++-
gcc/doc/tm.texi.in | 8 +++++++-
gcc/gcc.cc | 12 +++++++++++-
9 files changed, 102 insertions(+), 5 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 1e039c20550..20f535a306a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -238,6 +238,7 @@ HOST_EXPORTS = \
RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \
TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
+ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \
HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \
GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
GMPINC="$(HOST_GMPINC)"; export GMPINC; \
diff --git a/gcc/config.in b/gcc/config.in
index 8a531ed591c..40045ff35a5 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -131,6 +131,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/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 3c17ac6eade..0426efdb8c3 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
#endif
+#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC)
+# ifdef LD_AS_NEEDED_OPTION
+# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION
+# else
+# define LINK_LIBATOMIC_SPEC "-latomic"
+# endif
+#elif !defined(LINK_LIBATOMIC_SPEC)
+# define LINK_LIBATOMIC_SPEC ""
+#endif
+
#define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
- "%{static|static-pie:--start-group} %G %{!nolibc:%L} \
+ "%{static|static-pie:--start-group} %G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L} \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
#undef LINK_GCC_C_SEQUENCE_SPEC
diff --git a/gcc/configure b/gcc/configure
index 343563c8948..54300a2a867 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -1003,6 +1003,7 @@ with_changes_root_url
enable_languages
with_multilib_list
with_multilib_generator
+enable_autolink_libatomic
with_zstd
with_zstd_include
with_zstd_lib
@@ -1742,6 +1743,9 @@ Optional Features:
--disable-shared don't provide a shared libgcc
--disable-gcov don't provide libgcov and related host tools
--enable-languages=LIST specify which front-ends to build
+ --enable-autolink-libatomic
+ enable automatic linking of libatomic (ignored if
+ not built)
--disable-rpath do not hardcode runtime library paths
--enable-sjlj-exceptions
arrange to use setjmp/longjmp exception handling
@@ -8400,7 +8404,6 @@ else
fi
-
# Check whether --with-multilib-generator was given.
if test "${with_multilib_generator+set}" = set; then :
withval=$with_multilib_generator; :
@@ -8408,6 +8411,32 @@ else
with_multilib_generator=default
fi
+# If libatomic is available, whether it should be linked automatically
+# Check whether --enable-autolink-libatomic was given.
+if test "${enable_autolink_libatomic+set}" = set; then :
+ enableval=$enable_autolink_libatomic;
+ case $enable_autolink_libatomic in
+ yes | no) ;;
+ *) as_fn_error $? "'$enable_autolink_libatomic' is an invalid value for
+--enable-autolink-libatomic. Valid choices are 'yes' and 'no'." "$LINENO" 5 ;;
+ esac
+
+else
+ enable_autolink_libatomic=''
+fi
+
+
+if test x$enable_autolink_libatomic = xyes; then
+ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then
+
+$as_echo "#define ENABLE_AUTOLINK_LIBATOMIC 1" >>confdefs.h
+
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&5
+$as_echo "$as_me: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&2;}
+ fi
+fi
+
# -------------------------
# Checks for other programs
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b3948469d17..81c070830e2 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1227,6 +1227,27 @@ AC_ARG_WITH(multilib-generator,
:,
with_multilib_generator=default)
+# If libatomic is available, whether it should be linked automatically
+AC_ARG_ENABLE(autolink-libatomic,
+[AS_HELP_STRING([--enable-autolink-libatomic],
+ [enable automatic linking of libatomic (ignored if not built)])],
+[
+ case $enable_autolink_libatomic in
+ yes | no) ;;
+ *) AC_MSG_ERROR(['$enable_autolink_libatomic' is an invalid value for
+--enable-autolink-libatomic. Valid choices are 'yes' and 'no'.]) ;;
+ esac
+], [enable_autolink_libatomic=''])
+
+if test x$enable_autolink_libatomic = xyes; then
+ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then
+ AC_DEFINE(ENABLE_AUTOLINK_LIBATOMIC, 1,
+ [Define if libatomic should always be linked.])
+ else
+ AC_MSG_WARN([libatomic is not build for this target, --enable-autolink-libatomic ignored])
+ fi
+fi
+
# -------------------------
# Checks for other programs
# -------------------------
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 3e9e09b4ae3..6e7b756be61 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -2617,6 +2617,14 @@ files, but these changed header paths may conflict with some compilation
environments. Enabled by default, and may be disabled using
@option{--disable-canonical-system-headers}.
+@item --enable-autolink-libatomic
+@itemx --disable-autolink-libatomic
+Tell GCC that it should automatically link libatomic; if supported by
+the linker, the file is only linked as needed. This flag is ignored
+when libatomic is not built. Note that this conigure flag is in particular
+useful when building an offloading-target compiler; as for those, a
+user had to specify @code{-foffload=target=-latomic} otherwise.
+
@item --with-glibc-version=@var{major}.@var{minor}
Tell GCC that when the GNU C Library (glibc) is used on the target it
will be version @var{major}.@var{minor} or later. Normally this can
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index a96700c0d38..16deedca64d 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -390,7 +390,13 @@ the argument @option{-lgcc} to tell the linker to do the search.
@defmac LINK_GCC_C_SEQUENCE_SPEC
The sequence in which libgcc and libc are specified to the linker.
-By default this is @code{%G %L %G}.
+By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}.
+@end defmac
+
+@defmac LINK_LIBATOMIC_SPEC
+This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link
+libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC}
+is set.
@end defmac
@defmac POST_LINK_SPEC
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index eccc4d88493..4ca4c610571 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -390,7 +390,13 @@ the argument @option{-lgcc} to tell the linker to do the search.
@defmac LINK_GCC_C_SEQUENCE_SPEC
The sequence in which libgcc and libc are specified to the linker.
-By default this is @code{%G %L %G}.
+By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}.
+@end defmac
+
+@defmac LINK_LIBATOMIC_SPEC
+This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link
+libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC}
+is set.
@end defmac
@defmac POST_LINK_SPEC
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 607c8ca1d42..e9f78f0f4c1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1000,13 +1000,23 @@ proper position among the other output files. */
# define ASM_DEBUG_OPTION_SPEC ""
#endif
+#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC)
+# ifdef LD_AS_NEEDED_OPTION
+# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION
+# else
+# define LINK_LIBATOMIC_SPEC "-latomic"
+# endif
+#elif !defined(LINK_LIBATOMIC_SPEC)
+# define LINK_LIBATOMIC_SPEC ""
+#endif
+
/* Here is the spec for running the linker, after compiling all files. */
/* This is overridable by the target in case they need to specify the
-lgcc and -lc order specially, yet not require them to override all
of LINK_COMMAND_SPEC. */
#ifndef LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}"
#endif
#ifdef ENABLE_DEFAULT_SSP
--
2.50.1

View file

@ -0,0 +1,57 @@
From ddc31942d7363acc938007d70f29e3e324064f76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Sun, 29 Aug 2021 12:23:34 +0200
Subject: [PATCH] configure: fix detection of atomic builtins in libatomic
configure script
Alpine's --enable-autolink-libatomic (which is enabled for riscv64 by
default) causes the libatomic configure script to incorrectly detect
which builtins are available on riscv64. This then causes incorrect code
generation for libatomic since it assumes compiler builtins to be
available which are not actually available on riscv64.
This commit fixes this issue by disabling linking of libatomic configure
test code entirely, thereby preventing linking against libatomic.
See:
* https://gitlab.alpinelinux.org/alpine/aports/-/issues/12948
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c6
---
libatomic/configure.tgt | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index 6db039d6e8b..2751b5c1387 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -30,6 +30,26 @@
# on ${target_cpu}. For example to allow proper use of multilibs.
configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}"
+# The libatomic configure script performs several checks to determine
+# whether builtins for atomic operations are available. When compiling
+# with --enable-autolink-libatomic the test code compiled by the
+# configure script is also linked against libatomic. This causes it
+# to think that builtins are available, even if there are not, since
+# the tested symbols are provided by libatomic.
+#
+# This is a hack to ensure that we don't link against libatomic by not
+# linking any configure test code at all when --enable-autolink-libatomic
+# is given.
+#
+# See:
+#
+# * https://gitlab.alpinelinux.org/alpine/aports/-/issues/12817
+# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c4
+#
+if test x$enable_autolink_libatomic = xyes; then
+ gcc_no_link=yes
+fi
+
case "${target_cpu}" in
alpha*)
# fenv.c needs this option to generate inexact exceptions.
--
2.50.1

View file

@ -0,0 +1,27 @@
From e9f4662af949bc56eef27d531605dd90181bc300 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Thu, 30 Jun 2022 16:44:51 +0000
Subject: [PATCH] libstdc++: do not throw exceptions for non-C locales on musl
targets
---
libstdc++-v3/config/locale/generic/c_locale.cc | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc
index bfd02b5c2c6..16f9e84d66f 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Currently, the generic model only supports the "C" locale.
// See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
__cloc = 0;
- if (strcmp(__s, "C"))
- __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
- "name not valid"));
}
void
--
2.50.1

View file

@ -0,0 +1,26 @@
From b4c412a5d538f7478596880e89d0e6d5046ef16b Mon Sep 17 00:00:00 2001
From: Mathias LANG <pro.mathias.lang@gmail.com>
Date: Mon, 17 Jan 2022 03:49:21 +0000
Subject: [PATCH] gdc: unconditionally link libgphobos against libucontext
ref: alpine/aports#13422
---
Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index 20f535a306a..c087bfe7cd4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -54382,7 +54382,7 @@ configure-target-libphobos:
esac; \
module_srcdir=libphobos; \
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.50.1

View file

@ -0,0 +1,54 @@
From 0c10e5ee09685a5ecc39650e8ec8a1b4f5e096e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Sat, 16 Jul 2022 09:21:11 +0200
Subject: [PATCH] druntime: link against libucontext on all platforms
On musl-based Linux distributions, swapcontext etc. are not provided by
musl but instead by libucontext. Hence, we _always_ need to link against
an external library for these functions.
---
libphobos/configure | 8 --------
libphobos/m4/druntime/libraries.m4 | 8 --------
2 files changed, 16 deletions(-)
diff --git a/libphobos/configure b/libphobos/configure
index 4f5be7d4ff4..0a48032edb4 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -15420,14 +15420,6 @@ fi
# Keep this in sync with core/thread.d, set druntime_fiber_asm_external to
# "yes" for targets that have 'version = AsmExternal'.
druntime_fiber_asm_external=no
- case "$target_cpu" in
- aarch64* | \
- arm* | \
- i[34567]86|x86_64 | \
- powerpc)
- druntime_fiber_asm_external=yes
- ;;
- esac
if test "$druntime_fiber_asm_external" = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5
$as_echo_n "checking for library containing swapcontext... " >&6; }
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
index 8dd9c7da107..b61bf528a14 100644
--- a/libphobos/m4/druntime/libraries.m4
+++ b/libphobos/m4/druntime/libraries.m4
@@ -220,14 +220,6 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
# Keep this in sync with core/thread.d, set druntime_fiber_asm_external to
# "yes" for targets that have 'version = AsmExternal'.
druntime_fiber_asm_external=no
- case "$target_cpu" in
- aarch64* | \
- arm* | \
- i[[34567]]86|x86_64 | \
- powerpc)
- druntime_fiber_asm_external=yes
- ;;
- esac
if test "$druntime_fiber_asm_external" = no; then
AC_SEARCH_LIBS([swapcontext], [c ucontext], [],
AC_MSG_ERROR([swapcontext required but not found]))
--
2.50.1

View file

@ -0,0 +1,25 @@
From e5190522319c315efaf9a921737c05fae6a49e85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Tue, 19 Jul 2022 14:54:07 +0200
Subject: [PATCH] libgnat: time_t is always 64-bit on musl libc
---
gcc/ada/libgnat/s-parame.ads | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/ada/libgnat/s-parame.ads b/gcc/ada/libgnat/s-parame.ads
index 98284a4d13e..0d14f116a10 100644
--- a/gcc/ada/libgnat/s-parame.ads
+++ b/gcc/ada/libgnat/s-parame.ads
@@ -101,7 +101,7 @@ package System.Parameters is
-- Characteristics of time_t type --
------------------------------------
- time_t_bits : constant := Long_Integer'Size;
+ time_t_bits : constant := Long_Long_Integer'Size;
-- Number of bits in type time_t
----------------------------------------------
--
2.50.1

View file

@ -0,0 +1,30 @@
From 3fe1ff6c349a065daba97794c55961cafe6c4a10 Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Mon, 29 May 2023 15:33:11 +0000
Subject: [PATCH] libphobos: do not use LFS64 symbols
musl does not have these since 1.2.4, we can't use the compat interfaces.
---
libphobos/libdruntime/core/sys/posix/sys/mman.d | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d
index b1eb9fa8107..3aee0d96319 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/mman.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d
@@ -293,11 +293,7 @@ else version (CRuntime_Bionic)
}
else version (CRuntime_Musl)
{
- static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t);
- static if (__USE_FILE_OFFSET64)
- alias mmap = mmap64;
- else
- void* mmap(void*, size_t, int, int, int, off_t);
+ void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
}
else version (CRuntime_UClibc)
--
2.50.1

View file

@ -0,0 +1,195 @@
From ff21b1649c1c5009a33722d21e28af9026c72cd7 Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Mon, 10 Jul 2023 23:23:29 +0000
Subject: [PATCH] libgo: fix lfs64 use
---
.../go/internal/syscall/unix/at_largefile.go | 2 +-
libgo/go/os/dir_largefile.go | 2 +-
libgo/go/syscall/libcall_glibc.go | 2 +-
libgo/go/syscall/libcall_linux.go | 4 +--
libgo/go/syscall/libcall_posix_largefile.go | 26 +++++++++----------
libgo/runtime/go-varargs.c | 2 +-
libgo/sysinfo.c | 9 +++----
7 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/libgo/go/internal/syscall/unix/at_largefile.go b/libgo/go/internal/syscall/unix/at_largefile.go
index 82e0dcfd074..16151ecad1b 100644
--- a/libgo/go/internal/syscall/unix/at_largefile.go
+++ b/libgo/go/internal/syscall/unix/at_largefile.go
@@ -10,5 +10,5 @@ import (
"syscall"
)
-//extern fstatat64
+//extern fstatat
func fstatat(int32, *byte, *syscall.Stat_t, int32) int32
diff --git a/libgo/go/os/dir_largefile.go b/libgo/go/os/dir_largefile.go
index 1fc5ee0771f..0c6dffe1a75 100644
--- a/libgo/go/os/dir_largefile.go
+++ b/libgo/go/os/dir_largefile.go
@@ -11,5 +11,5 @@ package os
import "syscall"
-//extern readdir64
+//extern readdir
func libc_readdir(*syscall.DIR) *syscall.Dirent
diff --git a/libgo/go/syscall/libcall_glibc.go b/libgo/go/syscall/libcall_glibc.go
index 5c1ec483c75..5a1245ed44b 100644
--- a/libgo/go/syscall/libcall_glibc.go
+++ b/libgo/go/syscall/libcall_glibc.go
@@ -114,7 +114,7 @@ func Pipe2(p []int, flags int) (err error) {
}
//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error)
-//sendfile64(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t
+//sendfile(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
if race.Enabled {
diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go
index 03ca7261b59..ad21fd0b3ac 100644
--- a/libgo/go/syscall/libcall_linux.go
+++ b/libgo/go/syscall/libcall_linux.go
@@ -158,7 +158,7 @@ func Reboot(cmd int) (err error) {
//adjtimex(buf *Timex) _C_int
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
-//fstatfs64(fd _C_int, buf *Statfs_t) _C_int
+//fstatfs(fd _C_int, buf *Statfs_t) _C_int
func Gettid() (tid int) {
r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0)
@@ -245,7 +245,7 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i
}
//sys Statfs(path string, buf *Statfs_t) (err error)
-//statfs64(path *byte, buf *Statfs_t) _C_int
+//statfs(path *byte, buf *Statfs_t) _C_int
//sysnb Sysinfo(info *Sysinfo_t) (err error)
//sysinfo(info *Sysinfo_t) _C_int
diff --git a/libgo/go/syscall/libcall_posix_largefile.go b/libgo/go/syscall/libcall_posix_largefile.go
index f90055bb29a..334212f0af1 100644
--- a/libgo/go/syscall/libcall_posix_largefile.go
+++ b/libgo/go/syscall/libcall_posix_largefile.go
@@ -10,40 +10,40 @@
package syscall
//sys Creat(path string, mode uint32) (fd int, err error)
-//creat64(path *byte, mode Mode_t) _C_int
+//creat(path *byte, mode Mode_t) _C_int
//sys Fstat(fd int, stat *Stat_t) (err error)
-//fstat64(fd _C_int, stat *Stat_t) _C_int
+//fstat(fd _C_int, stat *Stat_t) _C_int
//sys Ftruncate(fd int, length int64) (err error)
-//ftruncate64(fd _C_int, length Offset_t) _C_int
+//ftruncate(fd _C_int, length Offset_t) _C_int
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
-//getrlimit64(resource _C_int, rlim *Rlimit) _C_int
+//getrlimit(resource _C_int, rlim *Rlimit) _C_int
//sys Lstat(path string, stat *Stat_t) (err error)
-//lstat64(path *byte, stat *Stat_t) _C_int
+//lstat(path *byte, stat *Stat_t) _C_int
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
-//mmap64(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte
+//mmap(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte
//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//__go_open64(path *byte, mode _C_int, perm Mode_t) _C_int
+//__go_open(path *byte, mode _C_int, perm Mode_t) _C_int
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
-//pread64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t
+//pread(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
-//pwrite64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t
+//pwrite(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t
//sys Seek(fd int, offset int64, whence int) (off int64, err error)
-//lseek64(fd _C_int, offset Offset_t, whence _C_int) Offset_t
+//lseek(fd _C_int, offset Offset_t, whence _C_int) Offset_t
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
-//setrlimit64(resource int, rlim *Rlimit) _C_int
+//setrlimit(resource int, rlim *Rlimit) _C_int
//sys Stat(path string, stat *Stat_t) (err error)
-//stat64(path *byte, stat *Stat_t) _C_int
+//stat(path *byte, stat *Stat_t) _C_int
//sys Truncate(path string, length int64) (err error)
-//truncate64(path *byte, length Offset_t) _C_int
+//truncate(path *byte, length Offset_t) _C_int
diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c
index f84860891e6..7efc9615985 100644
--- a/libgo/runtime/go-varargs.c
+++ b/libgo/runtime/go-varargs.c
@@ -84,7 +84,7 @@ __go_ioctl_ptr (int d, int request, void *arg)
int
__go_open64 (char *path, int mode, mode_t perm)
{
- return open64 (path, mode, perm);
+ return open (path, mode, perm);
}
#endif
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 180f5c31d74..1d717d55c0e 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -366,7 +366,7 @@ typedef loff_t libgo_loff_t_type;
#endif
#if defined(HAVE_OFF64_T)
-typedef off64_t libgo_off_t_type;
+typedef off_t libgo_off_t_type;
#else
typedef off_t libgo_off_t_type;
#endif
@@ -398,13 +398,11 @@ typedef off_t libgo_off_t_type;
// From dirent.h
SREF(dirent);
-SREF(dirent64);
OTREF(DIR);
EREF(DT_UNKNOWN);
// From fcntl.h
SREF(flock);
-SREF(flock64);
// From ffi headers
SREF(_ffi_type);
@@ -485,11 +483,10 @@ EREF(SS_ONSTACK);
EREF(SEGV_MAPERR);
// From stat.h
-SREF(stat64);
+SREF(stat);
// From statfs.h
SREF(statfs);
-SREF(statfs64);
// From sysinfo.h
SREF(sysinfo);
@@ -519,7 +516,7 @@ EREF(PTRACE_PEEKTEXT);
// From sys/resource.h
SREF(rusage);
-SREF(rlimit64);
+SREF(rlimit);
EREF(RLIMIT_NOFILE);
EREF(PRIO_USER);
EREF(RUSAGE_SELF);
--
2.50.1

View file

@ -0,0 +1,32 @@
From 0e09546330c7500b0d6d4e6d4bbf4fe751d57c34 Mon Sep 17 00:00:00 2001
From: Jingyun Hua <huajingyun@loongson.cn>
Date: Mon, 7 Aug 2023 15:25:58 +0800
Subject: [PATCH] loongarch disable multilib support
Signed-off-by: Jingyun Hua <huajingyun@loongson.cn>
---
gcc/config/loongarch/t-linux | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/gcc/config/loongarch/t-linux b/gcc/config/loongarch/t-linux
index 45862048abf..73155acd832 100644
--- a/gcc/config/loongarch/t-linux
+++ b/gcc/config/loongarch/t-linux
@@ -21,11 +21,6 @@ MULTIOSDIR_lp64f := ../lib64/f32$(call if_multiarch,:loongarch64-linux-gnuf32)
MULTIOSDIR_lp64s := ../lib64/sf$(call if_multiarch,:loongarch64-linux-gnusf)
# Don't define MULTILIB_OSDIRNAMES if multilib is disabled.
-ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),)
-
- MULTILIB_OSDIRNAMES = .=$(MULTIOSDIR_$(mlib_default))
- MULTILIB_OSDIRNAMES += mabi.lp64d=$(MULTIOSDIR_lp64d)
- MULTILIB_OSDIRNAMES += mabi.lp64f=$(MULTIOSDIR_lp64f)
- MULTILIB_OSDIRNAMES += mabi.lp64s=$(MULTIOSDIR_lp64s)
-
-endif
+ MULTILIB_OSDIRNAMES = mabi.lp64d=../lib
+ MULTILIB_OSDIRNAMES += mabi.lp64f=../lib
+ MULTILIB_OSDIRNAMES += mabi.lp64s=../lib
--
2.50.1

View file

@ -0,0 +1,113 @@
From 05b462e0a6de90c0d69a48ed9c58a6f76158344e Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Fri, 25 Jul 2025 02:41:46 -0700
Subject: [PATCH] static PIE: ensure -static reaches the linker
on some targets, the logic for the compiler option -static seems not
to be processed when -pie is present. rather than playing
whack-a-mole, just ensure LD_PIE_SPEC specs always pass -static to ld
if either -static or -static-pie is present on the compiler driver
command line.
this may produce redundant -static arguments but it doesn't matter.
---
gcc/common.opt | 4 ++--
gcc/config/gnu-user.h | 17 ++++++++---------
gcc/gcc.cc | 6 +++---
3 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index e65a575d9f8..7ad38711f6e 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3968,11 +3968,11 @@ Driver
no-pie
Driver RejectNegative Negative(shared)
-Don't create a dynamically linked position independent executable.
+Don't create a position independent executable.
pie
Driver RejectNegative Negative(no-pie)
-Create a dynamically linked position independent executable.
+Create a position independent executable.
static-pie
Driver RejectNegative Negative(pie)
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 0426efdb8c3..866c8bd77f2 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -51,13 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define GNU_USER_TARGET_STARTFILE_SPEC \
"%{shared:; \
pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
- static:crt1.o%s; \
- static-pie:rcrt1.o%s; \
+ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
" PIE_SPEC ":Scrt1.o%s; \
:crt1.o%s} " \
GNU_USER_TARGET_CRTI " \
- %{static:crtbeginT.o%s; \
- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
+ %{shared|" PIE_SPEC ":crtbeginS.o%s; \
+ static:crtbeginT.o%s; \
:crtbegin.o%s} \
%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_start_preinit.o%s; \
@@ -73,11 +72,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
GNU userspace "finalizer" file, `crtn.o'. */
#define GNU_USER_TARGET_ENDFILE_SPEC \
- "%{!static:%{fvtable-verify=none:%s; \
+ "%{static|static-pie:; \
+ fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_end_preinit.o%s; \
- fvtable-verify=std:vtv_end.o%s}} \
- %{static:crtend.o%s; \
- shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
+ fvtable-verify=std:vtv_end.o%s} \
+ %{shared|" PIE_SPEC ":crtendS.o%s; \
:crtend.o%s} " \
GNU_USER_TARGET_CRTN " " \
CRTOFFLOADEND
@@ -106,7 +105,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
#if defined(HAVE_LD_EH_FRAME_HDR)
-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
+#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
#endif
#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index e9f78f0f4c1..767ff65f348 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1056,7 +1056,7 @@ proper position among the other output files. */
#define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
#define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
#else
-#define PIE_SPEC "pie"
+#define PIE_SPEC "pie|static-pie"
#define FPIE1_SPEC "fpie"
#define NO_FPIE1_SPEC FPIE1_SPEC ":;"
#define FPIE2_SPEC "fPIE"
@@ -1080,12 +1080,12 @@ proper position among the other output files. */
#ifndef LINK_PIE_SPEC
#ifdef HAVE_LD_PIE
#ifndef LD_PIE_SPEC
-#define LD_PIE_SPEC "-pie"
+#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}"
#endif
#else
#define LD_PIE_SPEC ""
#endif
-#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
+#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
#endif
#ifndef LINK_BUILDID_SPEC
--
2.50.1

View file

@ -0,0 +1,77 @@
From 4c8cc9a8621b91f8aa83d8ca81f22b00a98d9fa9 Mon Sep 17 00:00:00 2001
From: Andrew Pinski <quic_apinski@quicinc.com>
Date: Fri, 28 Mar 2025 17:25:56 -0700
Subject: [PATCH] except: Don't use the cached value of the gcc_except_table
section for comdat functions [PR119507]
This has been broken since GCC started to put the comdat functions' gcc_except_table into their
own section; r0-118218-g3e6011cfebedfb. What would happen is after a non-comdat function is processed,
the cached value would always be used even for comdat function. Instead we should create a new
section for comdat functions.
OK? Bootstrapped and tested on x86_64-linux-gnu.
PR middle-end/119507
gcc/ChangeLog:
* except.cc (switch_to_exception_section): Don't use the cached section if
the current function is in comdat.
gcc/testsuite/ChangeLog:
* g++.dg/eh/pr119507.C: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
gcc/except.cc | 9 ++++++++-
gcc/testsuite/g++.dg/eh/pr119507.C | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/eh/pr119507.C
diff --git a/gcc/except.cc b/gcc/except.cc
index 205811c6567..0fe1e093489 100644
--- a/gcc/except.cc
+++ b/gcc/except.cc
@@ -2949,7 +2949,14 @@ switch_to_exception_section (const char * ARG_UNUSED (fnname))
{
section *s;
- if (exception_section)
+ if (exception_section
+ /* Don't use the cached section for comdat if it will be different. */
+#ifdef HAVE_LD_EH_GC_SECTIONS
+ && !(targetm_common.have_named_sections
+ && DECL_COMDAT_GROUP (current_function_decl)
+ && HAVE_COMDAT_GROUP)
+#endif
+ )
s = exception_section;
else
{
diff --git a/gcc/testsuite/g++.dg/eh/pr119507.C b/gcc/testsuite/g++.dg/eh/pr119507.C
new file mode 100644
index 00000000000..50afa75a43f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/pr119507.C
@@ -0,0 +1,17 @@
+// { dg-do compile { target comdat_group } }
+// Force off function sections
+// Force on exceptions
+// { dg-options "-fno-function-sections -fexceptions" }
+// PR middle-end/119507
+
+
+inline int comdat() { try { throw 1; } catch (int) { return 1; } return 0; }
+int another_func_with_exception() { try { throw 1; } catch (int) { return 1; } return 0; }
+inline int comdat1() { try { throw 1; } catch (int) { return 1; } return 0; }
+int foo() { return comdat() + comdat1(); }
+
+// Make sure the gcc puts the exception table for both comdat and comdat1 in their own section
+// { dg-final { scan-assembler-times ".section\[\t \]\[^\n\]*.gcc_except_table._Z6comdatv" 1 } }
+// { dg-final { scan-assembler-times ".section\[\t \]\[^\n\]*.gcc_except_table._Z7comdat1v" 1 } }
+// There should be 3 exception tables,
+// { dg-final { scan-assembler-times ".section\[\t \]\[^\n\]*.gcc_except_table" 3 } }
--
2.50.1

View file

@ -0,0 +1,164 @@
From a6c08fc7fe3a144ebd767cd52fe22043947655e9 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Sat, 26 Jul 2025 02:59:45 -0700
Subject: [PATCH] ada: libgnat: use stub symbolic module name functions
The "linux" implementation depends on glibc internals and accordingly
does not work on musl.
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
---
gcc/ada/Makefile.rtl | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index cb41e6887cd..152ba70db4d 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -1642,7 +1642,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 \
@@ -2014,7 +2014,7 @@ ifeq ($(strip $(filter-out s390% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
system.ads<libgnat/system-linux-s390.ads
ifeq ($(strip $(filter-out s390x,$(target_cpu))),)
@@ -2359,7 +2359,7 @@ ifeq ($(strip $(filter-out loongarch% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix.ads \
g-sercom.adb<libgnat/g-sercom__linux.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
$(GNATRTL_128BIT_PAIRS) \
$(ATOMICS_TARGET_PAIRS) \
$(ATOMICS_BUILTINS_TARGET_PAIRS) \
@@ -2407,7 +2407,7 @@ ifeq ($(strip $(filter-out mips% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
system.ads<libgnat/system-linux-mips.ads
ifeq ($(strip $(filter-out mips64% mipsisa64%,$(target_cpu))),)
@@ -2463,7 +2463,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),)
s-tasinf.adb<libgnarl/s-tasinf__linux.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) \
$(ATOMICS_BUILTINS_TARGET_PAIRS) \
system.ads<libgnat/system-linux-ppc.ads
@@ -2519,7 +2519,7 @@ ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.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-arm.ads
@@ -2565,7 +2565,7 @@ ifeq ($(strip $(filter-out aarch64% 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) \
$(ATOMICS_BUILTINS_TARGET_PAIRS) \
$(GNATRTL_128BIT_PAIRS) \
@@ -2607,7 +2607,7 @@ ifeq ($(strip $(filter-out sparc% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
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 \
system.ads<libgnat/system-linux-sparc.ads
ifeq ($(strip $(filter-out sparc64 sparcv9,$(target_cpu))),)
@@ -2660,7 +2660,7 @@ ifeq ($(strip $(filter-out hppa% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
system.ads<libgnat/system-linux-hppa.ads
TOOLS_TARGET_PAIRS = indepsw.adb<indepsw-gnu.adb
@@ -2697,7 +2697,7 @@ ifeq ($(strip $(filter-out m68k% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
system.ads<libgnat/system-linux-m68k.ads
TOOLS_TARGET_PAIRS = indepsw.adb<indepsw-gnu.adb
@@ -2734,7 +2734,7 @@ ifeq ($(strip $(filter-out sh4% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
system.ads<libgnat/system-linux-sh4.ads
TOOLS_TARGET_PAIRS = indepsw.adb<indepsw-linux.adb
@@ -2779,7 +2779,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) \
$(GNATRTL_128BIT_PAIRS) \
@@ -2859,7 +2859,7 @@ ifeq ($(strip $(filter-out alpha% linux%,$(target_cpu) $(target_os))),)
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.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) \
$(GNATRTL_128BIT_PAIRS) \
@@ -2904,7 +2904,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) \
$(SIMD_PATH_TARGET_PAIRS) \
@@ -2956,7 +2956,7 @@ ifeq ($(strip $(filter-out %x32 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) \
$(SIMD_PATH_TARGET_PAIRS) \
@@ -3000,7 +3000,7 @@ ifeq ($(strip $(filter-out riscv% linux%,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
$(TRASYM_DWARF_UNIX_PAIRS) \
- s-tsmona.adb<libgnat/s-tsmona__linux.adb \
+ s-tsmona.adb<libgnat/s-tsmona.adb \
system.ads<libgnat/system-linux-riscv.ads
ifeq ($(strip $(filter-out riscv64,$(target_cpu))),)
--
2.50.1

View file

@ -0,0 +1,26 @@
From 4b5dfaaa043999f353ade7fc09e7f1bb4a6fe6db Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Sat, 26 Jul 2025 03:02:38 -0700
Subject: [PATCH] ada: libgnat: recognize linux-musleabi and linux-muslgnueabi
platforms for ARM
---
gcc/ada/Makefile.rtl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index 152ba70db4d..89574cdfba7 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -2500,7 +2500,7 @@ endif
# ARM linux, GNU eabi
ifeq ($(SELECTED_PAIRS),PAIRS_NONE)
-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))),)
SELECTED_PAIRS=arm-linux-gnueabi
--
2.50.1

796
cross/gcc-ppc64le/APKBUILD Normal file
View file

@ -0,0 +1,796 @@
# Automatically generated aport, do not edit!
# Generator: pmbootstrap aportgen gcc-ppc64le
# Based on: main/gcc (from Alpine)
CTARGET_ARCH=ppc64le
CTARGET="$(arch_to_hostspec ${CTARGET_ARCH})"
LANG_D=false
LANG_OBJC=false
LANG_JAVA=false
LANG_GO=false
LANG_FORTRAN=false
LANG_ADA=false
options="!strip"
# abuild doesn't try to tries to install "build-base-$CTARGET_ARCH"
# when this variable matches "no*"
BOOTSTRAP="nobuildbase"
# abuild will only cross compile when this variable is set, but it
# needs to find a valid package database in there for dependency
# resolving, so we set it to /.
CBUILDROOT="/"
_cross_configure="--disable-bootstrap --with-sysroot=/usr/$CTARGET"
pkgname=gcc-ppc64le
pkgver=15.2.0
# i.e. 13.2.1, must match gcc/BASE-VER
_pkgbase="${pkgver%%_git*}"
# date component from snapshots
_pkgsnap="${pkgver##*_git}"
[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2"
[ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross=""
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
pkgname=gcc-ppc64le
pkgrel=0
pkgdesc="Stage2 cross-compiler for ppc64le"
url="https://gcc.gnu.org"
arch="x86_64"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
_gccrel=$pkgver-r$pkgrel
depends="binutils-ppc64le mpc1 so:libc.musl-x86_64.so.1 so:libgcc_s.so.1 so:libgmp.so.10 so:libisl.so.23 so:libmpc.so.3 so:libmpfr.so.6 so:libstdc++.so.6 so:libz.so.1"
makedepends_build="gcc g++ bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev"
makedepends_host="linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev musl-dev-ppc64le binutils-ppc64le"
subpackages="g++-ppc64le:gpp libstdc++-dev-ppc64le:libcxx_dev"
[ "$CHOST" = "$CTARGET" ] && subpackages="gcc-gdb gcc-doc"
replaces="libstdc++ binutils"
options="!strip !tracedeps"
: "${LANG_CXX:=true}"
: "${LANG_D:=true}"
: "${LANG_OBJC:=true}"
: "${LANG_GO:=true}"
: "${LANG_FORTRAN:=true}"
: "${LANG_ADA:=true}"
: "${LANG_JIT:=true}"
_libgomp=true
_libgcc=false
_libatomic=true
_libitm=true
if [ "$CHOST" != "$CTARGET" ]; then
if [ "$BOOTSTRAP" = nolibc ]; then
LANG_CXX=false
LANG_D=false
LANG_ADA=false
_libgcc=false
_builddir="$srcdir/build-cross-pass2"
else
_builddir="$srcdir/build-cross-final"
fi
LANG_OBJC=false
LANG_GO=false
LANG_FORTRAN=false
LANG_JIT=false
_libgomp=false
_libatomic=false
_libitm=false
# format-sec: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431
CPPFLAGS="${CPPFLAGS/-Werror=format-security/}"
# reset target flags (should be set in crosscreate abuild)
# fixup flags. seems gcc treats CPPFLAGS as global without
# _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS.
export CFLAGS="$CPPFLAGS -g0 ${CFLAGS/-Werror=format-security/}"
export CXXFLAGS="$CPPFLAGS -g0 ${CXXFLAGS/-Werror=format-security/}"
unset CPPFLAGS
export CFLAGS_FOR_TARGET=" "
export CXXFLAGS_FOR_TARGET=" "
export LDFLAGS_FOR_TARGET=" "
STRIP_FOR_TARGET="$CTARGET-strip"
elif [ "$CBUILD" != "$CHOST" ]; then
# format-sec: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431
CPPFLAGS="${CPPFLAGS/-Werror=format-security/}"
# fixup flags. seems gcc treats CPPFLAGS as global without
# _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS.
export CFLAGS="$CPPFLAGS -g0 ${CFLAGS/-Werror=format-security/}"
export CXXFLAGS="$CPPFLAGS -g0 ${CXXFLAGS/-Werror=format-security/}"
unset CPPFLAGS
# reset flags and cc for build
export CC_FOR_BUILD="gcc"
export CXX_FOR_BUILD="g++"
export CFLAGS_FOR_BUILD=" "
export CXXFLAGS_FOR_BUILD=" "
export LDFLAGS_FOR_BUILD=" "
export CFLAGS_FOR_TARGET=" "
export CXXFLAGS_FOR_TARGET=" "
export LDFLAGS_FOR_TARGET=" "
# Languages that do not need bootstrapping
LANG_OBJC=false
LANG_GO=false
LANG_FORTRAN=false
LANG_JIT=false
STRIP_FOR_TARGET=${CROSS_COMPILE}strip
_builddir="$srcdir/build-cross-native"
else
STRIP_FOR_TARGET=${CROSS_COMPILE}strip
_builddir="$srcdir/build"
# format-sec: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431
CPPFLAGS="${CPPFLAGS/-Werror=format-security/}"
# pass -g0 by default to bypass -g, since we don't do debug
# if -dbg added, the -g is appended and overrides this
export CFLAGS="$CPPFLAGS -g0 ${CFLAGS/-Werror=format-security/} -O2"
export CXXFLAGS="$CPPFLAGS -g0 ${CXXFLAGS/-Werror=format-security/} -O2"
unset CPPFLAGS
# https://gcc.gnu.org/install/build.html
export CFLAGS_FOR_TARGET="$CFLAGS"
export CXXFLAGS_FOR_TARGET="$CXXFLAGS"
export LDFLAGS_FOR_TARGET="$LDFLAGS"
export BOOT_CFLAGS="$CFLAGS"
export BOOT_LDFLAGS="$LDFLAGS"
fi
case "$CTARGET_ARCH" in
# GDC hasn't been ported to PowerPC (LIBDRUNTIME_ONLY=yes)
# See libphobos/configure.tgt in GCC sources for supported targets
# riscv fails with: error: static assert "unimplemented"
ppc*|riscv64) LANG_D=false ;;
# GDC does currently not work on 32-bit musl architectures.
# This is a known upstream issue.
# See: https://github.com/dlang/druntime/pull/3383
armhf|armv7|x86) LANG_D=false ;;
esac
# libitm has TEXTRELs in ARM build, so disable for now
case "$CTARGET_ARCH" in
arm*) _libitm=false ;;
mips*) _libitm=false ;;
riscv64) _libitm=false ;;
loongarch64) _libitm=false ;;
esac
# Internal libffi fails to build on MIPS at the moment, need to
# investigate further. We disable LANG_GO on mips64 as it requires
# the internal libffi.
case "$CTARGET_ARCH" in
mips*) LANG_GO=false ;;
loongarch64) LANG_GO=false ;;
esac
# Fortran uses libquadmath if toolchain has __float128
# currently on x86, x86_64 and ia64
_libquadmath=$LANG_FORTRAN
case "$CTARGET_ARCH" in
x86 | x86_64 | ppc64le) ;;
*) _libquadmath=false ;;
esac
# libatomic is a dependency for openvswitch
$_libatomic && subpackages="$subpackages libatomic::$CTARGET_ARCH"
$_libgcc && subpackages="$subpackages libgcc::$CTARGET_ARCH"
$_libquadmath && subpackages="$subpackages libquadmath::$CTARGET_ARCH"
if $_libgomp; then
depends="$depends libgomp=$_gccrel"
subpackages="$subpackages libgomp::$CTARGET_ARCH"
fi
_languages=c
if $LANG_CXX; then
_languages="$_languages,c++"
fi
if $LANG_D; then
subpackages="$subpackages gcc-gdc$_target:gdc"
_languages="$_languages,d"
makedepends_build="$makedepends_build libucontext-dev"
if [ "$CBUILD" = "$CTARGET" ]; then
makedepends_build="$makedepends_build gcc-gdc-bootstrap"
subpackages="$subpackages libgphobos::$CTARGET_ARCH"
else
# shared libgphobos is for D programs to link against, so
# skip building that while cross-compiling the GDC compiler
makedepends_build="$makedepends_build gcc-gdc gcc-gdc$_cross"
fi
fi
if $LANG_OBJC; then
subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc"
_languages="$_languages,objc"
fi
if $LANG_GO; then
subpackages="$subpackages libgo::$CTARGET_ARCH gcc-go$_target:go"
_languages="$_languages,go"
fi
if $LANG_FORTRAN; then
subpackages="$subpackages libgfortran::$CTARGET_ARCH gfortran$_target:gfortran"
_languages="$_languages,fortran"
fi
if $LANG_ADA; then
subpackages="$subpackages gcc-gnat$_target:gnat libgnat::$CTARGET_ARCH"
_languages="$_languages,ada"
if [ "$CBUILD" = "$CTARGET" ]; then
makedepends_build="$makedepends_build gcc-gnat-bootstrap"
subpackages="$subpackages libgnat-static:libgnatstatic:$CTARGET_ARCH"
else
makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross"
fi
fi
if $LANG_JIT; then
subpackages="$subpackages libgccjit:jit libgccjit-dev:jitdev"
fi
# when using upstream releases, use this URI template
# https://gcc.gnu.org/pub/gcc/releases/gcc-$_pkgbase/gcc-$_pkgbase.tar.xz
#
# right now, we are using a git snapshot. snapshots are taken from gcc.gnu.org/pub/gcc/snapshots.
# However, since they are periodically deleted from the GCC mirrors the utilized snapshots are
# mirrored on dev.alpinelinux.org. Please ensure that the snapshot Git commit (as stated in the
# README) matches the base commit on the version-specific branch in the Git repository below.
#
# PLEASE submit all patches to gcc to https://gitlab.alpinelinux.org/kaniini/alpine-gcc-patches,
# so that they can be properly tracked and easily rebased if needed.
#source="https://dev.alpinelinux.org/archive/gcc/${_pkgbase%%.*}-$_pkgsnap/gcc-${_pkgbase%%.*}-$_pkgsnap.tar.xz"
#source="https://gcc.gnu.org/pub/gcc/snapshots/${_pkgbase%%.*}-$_pkgsnap/gcc-${_pkgbase%%.*}-$_pkgsnap.tar.xz"
source="https://gcc.gnu.org/pub/gcc/releases/gcc-$_pkgbase/gcc-$_pkgbase.tar.xz
0001-posix_memalign.patch
0002-gcc-poison-system-directories.patch
0003-specs-turn-on-Wl-z-now-by-default.patch
0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch
0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch
0006-Enable-Wformat-and-Wformat-security-by-default.patch
0007-Enable-Wtrampolines-by-default.patch
0008-gcc-disable-SSP-on-ffreestanding-nostdlib-and-nodefa.patch
0009-gcc-params-set-default-ssp-buffer-size-to-4.patch
0010-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch
0011-Don-t-declare-asprintf-if-defined-as-a-macro.patch
0012-libiberty-copy-PIC-objects-during-build-process.patch
0013-libgcc_s.patch
0014-nopie.patch
0015-ada-fix-shared-linking.patch
0016-build-fix-CXXFLAGS_FOR_BUILD-passing.patch
0017-add-fortify-headers-paths.patch
0018-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
0019-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch
0020-aarch64-disable-multilib-support.patch
0021-s390x-disable-multilib-support.patch
0022-ppc64-le-disable-multilib-support.patch
0023-x86_64-disable-multilib-support.patch
0024-riscv-disable-multilib-support.patch
0025-always-build-libgcc_eh.a.patch
0026-ada-libgnarl-remove-use-of-glibc-specific-pthread_rw.patch
0027-ada-libgnarl-use-posix_openpt-instead-of-glibc-speci.patch
0028-ada-libgnarl-adaint-fix-sched.h-inclusion-for-musl.patch
0029-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch
0030-configure-fix-detection-of-atomic-builtins-in-libato.patch
0031-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch
0032-gdc-unconditionally-link-libgphobos-against-libucont.patch
0033-druntime-link-against-libucontext-on-all-platforms.patch
0034-libgnat-time_t-is-always-64-bit-on-musl-libc.patch
0035-libphobos-do-not-use-LFS64-symbols.patch
0036-libgo-fix-lfs64-use.patch
0037-loongarch-disable-multilib-support.patch
0038-static-PIE-ensure-static-reaches-the-linker.patch
0039-except-Don-t-use-the-cached-value-of-the-gcc_except_.patch
0040-ada-libgnat-use-stub-symbolic-module-name-functions.patch
0041-ada-libgnat-recognize-linux-musleabi-and-linux-muslg.patch
"
# secfixes:
# 13.2.1_git20231014-r0:
# - CVE-2023-4039
# we build out-of-tree
#builddir="$srcdir"/gcc-${_pkgbase%%.*}-$_pkgsnap
builddir="$srcdir"/gcc-$_pkgbase
_gcclibdir="usr/lib/gcc/$CTARGET/$_pkgbase"
_gcclibexec="usr/libexec/gcc/$CTARGET/$_pkgbase"
prepare() {
default_prepare
echo $_pkgbase > gcc/BASE-VER
}
build() {
local _arch_configure=
local _bootstrap_configure=
local _jit_configure=
local _sanitizer_configure=
case "$CTARGET" in
aarch64-*-*-*) _arch_configure="--with-arch=armv8-a --with-abi=lp64";;
armv5-*-*-*eabi) _arch_configure="--with-arch=armv5te --with-tune=arm926ej-s --with-float=soft --with-abi=aapcs-linux";;
armv6-*-*-*eabihf) _arch_configure="--with-arch=armv6kz --with-tune=arm1176jzf-s --with-fpu=vfpv2 --with-float=hard --with-abi=aapcs-linux";;
armv7-*-*-*eabihf) _arch_configure="--with-arch=armv7-a --with-tune=generic-armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-abi=aapcs-linux --with-mode=thumb";;
mips-*-*-*) _arch_configure="--with-arch=mips32 --with-mips-plt --with-float=soft --with-abi=32";;
mips64-*-*-*) _arch_configure="--with-arch=mips3 --with-tune=mips64 --with-mips-plt --with-float=soft --with-abi=64";;
mips64el-*-*-*) _arch_configure="--with-arch=mips3 --with-tune=mips64 --with-mips-plt --with-float=soft --with-abi=64";;
mipsel-*-*-*) _arch_configure="--with-arch=mips32 --with-mips-plt --with-float=soft --with-abi=32";;
powerpc-*-*-*) _arch_configure="--enable-secureplt --enable-decimal-float=no";;
powerpc64*-*-*-*) _arch_configure="--with-abi=elfv2 --enable-secureplt --enable-decimal-float=no --enable-targets=powerpcle-linux";;
i486-*-*-*) _arch_configure="--with-arch=i486 --with-tune=generic --enable-cld";;
i586-*-*-*) _arch_configure="--with-arch=pentium-m --with-fpmath=sse --with-tune=generic --enable-cld";;
s390x-*-*-*) _arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";;
riscv64-*-*-*) _arch_configure="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic";;
loongarch64-*-*-*) _arch_configure="--with-arch=la64v1.0 --with-abi=lp64d";;
esac
case "$CTARGET_ARCH" in
*) _sanitizer_configure="--disable-libsanitizer" ;;
esac
case "$CTARGET_ARCH" in
mips*) _hash_style_configure="--with-linker-hash-style=sysv" ;;
*) _hash_style_configure="--with-linker-hash-style=gnu" ;;
esac
export libat_cv_have_ifunc=no
case "$BOOTSTRAP" in
nolibc) _bootstrap_configure="--with-newlib --disable-shared --enable-threads=no" ;;
*)
# cross-bootstrap GDC with a static libphobos: due to GCC's
# ./configure not having a --disable-shared=libphobos option,
# we have to use --enable-shared with everything else instead.
if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then
_bootstrap_configure="--enable-shared=libgcc,libstdc++,libffi,zlib,boehm-gc,ada,libada,libgo,libobjc,libatomic,libgomp,libitm,libgfortran,libquadmath"
else
_bootstrap_configure="--enable-shared"
fi
_bootstrap_configure="$_bootstrap_configure --enable-threads --enable-tls"
;;
esac
$_libgomp || _bootstrap_configure="$_bootstrap_configure --disable-libgomp"
$_libatomic || _bootstrap_configure="$_bootstrap_configure --disable-libatomic"
$_libitm || _bootstrap_configure="$_bootstrap_configure --disable-libitm"
$_libquadmath || _arch_configure="$_arch_configure --disable-libquadmath"
msg "Building the following:"
echo ""
echo " CBUILD=$CBUILD"
echo " CHOST=$CHOST"
echo " CTARGET=$CTARGET"
echo " CTARGET_ARCH=$CTARGET_ARCH"
echo " languages=$_languages"
echo " arch_configure=$_arch_configure"
echo " cross_configure=$_cross_configure"
echo " bootstrap_configure=$_bootstrap_configure"
echo " hash_style_configure=$_hash_style_configure"
echo ""
local version="Alpine $pkgver"
local gccconfiguration="
--prefix=/usr
--mandir=/usr/share/man
--infodir=/usr/share/info
--build=$CBUILD
--host=$CHOST
--target=$CTARGET
--enable-checking=release
--disable-cet
--disable-fixed-point
--disable-libstdcxx-pch
--disable-multilib
--disable-nls
--disable-werror
--disable-symvers
--enable-__cxa_atexit
--enable-default-pie
--enable-default-ssp
--enable-languages=$_languages
--enable-link-serialization=2
--enable-linker-build-id
$_arch_configure
--disable-libssp
$_sanitizer_configure
$_cross_configure
$_bootstrap_configure
--with-bugurl=https://gitlab.alpinelinux.org/alpine/aports/-/issues
--with-system-zlib
$_hash_style_configure
"
mkdir -p "$_builddir"
cd "$_builddir"
"$builddir"/configure $gccconfiguration \
--with-pkgversion="$version"
msg "building gcc"
if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then
# cross-compiling libphobos with parallel make fails
make all-target-libphobos
fi
make
# we build gccjit separate to not build all of gcc with --enable-host-shared
# as doing so slows it down a few %, so for some quick if's here we gain
# free performance
if $LANG_JIT; then
mkdir -p "$_builddir"/libgccjit-build
cd "$_builddir"/libgccjit-build
"$builddir"/configure $gccconfiguration \
--disable-bootstrap \
--enable-host-shared \
--enable-languages=jit \
--with-pkgversion="$version"
msg "building libgccjit"
make all-gcc
fi
}
package() {
cd "$_builddir"
make -j1 DESTDIR="$pkgdir" install
[ "$CHOST" = "$CTARGET" ] && ln -s gcc "$pkgdir"/usr/bin/cc
ln -s ${CTARGET}-gcc "$pkgdir"/usr/bin/${CTARGET}-cc
# symlink to vendor-less target triple for
# supporting clang --target's fallback match
# ref: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16828
ln -s "$CTARGET" "$pkgdir/usr/lib/gcc/${CTARGET%%-*}-${CTARGET#*-*-}"
if $LANG_JIT; then
make -C "$_builddir"/libgccjit-build/gcc DESTDIR="$pkgdir" jit.install-common
fi
# we dont support gcj -static
# and saving 35MB is not bad.
find "$pkgdir" \( -name libgtkpeer.a \
-o -name libgjsmalsa.a \
-o -name libgij.a \) \
-delete
# strip debug info from some static libs
find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \
-o -name libgphobos.a -o -name libgdruntime.a \
-o -name libgcc.a -o -name libgcov.a -o -name libquadmath.a \
-o -name libitm.a -o -name libgo.a -o -name libcaf\*.a \
-o -name libatomic.a -o -name libasan.a -o -name libtsan.a \) \
-a -type f \
-exec $STRIP_FOR_TARGET -g {} +
if $_libgomp; then
mv "$pkgdir"/usr/lib/libgomp.spec "$pkgdir"/$_gcclibdir
fi
if $_libitm; then
mv "$pkgdir"/usr/lib/libitm.spec "$pkgdir"/$_gcclibdir
fi
# remove ffi
rm -f "$pkgdir"/usr/lib/libffi* "$pkgdir"/usr/share/man/man3/ffi*
find "$pkgdir" -name 'ffi*.h' -delete
local gdblib=${_target:+$CTARGET/}lib
if [ -d "$pkgdir"/usr/$gdblib/ ]; then
for i in $(find "$pkgdir"/usr/$gdblib/ -type f -maxdepth 1 -name "*-gdb.py"); do
mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib
mv "$i" "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib/
done
fi
# move ada runtime libs
if $LANG_ADA; then
local libgnat_static=
[ "$CHOST" = "$CTARGET" ] && libgnat_static="libgna*.a"
for i in $(find "$pkgdir"/$_gcclibdir/adalib/ -type f -maxdepth 1 \( -name "libgna*.so" -o -name "$libgnat_static" \) ); do
mv "$i" "$pkgdir"/usr/lib/
ln -s ../../../../${i##*/} $i
done
fi
if [ "$CHOST" != "$CTARGET" ]; then
# cross-gcc: remove any files that would conflict with the
# native gcc package
rm -rf "$pkgdir"/usr/include "${pkgdir:?}"/usr/share
# libcc1 does not depend on target, don't ship it
rm -rf "$pkgdir"/usr/lib/libcc1.so*
# fixup gcc library symlinks to be linker scripts so
# linker finds the libs from relocated sysroot
for so in "$pkgdir"/usr/"$CTARGET"/lib/*.so; do
if [ -h "$so" ]; then
local _real=$(basename "$(readlink "$so")")
rm -f "$so"
echo "GROUP ($_real)" > "$so"
fi
done
else
# add c89/c99 wrapper scripts
cat >"$pkgdir"/usr/bin/c89 <<'EOF'
#!/bin/sh
_flavor="-std=c89"
for opt; do
case "$opt" in
-ansi|-std=c89|-std=iso9899:1990) _flavor="";;
-std=*) echo "$(basename $0) called with non ANSI/ISO C option $opt" >&2
exit 1;;
esac
done
exec gcc $_flavor ${1+"$@"}
EOF
cat >"$pkgdir"/usr/bin/c99 <<'EOF'
#!/bin/sh
_flavor="-std=c99"
for opt; do
case "$opt" in
-std=c99|-std=iso9899:1999) _flavor="";;
-std=*) echo "$(basename $0) called with non ISO C99 option $opt" >&2
exit 1;;
esac
done
exec gcc $_flavor ${1+"$@"}
EOF
chmod 755 "$pkgdir"/usr/bin/c?9
# install lto plugin so regular binutils may use it
mkdir -p "$pkgdir"/usr/lib/bfd-plugins
ln -s /$_gcclibexec/liblto_plugin.so "$pkgdir/usr/lib/bfd-plugins/"
fi
}
libatomic() {
pkgdesc="GCC Atomic library"
depends=
replaces="gcc"
amove usr/lib/libatomic.so.*
}
libcxx() {
pkgdesc="GNU C++ standard runtime library"
depends=
if [ "$CHOST" = "$CTARGET" ]; then
# verify that we are using clock_gettime rather than doing direct syscalls
# so we dont break 32 bit arches due to time64.
nm -D "$pkgdir"/usr/lib/libstdc++.so.* | grep clock_gettime
fi
amove usr/lib/libstdc++.so.*
}
libcxx_dev() {
pkgdesc="GNU C++ standard runtime library (development files)"
depends=
replaces="g++"
amove usr/${_target:+$CTARGET/}lib/libstdc++.a \
usr/${_target:+$CTARGET/}lib/libstdc++exp.a \
usr/${_target:+$CTARGET/}lib/libstdc++.so \
usr/${_target:+$CTARGET/}lib/libstdc++fs.a \
usr/${_target:+$CTARGET/}lib/libsupc++.a \
usr/${_target:+$CTARGET/}include/c++
}
gpp() {
pkgdesc="GNU C++ standard library and compiler"
depends="libstdc++-dev$_target=$_gccrel gcc$_target=$_gccrel musl-dev"
[ "$CHOST" = "$CTARGET" ] && depends="$depends libstdc++=$_gccrel"
depends="$depends so:libc.musl-x86_64.so.1 so:libgmp.so.10 so:libisl.so.23 so:libmpc.so.3 so:libmpfr.so.6 so:libz.so.1"
amove $_gcclibexec/cc1plus
amove usr/bin/*++
}
jit() {
pkgdesc="GCC JIT Library"
depends=
amove usr/lib/libgccjit.so*
}
jitdev() {
pkgdesc="GCC JIT Library (development files)"
depends="libgccjit"
amove usr/include/libgccjit*.h
}
libobjc() {
pkgdesc="GNU Objective-C runtime"
replaces="objc"
depends=
amove usr/lib/libobjc.so.*
}
objc() {
pkgdesc="GNU Objective-C"
replaces="gcc"
depends="musl-dev gcc=$_gccrel libobjc=$_gccrel"
amove $_gcclibexec/cc1obj
amove $_gcclibdir/include/objc
amove usr/lib/libobjc.so
amove usr/lib/libobjc.a
}
libgcc() {
pkgdesc="GNU C compiler runtime libraries"
depends=
amove usr/lib/libgcc_s.so.*
}
libgomp() {
pkgdesc="GCC shared-memory parallel programming API library"
depends=
replaces="gcc"
amove usr/lib/libgomp.so.*
}
libgphobos() {
pkgdesc="D programming language standard library for GCC"
depends=
amove usr/lib/libgdruntime.so.*
amove usr/lib/libgphobos.so.*
}
gdc() {
pkgdesc="GCC-based D language compiler"
depends="gcc$_target=$_gccrel musl-dev libucontext-dev"
[ "$CBUILD" = "$CTARGET" ] && depends="$depends libgphobos=$_gccrel"
[ "$CHOST" = "$CTARGET" ] && provides="gcc-gdc-bootstrap=$_gccrel"
# Copy: The installed '.d' files, the static lib, the binary itself
# The shared libs are part of 'libgphobos' so one can run program
# without installing the compiler
amove $_gcclibexec/d21
amove $_gcclibdir/include/d
if [ "$CBUILD" = "$CTARGET" ]; then
amove usr/lib/libgdruntime.so
amove usr/lib/libgphobos.so
fi
amove usr/${_target:+$CTARGET/}lib/libgdruntime.a
amove usr/${_target:+$CTARGET/}lib/libgphobos.a
amove usr/${_target:+$CTARGET/}lib/libgphobos.spec
amove usr/bin/*gdc
}
libgo() {
pkgdesc="Go runtime library for GCC"
depends=
amove usr/lib/libgo.so.*
}
go() {
pkgdesc="GCC Go frontend (intended for bootstrapping community/go)"
depends="gcc=$_gccrel libgo=$_gccrel !go"
amove usr/lib/go
amove usr/bin/*go
amove usr/bin/*gofmt
amove $_gcclibexec/go1
amove $_gcclibexec/cgo
amove $_gcclibexec/buildid
amove $_gcclibexec/test2json
amove $_gcclibexec/vet
amove usr/lib/libgo.a
amove usr/lib/libgo.so
amove usr/lib/libgobegin.a
amove usr/lib/libgolibbegin.a
}
libgfortran() {
pkgdesc="Fortran runtime library for GCC"
depends=
amove usr/lib/libgfortran.so.*
}
libquadmath() {
replaces="gcc"
pkgdesc="128-bit math library for GCC"
depends=
amove usr/lib/libquadmath.so.*
}
gfortran() {
pkgdesc="GNU Fortran Compiler"
depends="gcc=$_gccrel libgfortran=$_gccrel"
$_libquadmath && depends="$depends libquadmath=$_gccrel"
replaces="gcc"
amove usr/bin/*gfortran
amove usr/lib/libgfortran.a
amove usr/lib/libgfortran.so
if $_libquadmath; then
amove usr/lib/libquadmath.a
amove usr/lib/libquadmath.so
fi
amove $_gcclibdir/finclude
amove $_gcclibexec/f951
mv -v "$pkgdir"/usr/lib/libgfortran.spec "$subpkgdir"/$_gcclibdir/
}
libgnat() {
pkgdesc="GNU Ada runtime shared libraries"
depends=
amove usr/lib/libgna*.so
}
libgnatstatic() {
pkgdesc="GNU Ada static libraries"
depends=
amove usr/lib/libgna*.a
}
gnat() {
pkgdesc="Ada support for GCC"
depends="gcc=$_gccrel"
provides="$pkgname-gnat-bootstrap=$_gccrel"
[ "$CHOST" = "$CTARGET" ] && depends="$depends libgnat=$_gccrel"
amove $_gcclibexec/*gnat*
amove $_gcclibdir/*ada*
amove usr/bin/*gnat*
}
gdb() {
pkgdesc="$pkgdesc (gdb printers)"
install_if="$pkgname=$pkgver-r$pkgrel gdb"
amove \
usr/share/gdb/python/ \
usr/share/gcc-*/python/
}
sha512sums="
89047a2e07bd9da265b507b516ed3635adb17491c7f4f67cf090f0bd5b3fc7f2ee6e4cc4008beef7ca884b6b71dffe2bb652b21f01a702e17b468cca2d10b2de gcc-15.2.0.tar.xz
fd5cebc5deb1d588583424acbc1b5a6d8d6f5b1bfa9f4bdbc082cfd406723f423d87011ee30e04ed18128a7ed8021cbfc9262becff5419125dc1afb6f407defa 0001-posix_memalign.patch
6634004cb9feea9ee0d063d6b6984d7db3b10c692b6139bb99169a4f2d74f0e10b5ca0ab31ce346ffef34b8eb9c3f536aa4d94bce1b27f8e0b8a9fc5cc4b7057 0002-gcc-poison-system-directories.patch
37e089791dbcbad73af866b662cda611dc0970d93e28251c7a9aa898db3b96446654e8b778d7866eb8550ba7f4a57cf22e8514d562bfed0c66613e65550d9c85 0003-specs-turn-on-Wl-z-now-by-default.patch
d4d5bfeb20a9fac968f37497d86d7eff4a9ac863e015dadbffae24c08236f5efde69b615d95191e2546672ce2d4b30d3627528c64a83fc64b715e8fa6fd4c372 0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch
4806687c806154dd3d5423ea9ef1203db344dfb8fd21f3eb3543d9f05f4dc01aacc4f012f45db8e890eeddc7b1c75ec06a6b29e29a1ef7b9ec6f853d1854cfd0 0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch
6b225df0dd76339b06d5efbe07edd6648391a7b9415a219041189c35c084ceffe8fb96b2660d60d62099e7afdfeb8e053622a2b6660d2e8a13adb924f4bc8c8a 0006-Enable-Wformat-and-Wformat-security-by-default.patch
e419b7f20a74384bfb1ac792e3625f9bfe69f8031c2c0beb23f4015df9d48a6c6f107d89bea3c20fa56309b022637863c13e90c1565d027eb47c08154389b7a0 0007-Enable-Wtrampolines-by-default.patch
e6307eec09196900bcd2c0154a62d6694576b4da48a1cf901750b97b4603cd694c4daee2476c33bce09f10bee92a72749face835eb18fbf2c2a50aa1dd251572 0008-gcc-disable-SSP-on-ffreestanding-nostdlib-and-nodefa.patch
969797f99602c119e1632f0c5be02a566be5fb4c7e59affefb5eb6084a06b97120d99d5ee63fef0dab6c0278c7cecf1d8caa53521cc5b6622de2aaa7deabf86e 0009-gcc-params-set-default-ssp-buffer-size-to-4.patch
c15f062790367c9e786a4933deec33931438680176ec752b172c2a0504463a23d588ead4350d32e474603750ceb130ba0ccadfcde601bcf8e2eabca5af8322d0 0010-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch
03a1012f1022cd68cf08440428e7d6cbf65ea2184e4a088a55976f34af627d80f42f15f713841ec9cbfc4afa39117d4fc384c3f27a4f9ad0ff3947bd45b71c4a 0011-Don-t-declare-asprintf-if-defined-as-a-macro.patch
8f098de9fcf4bbece0923dc4a2acfc67cf751c1d5c007535c5d88b8637a4482c1a42d5721a2760127498e327f6983bbc865a592a8e0db9ef7efc0e36b6d4102f 0012-libiberty-copy-PIC-objects-during-build-process.patch
bbe2b561b5288ca724af37353e17b413df8bf247bce724391e75373aee5cdcdb85e6489d51622c11f4041ed8f317278cf687aee14dfc8756398f03f1a796feb9 0013-libgcc_s.patch
ae34ca2bc5a53ed1c832651e3f6425ca29b5873f1e112b45613277fb9611693be41986d5879593f09149777e3e57d04ba17b142c43eaa990375d31e4e0b4adde 0014-nopie.patch
2c91a1eadf7236efff42eb53037862a342807596e37c6cc3c270d25c2d89078bf8db68bb2e93e57a8ad39b3af825e33db72e2f48a6311951fff53776933bc48c 0015-ada-fix-shared-linking.patch
1366d696a952ed35e5e56ab5bd1eba67e58a8ce752c0ef7e7fe4ad3eef44f25ce6016342d11add9548f9e719dc9ee0772064dda68784257a1a3234ae5957f3fb 0016-build-fix-CXXFLAGS_FOR_BUILD-passing.patch
af739373285e89a4ab0000042b537ff7197b0b366019b56991008c43f3d2b76709d472841cda40e9fb61e6f0dacc0fe8c6b888abb31f393ec1a87acc1c0585b3 0017-add-fortify-headers-paths.patch
c18f3eef4d7d6fcbfa64570edb71157a62dad1f3d7276f10fe3424e49caa33f57a0a5952f03189199472802a2dd966e4832789685a94911fe9a86bb1fd6c1d50 0018-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
341d39a40ffd896db152863c717798c6885bdde44c9ac645c5d099c2364cbd8f6f526f97cc98302c420682cb5d6d88bbe28d838c7141456f2ba5581f3edfd64f 0019-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch
e603652f341909820789a2cec173b8e547ee607b040863f1745b998b8a69d51cb412a4ac55d2c9e3c5192cc298f6288f9dd48fa06fe53ba8f6b1cabbe61c997a 0020-aarch64-disable-multilib-support.patch
26819f3c3a5844c96cee89fc9766a4f8153e7bb22f6296c6c9fd6a13d45648e3f6c7059397ad7e5be66f55addc21054614b38f480b52a7c9a967cf389735644a 0021-s390x-disable-multilib-support.patch
8e6e6ed84c8cb39ecc35ad0986a91168fedbae2426c8ec1c83dec85a293777e0ec29eac13130193b1bdc2d98b6ffa180abf574dad70740d4720b4bfdab992ab8 0022-ppc64-le-disable-multilib-support.patch
264eaa54a76ec5a12294d91ad2f995eddac9210a569ba85aef27176cb015354aa427840bb22f1e3ba2f7761f6f85cc98ddb3b00584b295c6a10a9770c59a2607 0023-x86_64-disable-multilib-support.patch
47a1a407298b6c259d7faff774f26e4843c9d3764362d74230e7d3f77c46ea8bb51211e09a66bb51c04a9f276ea5b07570fb52312fdb1d354c72a0343bc40c57 0024-riscv-disable-multilib-support.patch
b86fcf40e75861bdffb00069d3a0c9cec3fe8042d49d6ce2beae48ffeadccc576b8ab36e5a85421db5cffeb080a75f3a66dbcbb825d7f4462d40ec621964efe3 0025-always-build-libgcc_eh.a.patch
1425543ce064bfd8e33d7e6e07f45cc16d94f156adcfe190c842722652d5ea0c9ba60f6a3e1b444bb0e5bc906ec4f9ca54720b306f274b441600b79bff47dc57 0026-ada-libgnarl-remove-use-of-glibc-specific-pthread_rw.patch
b8851d0e7fc66201e323007f7c1d702ea8a0d0405aa5945621128ebfb93afd967ec8b3ab6fd4ea779ec10dca2a32e1797f7a2622124ccf8ace2a7596f66ff0bf 0027-ada-libgnarl-use-posix_openpt-instead-of-glibc-speci.patch
12b09a171d61406a2bfa10bb25398cee8c92676b12506afe7aace7028e94cbf8d7df25f62ff7af07e8ed471c6edd3ab7811fa51dfaf3a221a6b367858b1f032c 0028-ada-libgnarl-adaint-fix-sched.h-inclusion-for-musl.patch
15bed06ee74a36e9f21f4b29d7bce9c4188769abb6391560e13ea6b165da51f5ae908e141de7510d3d7eec6b998d0fc53de1042fdb7bd056efa703d230a683b4 0029-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch
4c5501256669fd33527a5394eaa4b84451ee341a943dd24a179b661d3c53ef70e87ed5d5f3e76c6c3f9cb79cb5d120ea40101278a7b9d04a55d9405e4cbf9796 0030-configure-fix-detection-of-atomic-builtins-in-libato.patch
eecc77e2a9cf956fd752693ad7f8ff8253a7bb557e00564bb488bbc1deac895e63104cc1182a0bdd700e440763f4a72e29876f560e13e4f5e6de2a1d9438c2f6 0031-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch
2b09f90d9cb417170060c8ce198bd4aa2e4ef163286c8f24f6e6c5a673ae80f5a883b078b1a5dd5fa71bc1502e08c886687072694da039eb82baa1ea1948ac2c 0032-gdc-unconditionally-link-libgphobos-against-libucont.patch
99c74242b6d79e6a814f1199b9fb0b56c6a43eb93e5d1a79b674cea750bb025363cdd1505d05cd2195a43c918831fa586c427556ee5bc826aa79cd82e7ee1c24 0033-druntime-link-against-libucontext-on-all-platforms.patch
4f8f7876bf8647cda47cbd2b145ff31efe2a7ac21c012c4134174f93482aad1fbab2592c66aacc3b05fccd1a694ff97511b794139db4aac719e243c114373240 0034-libgnat-time_t-is-always-64-bit-on-musl-libc.patch
0069da1d8cb9adb9bab081a34fec680a9ebb1236e606a2497e4565e99bef434518a0f06474a9a1fdfa70811ed3da5d35ca95d267268328f2764bf41c50e924de 0035-libphobos-do-not-use-LFS64-symbols.patch
1cbe85b63ef13bdf2804bfd3173998a6e86752d8ffc09d4cc75a9ba80b98aec5a04efa732bce97a2f50a90c84b92c442ca8f6639841fe7d6618f928ea65916a6 0036-libgo-fix-lfs64-use.patch
98fcd5b893a1646edab961a5d00246151c47b449f8eca99c51f4026ffdb53f60b5b9f6426437c0a6411342da10db8983e20337a29cd46ed22b70e0478573ea30 0037-loongarch-disable-multilib-support.patch
1ad48e39dab351b7bb3e17d9b4b8b78e7de7c736e212638c9d6874b1dde0360dcfc85586c39f515fbd2a6d9910fedc4f0c6ad7ff652b10a5c288c47173671ec7 0038-static-PIE-ensure-static-reaches-the-linker.patch
9f4c3fa0d17cfcd72626bdbaf51992ff3018f878d673ab19b9056047ee2630b581e5a5a4d4857444f08ba9bcdb0fc94f90dcda6180816e39690d1652843f0d8a 0039-except-Don-t-use-the-cached-value-of-the-gcc_except_.patch
d166475e340c91bbb24cf257240aab37129b04f2609e5ce323b530ab83853a4c34c525e0072c15732717f1681db07e6b3b0a4d268720c31f460435ccf4c99b7f 0040-ada-libgnat-use-stub-symbolic-module-name-functions.patch
c717764ef52c0226a23cbf434654cdefa6cbf38ec625648575d9143c5513b16d8914c25015db743033b8a46ac5b2c33ab75e1b67076128d67bb1319e5a83dd85 0041-ada-libgnat-recognize-linux-musleabi-and-linux-muslg.patch
"

View file

@ -0,0 +1,62 @@
# Automatically generated aport, do not edit!
# Generator: pmbootstrap aportgen musl-ppc64le
# Stub for apkbuild-lint
if [ -z "$(type -t arch_to_hostspec)" ]; then
arch_to_hostspec() { :; }
fi
pkgname=musl-ppc64le
pkgver=1.2.5
pkgrel=19
arch="x86_64"
subpackages="musl-dev-ppc64le:package_dev"
_arch="ppc64le"
_mirror="http://dl-4.alpinelinux.org/alpine/"
url="https://musl-libc.org"
license="MIT"
options="!check !strip"
pkgdesc="the musl library (lib c) implementation for $_arch"
_target="$(arch_to_hostspec $_arch)"
source="
musl-$pkgver-r$pkgrel-$_arch-edge.apk::$_mirror/edge/main/$_arch/musl-$pkgver-r$pkgrel.apk
musl-dev-$pkgver-r$pkgrel-$_arch-edge.apk::$_mirror/edge/main/$_arch/musl-dev-$pkgver-r$pkgrel.apk
"
package() {
mkdir -p "$pkgdir/usr/$_target"
cd "$pkgdir/usr/$_target"
# Use 'busybox tar' to avoid 'tar: Child returned status 141'
# on some machines (builds.sr.ht, gitlab-ci). See pmaports#26.
busybox tar -xf $srcdir/musl-$pkgver-r$pkgrel-$_arch-edge.apk
rm .PKGINFO .SIGN.*
}
package_dev() {
mkdir -p "$subpkgdir/usr/$_target"
cd "$subpkgdir/usr/$_target"
# Use 'busybox tar' to avoid 'tar: Child returned status 141'
# on some machines (builds.sr.ht, gitlab-ci). See pmaports#26.
busybox tar -xf $srcdir/musl-dev-$pkgver-r$pkgrel-$_arch-edge.apk
rm .PKGINFO .SIGN.*
# symlink everything from /usr/$_target/usr/*
# to /usr/$_target/* so the cross-compiler gcc does not fail
# to build.
for _dir in include lib; do
mkdir -p "$subpkgdir/usr/$_target/$_dir"
cd "$subpkgdir/usr/$_target/usr/$_dir"
for i in *; do
cd "$subpkgdir/usr/$_target/$_dir"
ln -s /usr/$_target/usr/$_dir/$i $i
done
done
}
sha512sums="
daf6620c8d9ff7ea0ea6beb83e94459d6de5a86a3f04d931881d5f8932eef01d576ef44bd421c86250bd0d3f1b22e9f476bee9f95af4c2f380eb755443a52a65 musl-1.2.5-r19-ppc64le-edge.apk
e9c414cc51948515b745f6af234a9240d5c8e98232d41074c0a4db0d1ddb67fae789bf4c86a2e1dc128e22cfa66fc39ab0094d5e1b885369088e6264b19530a8 musl-dev-1.2.5-r19-ppc64le-edge.apk
"