From 51debf7f857dddfb4dd2493867d2648041e7d8de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pekka=20Sepp=C3=A4nen?= <pexu@gcc.mail.kapsi.fi>
Date: Tue, 28 Jun 2022 17:14:09 +0300
Subject: [PATCH] lto: pass -pthread to AM_LDFLAGS [PR 106118]

Move -pthread from configure.ac to Makefile.in so that it is passed to AM_LDFLAGS.

	PR lto/106118

lto-plugin/ChangeLog:

	* configure.ac: Move -pthread from here...
	* Makefile.am: ...to here.
	* configure: Regenerate.
	* Makefile.in: Likewise.
---
 lto-plugin/Makefile.am  | 3 ++-
 lto-plugin/Makefile.in  | 3 ++-
 lto-plugin/configure    | 7 ++-----
 lto-plugin/configure.ac | 3 ---
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
index a96acc87ee28..81362eafc36e 100644
--- a/lto-plugin/Makefile.am
+++ b/lto-plugin/Makefile.am
@@ -9,7 +9,8 @@ libexecsubdir := $(libexecdir)/gcc/$(real_target_noncanonical)/$(gcc_version)$(a
 
 AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS)
 AM_CFLAGS = @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS)
-AM_LDFLAGS = @ac_lto_plugin_ldflags@
+# The plug-in depends on pthreads.
+AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
 AM_LIBTOOLFLAGS = --tag=disable-static
 override CFLAGS := $(filter-out -fsanitize=address -fsanitize=hwaddress,$(CFLAGS))
 override LDFLAGS := $(filter-out -fsanitize=address -fsanitize=hwaddress,$(LDFLAGS))
diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in
index 5debcb21b66d..2033dd9b7c2f 100644
--- a/lto-plugin/Makefile.in
+++ b/lto-plugin/Makefile.in
@@ -344,7 +344,8 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
 libexecsubdir := $(libexecdir)/gcc/$(real_target_noncanonical)/$(gcc_version)$(accel_dir_suffix)
 AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS)
 AM_CFLAGS = @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS)
-AM_LDFLAGS = @ac_lto_plugin_ldflags@
+# The plug-in depends on pthreads.
+AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
 AM_LIBTOOLFLAGS = --tag=disable-static
 libexecsub_LTLIBRARIES = liblto_plugin.la
 in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
diff --git a/lto-plugin/configure b/lto-plugin/configure
index 7d2f1ad308c2..aaa91a636232 100755
--- a/lto-plugin/configure
+++ b/lto-plugin/configure
@@ -5643,9 +5643,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-# The plug-in depends on pthreads
-LDFLAGS="-pthread"
-
 # Check whether -static-libgcc is supported.
 saved_LDFLAGS="$LDFLAGS"
 LDFLAGS="$LDFLAGS -static-libgcc"
@@ -12094,7 +12091,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12097 "configure"
+#line 12094 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12200,7 +12197,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12203 "configure"
+#line 12200 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
index 75cf46ac5c72..c2ec512880f2 100644
--- a/lto-plugin/configure.ac
+++ b/lto-plugin/configure.ac
@@ -13,9 +13,6 @@ AC_PROG_CC
 AC_SYS_LARGEFILE
 ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags])
 
-# The plug-in depends on pthreads
-LDFLAGS="-pthread"
-
 # Check whether -static-libgcc is supported.
 saved_LDFLAGS="$LDFLAGS"
 LDFLAGS="$LDFLAGS -static-libgcc"
-- 
GitLab