···11-From 46280d27a5c96b2efa7a61f49ee8dc14f7e10d0c Mon Sep 17 00:00:00 2001
22-From: John Ericson <git@JohnEricson.me>
33-Date: Sun, 22 Aug 2021 01:14:22 -0400
44-Subject: [PATCH] Factor out thread model detection with `GCC_AC_THREAD_MODEL`
55-MIME-Version: 1.0
66-Content-Type: text/plain; charset=UTF-8
77-Content-Transfer-Encoding: 8bit
88-99-This macro deduplicates the
1010-1111- $CC -v 2>&1 | sed -n 's/^Thread model: //p'
1212-1313-check that was occurring in various runtime libs.
1414-1515-Additionally, as a bit of an Easter egg, this also allows overriding
1616-what the compiler would return by setting the
1717-`gcc_cv_target_thread_file` cache variable first. I admit that it is in
1818-fact this Easter egg that led me to write the patch. The use-case for it
1919-is for making multilib builds where the library sets do not all share
2020-the same thread model easier. See also `THREAD_MODEL_SPEC` for more
2121-about the varying thread models use-case.
2222-2323-Arguably one could could try to define on `THREAD_MODEL_SPEC` on more
2424-platforms (besides e.g. AIX) but the ramifications of this are a bit
2525-unclear. Setting `gcc_cv_target_thread_file` directly is a "low tech"
2626-solution that will work for now for sure. Of course, since setting a
2727-cache variable like this a hacky trick, I will not expect this to be at
2828-all stable/guaranteed to work, going forward.
2929-3030-Thanks to Arsen who on IRC discussed these things with me, including in
3131-particular making it a cache var not `--with-model` flag, to not
3232-prematurely foster expectations that this is stable.
3333-3434-Suggested-by: Arsen Arsenović <arsen@aarsen.me>
3535----
3636- config/gthr.m4 | 23 +++++++++++++++++++++++
3737- libatomic/configure.ac | 4 +---
3838- libgcc/configure.ac | 4 +---
3939- libphobos/m4/druntime/os.m4 | 2 +-
4040- libstdc++-v3/acinclude.m4 | 8 +++-----
4141- 5 files changed, 29 insertions(+), 12 deletions(-)
4242-4343-diff --git a/config/gthr.m4 b/config/gthr.m4
4444-index 11996247f15..e8fac4a5721 100644
4545---- a/config/gthr.m4
4646-+++ b/config/gthr.m4
4747-@@ -5,6 +5,26 @@ dnl Public License, this file may be distributed as part of a program
4848- dnl that contains a configuration script generated by Autoconf, under
4949- dnl the same distribution terms as the rest of that program.
5050-5151-+dnl Define thread model
5252-+
5353-+dnl usage: GCC_AC_THREAD_MODEL
5454-+AC_DEFUN([GCC_AC_THREAD_MODEL],
5555-+[
5656-+# Specify the threading model for this GCC runtime library
5757-+# Pass with no value to take from compiler's metadata
5858-+# Pass with a value to specify a thread package
5959-+# 'single' means single threaded -- without threads.
6060-+AC_CACHE_CHECK([for the threading model used by GCC], [gcc_cv_target_thread_file], [
6161-+ # Set new cache variable
6262-+ gcc_cv_target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
6363-+])
6464-+# Set variable name (not prefixed enough to be a good cache variable
6565-+# name) traditionally used for this purpose, to avoid having to change
6666-+# a bunch of configure scripts.
6767-+target_thread_file="$gcc_cv_target_thread_file"
6868-+])
6969-+
7070-+
7171- dnl Define header location by thread model
7272-7373- dnl usage: GCC_AC_THREAD_HEADER([thread_model])
7474-@@ -23,6 +43,9 @@ case $1 in
7575- vxworks) thread_header=config/gthr-vxworks.h ;;
7676- win32) thread_header=config/i386/gthr-win32.h ;;
7777- mcf) thread_header=config/i386/gthr-mcf.h ;;
7878-+ *)
7979-+ AC_MSG_ERROR([No known header for threading model '$1'.])
8080-+ ;;
8181- esac
8282- AC_SUBST(thread_header)
8383- ])
8484-diff --git a/libatomic/configure.ac b/libatomic/configure.ac
8585-index aafae71028d..a1aa3bdf69f 100644
8686---- a/libatomic/configure.ac
8787-+++ b/libatomic/configure.ac
8888-@@ -162,9 +162,7 @@ libtool_VERSION=3:0:2
8989- AC_SUBST(libtool_VERSION)
9090-9191- # Check for used threading-model
9292--AC_MSG_CHECKING([for thread model used by GCC])
9393--target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
9494--AC_MSG_RESULT([$target_thread_file])
9595-+GCC_AC_THREAD_MODEL
9696-9797- case "$target" in
9898- *aarch64*)
9999-diff --git a/libgcc/configure.ac b/libgcc/configure.ac
100100-index 85e4f1bc48b..d44493f9653 100644
101101---- a/libgcc/configure.ac
102102-+++ b/libgcc/configure.ac
103103-@@ -305,9 +305,7 @@ AC_SUBST([use_tm_clone_registry])
104104-105105- AC_LIB_PROG_LD_GNU
106106-107107--AC_MSG_CHECKING([for thread model used by GCC])
108108--target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
109109--AC_MSG_RESULT([$target_thread_file])
110110-+GCC_AC_THREAD_MODEL
111111-112112- # Check for assembler CFI support.
113113- AC_CACHE_CHECK([whether assembler supports CFI directives], [libgcc_cv_cfi],
114114-diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4
115115-index ef8ca434407..7bb91362dbe 100644
116116---- a/libphobos/m4/druntime/os.m4
117117-+++ b/libphobos/m4/druntime/os.m4
118118-@@ -32,7 +32,7 @@ case $1 in
119119- # TODO: These targets need porting.
120120- dce|mipssde|rtems|tpf|vxworks)
121121- DCFG_THREAD_MODEL="Single" ;;
122122-- *) as_fn_error "Thread implementation '$1' not recognised" "$LINENO" 5 ;;
123123-+ *) AC_MSG_ERROR([Thread implementation '$1' not recognised]) ;;
124124- esac
125125- AC_SUBST(DCFG_THREAD_MODEL)
126126- ])
127127-diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
128128-index a0094c2dd95..66fc3abe4fd 100644
129129---- a/libstdc++-v3/acinclude.m4
130130-+++ b/libstdc++-v3/acinclude.m4
131131-@@ -4345,9 +4345,7 @@ dnl Substs:
132132- dnl thread_header
133133- dnl
134134- AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
135135-- AC_MSG_CHECKING([for thread model used by GCC])
136136-- target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
137137-- AC_MSG_RESULT([$target_thread_file])
138138-+ GCC_AC_THREAD_MODEL
139139- GCC_AC_THREAD_HEADER([$target_thread_file])
140140- ])
141141-142142-@@ -4357,7 +4355,8 @@ dnl Check if gthread implementation defines the types and functions
143143- dnl required by the c++0x thread library. Conforming gthread
144144- dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
145145- dnl
146146--dnl GLIBCXX_ENABLE_SYMVERS must be done before this.
147147-+dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_ENABLE_THREADS must be done
148148-+dnl before this.
149149- dnl
150150- AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
151151- GLIBCXX_ENABLE(libstdcxx-threads,auto,,[enable C++11 threads support])
152152-@@ -4372,7 +4371,6 @@ AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
153153- CXXFLAGS="$CXXFLAGS -fno-exceptions \
154154- -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc"
155155-156156-- target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
157157- case $target_thread_file in
158158- posix)
159159- CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
160160---
161161-2.47.2
162162-
···11+From bb3277895d3bd77bcacb7c489ebb1390478bbc12 Mon Sep 17 00:00:00 2001
22+From: John Ericson <John.Ericson@Obsidian.Systems>
33+Date: Thu, 17 Jul 2025 11:00:07 -0400
44+Subject: [PATCH 2/2] Force regular dirs
55+66+Override directories in libgcc so they are normal $out/lib and
77+$dev/include. This is not suitable for upstreaming, but is done on top
88+of a different patch which is, and which makes this smaller.
99+1010+---
1111+ libgcc/Makefile.in | 6 +++---
1212+ libgcc/configure.ac | 3 ---
1313+ 2 files changed, 3 insertions(+), 6 deletions(-)
1414+1515+diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
1616+index 4661c36703d..986cd035148 100644
1717+--- a/libgcc/Makefile.in
1818++++ b/libgcc/Makefile.in
1919+@@ -202,10 +202,10 @@ STRIP = @STRIP@
2020+ STRIP_FOR_TARGET = $(STRIP)
2121+2222+ # Used to install the shared libgcc.
2323+-slibdir = @slibdir@
2424++slibdir = $(libdir)
2525+ # Maybe used for DLLs on Windows targets.
2626+-toolexecdir = @toolexecdir@
2727+-toolexeclibdir = @toolexeclibdir@
2828++toolexecdir = $(bindir)
2929++toolexeclibdir = $(libdir)
3030+3131+ export AR_FOR_TARGET
3232+ export AR_CREATE_FOR_TARGET
3333+diff --git a/libgcc/configure.ac b/libgcc/configure.ac
3434+index 5fdac5d95f2..89044cb65c9 100644
3535+--- a/libgcc/configure.ac
3636++++ b/libgcc/configure.ac
3737+@@ -479,9 +479,6 @@ if test x"$enable_as_accelerator_for" != x; then
3838+ accel_dir_suffix=/accel/${target_noncanonical}
3939+ real_host_noncanonical=${enable_as_accelerator_for}
4040+ fi
4141+-# Directory in which the compiler finds libraries etc.
4242+-libdir=${orig_libdir}/gcc/${real_host_noncanonical}/'$(version)'${accel_dir_suffix}
4343+-includedir=${libdir}/include
4444+4545+ if test x"$enable_offload_targets" != x; then
4646+ extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o"
4747+--
4848+2.47.2
4949+
···11+From e7dac0e90f3e4363d858a6f147d7cc4f62815dd6 Mon Sep 17 00:00:00 2001
22+From: John Ericson <John.Ericson@Obsidian.Systems>
33+Date: Fri, 18 Jul 2025 16:54:17 -0400
44+Subject: [PATCH 3/3] Force regular dirs
55+66+Override directories in libssp so they are normal $out/lib and
77+$dev/include. This is not suitable for upstreaming, but is done on top
88+of a different patch which is, and which makes this smaller.
99+---
1010+ libssp/configure.ac | 4 ----
1111+ 1 file changed, 4 deletions(-)
1212+1313+diff --git a/libssp/configure.ac b/libssp/configure.ac
1414+index 5b9fa4fbecc..f1723dc33ce 100644
1515+--- a/libssp/configure.ac
1616++++ b/libssp/configure.ac
1717+@@ -207,10 +207,6 @@ esac
1818+ AC_SUBST(toolexecdir)
1919+ AC_SUBST(toolexeclibdir)
2020+2121+-# Directory in which the compiler finds libraries etc.
2222+-libdir='$(toolexeclibdir)'
2323+-includedir=${orig_libdir}/gcc/${host_noncanonical}/'$(version)/include'
2424+-
2525+ if test ${multilib} = yes; then
2626+ multilib_arg="--enable-multilib"
2727+ else
2828+--
2929+2.47.2
3030+