lto-plugin: Add path to libatomic for riscv64
Commit Message
Similarly to libgo, we need to provide -L for targets where
libpthread does depends on libatomic.
Ready for master?
PR bootstrap/106156
lto-plugin/ChangeLog:
* Makefile.am: Use PTHREAD_CFLAGS.
* Makefile.in: Regenerate.
* configure.ac: Detect if PTHREAD_CFLAGS should contain path
to libatomic.
* configure: Regenerate.
---
lto-plugin/Makefile.am | 2 +-
lto-plugin/Makefile.in | 3 ++-
lto-plugin/configure | 34 ++++++++++++++++++++++++++++++++--
lto-plugin/configure.ac | 17 +++++++++++++++++
4 files changed, 52 insertions(+), 4 deletions(-)
Comments
On Mon, Jul 4, 2022 at 1:32 PM Martin Liška <mliska@suse.cz> wrote:
>
> Similarly to libgo, we need to provide -L for targets where
> libpthread does depends on libatomic.
>
> Ready for master?
OK
> PR bootstrap/106156
>
> lto-plugin/ChangeLog:
>
> * Makefile.am: Use PTHREAD_CFLAGS.
> * Makefile.in: Regenerate.
> * configure.ac: Detect if PTHREAD_CFLAGS should contain path
> to libatomic.
> * configure: Regenerate.
> ---
> lto-plugin/Makefile.am | 2 +-
> lto-plugin/Makefile.in | 3 ++-
> lto-plugin/configure | 34 ++++++++++++++++++++++++++++++++--
> lto-plugin/configure.ac | 17 +++++++++++++++++
> 4 files changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
> index 81362eafc36..64a6bc8c943 100644
> --- a/lto-plugin/Makefile.am
> +++ b/lto-plugin/Makefile.am
> @@ -10,7 +10,7 @@ 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)
> # The plug-in depends on pthreads.
> -AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
> +AM_LDFLAGS = $(PTHREAD_CFLAGS) @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 2033dd9b7c2..de19c8873de 100644
> --- a/lto-plugin/Makefile.in
> +++ b/lto-plugin/Makefile.in
> @@ -264,6 +264,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
> PACKAGE_URL = @PACKAGE_URL@
> PACKAGE_VERSION = @PACKAGE_VERSION@
> PATH_SEPARATOR = @PATH_SEPARATOR@
> +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
> RANLIB = @RANLIB@
> SED = @SED@
> SET_MAKE = @SET_MAKE@
> @@ -345,7 +346,7 @@ 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)
> # The plug-in depends on pthreads.
> -AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
> +AM_LDFLAGS = $(PTHREAD_CFLAGS) @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 aaa91a63623..aa35bd94b3f 100755
> --- a/lto-plugin/configure
> +++ b/lto-plugin/configure
> @@ -650,6 +650,7 @@ LD
> FGREP
> SED
> LIBTOOL
> +PTHREAD_CFLAGS
> LTO_PLUGIN_USE_SYMVER_SUN_FALSE
> LTO_PLUGIN_USE_SYMVER_SUN_TRUE
> LTO_PLUGIN_USE_SYMVER_GNU_FALSE
> @@ -6020,6 +6021,35 @@ fi
>
>
>
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5
> +$as_echo_n "checking whether -pthread is supported... " >&6; }
> +if ${lto_plugin_cv_lib_pthread+:} false; then :
> + $as_echo_n "(cached) " >&6
> +else
> + CFLAGS_hold=$CFLAGS
> +CFLAGS="$CFLAGS -pthread -L../$build/libatomic/.libs"
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h. */
> +int i;
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> + lto_plugin_cv_lib_pthread=yes
> +else
> + lto_plugin_cv_lib_pthread=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +CFLAGS=$CFLAGS_hold
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lto_plugin_cv_lib_pthread" >&5
> +$as_echo "$lto_plugin_cv_lib_pthread" >&6; }
> +PTHREAD_CFLAGS=
> +if test "$libgo_cv_lib_pthread" = yes; then
> + # RISC-V apparently adds -latomic when using -pthread.
> + PTHREAD_CFLAGS="-pthread -L../$build/libatomic/.libs"
> +fi
> +
> +
> +
> case `pwd` in
> *\ * | *\ *)
> { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
> @@ -12091,7 +12121,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 12094 "configure"
> +#line 12124 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> @@ -12197,7 +12227,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 12200 "configure"
> +#line 12230 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
> index c2ec512880f..ba34a5d0ca1 100644
> --- a/lto-plugin/configure.ac
> +++ b/lto-plugin/configure.ac
> @@ -91,6 +91,23 @@ AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_SUN, [test "x$lto_plugin_use_symver" = xsun
> AC_CHECK_HEADER(pthread.h,
> [AC_DEFINE(HAVE_PTHREAD_H, 1, [Define to 1 if pthread.h is present.])])
>
> +dnl Test whether the compiler supports the -pthread option.
> +AC_CACHE_CHECK([whether -pthread is supported],
> +[lto_plugin_cv_lib_pthread],
> +[CFLAGS_hold=$CFLAGS
> +CFLAGS="$CFLAGS -pthread -L../$build/libatomic/.libs"
> +AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
> +[lto_plugin_cv_lib_pthread=yes],
> +[lto_plugin_cv_lib_pthread=no])
> +CFLAGS=$CFLAGS_hold])
> +PTHREAD_CFLAGS=
> +if test "$libgo_cv_lib_pthread" = yes; then
> + # RISC-V apparently adds -latomic when using -pthread.
> + PTHREAD_CFLAGS="-pthread -L../$build/libatomic/.libs"
> +fi
> +AC_SUBST(PTHREAD_CFLAGS)
> +
> +
> AM_PROG_LIBTOOL
> ACX_LT_HOST_FLAGS
> AC_SUBST(target_noncanonical)
> --
> 2.36.1
>
On Mon, Jul 4, 2022 at 2:28 PM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Mon, Jul 4, 2022 at 1:32 PM Martin Liška <mliska@suse.cz> wrote:
> >
> > Similarly to libgo, we need to provide -L for targets where
> > libpthread does depends on libatomic.
> >
> > Ready for master?
>
> OK
... but ... is libatomic properly built for the host? libgo is a
target library.
>
> > PR bootstrap/106156
> >
> > lto-plugin/ChangeLog:
> >
> > * Makefile.am: Use PTHREAD_CFLAGS.
> > * Makefile.in: Regenerate.
> > * configure.ac: Detect if PTHREAD_CFLAGS should contain path
> > to libatomic.
> > * configure: Regenerate.
> > ---
> > lto-plugin/Makefile.am | 2 +-
> > lto-plugin/Makefile.in | 3 ++-
> > lto-plugin/configure | 34 ++++++++++++++++++++++++++++++++--
> > lto-plugin/configure.ac | 17 +++++++++++++++++
> > 4 files changed, 52 insertions(+), 4 deletions(-)
> >
> > diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
> > index 81362eafc36..64a6bc8c943 100644
> > --- a/lto-plugin/Makefile.am
> > +++ b/lto-plugin/Makefile.am
> > @@ -10,7 +10,7 @@ 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)
> > # The plug-in depends on pthreads.
> > -AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
> > +AM_LDFLAGS = $(PTHREAD_CFLAGS) @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 2033dd9b7c2..de19c8873de 100644
> > --- a/lto-plugin/Makefile.in
> > +++ b/lto-plugin/Makefile.in
> > @@ -264,6 +264,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
> > PACKAGE_URL = @PACKAGE_URL@
> > PACKAGE_VERSION = @PACKAGE_VERSION@
> > PATH_SEPARATOR = @PATH_SEPARATOR@
> > +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
> > RANLIB = @RANLIB@
> > SED = @SED@
> > SET_MAKE = @SET_MAKE@
> > @@ -345,7 +346,7 @@ 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)
> > # The plug-in depends on pthreads.
> > -AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
> > +AM_LDFLAGS = $(PTHREAD_CFLAGS) @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 aaa91a63623..aa35bd94b3f 100755
> > --- a/lto-plugin/configure
> > +++ b/lto-plugin/configure
> > @@ -650,6 +650,7 @@ LD
> > FGREP
> > SED
> > LIBTOOL
> > +PTHREAD_CFLAGS
> > LTO_PLUGIN_USE_SYMVER_SUN_FALSE
> > LTO_PLUGIN_USE_SYMVER_SUN_TRUE
> > LTO_PLUGIN_USE_SYMVER_GNU_FALSE
> > @@ -6020,6 +6021,35 @@ fi
> >
> >
> >
> > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5
> > +$as_echo_n "checking whether -pthread is supported... " >&6; }
> > +if ${lto_plugin_cv_lib_pthread+:} false; then :
> > + $as_echo_n "(cached) " >&6
> > +else
> > + CFLAGS_hold=$CFLAGS
> > +CFLAGS="$CFLAGS -pthread -L../$build/libatomic/.libs"
> > +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> > +/* end confdefs.h. */
> > +int i;
> > +_ACEOF
> > +if ac_fn_c_try_compile "$LINENO"; then :
> > + lto_plugin_cv_lib_pthread=yes
> > +else
> > + lto_plugin_cv_lib_pthread=no
> > +fi
> > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> > +CFLAGS=$CFLAGS_hold
> > +fi
> > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lto_plugin_cv_lib_pthread" >&5
> > +$as_echo "$lto_plugin_cv_lib_pthread" >&6; }
> > +PTHREAD_CFLAGS=
> > +if test "$libgo_cv_lib_pthread" = yes; then
> > + # RISC-V apparently adds -latomic when using -pthread.
> > + PTHREAD_CFLAGS="-pthread -L../$build/libatomic/.libs"
> > +fi
> > +
> > +
> > +
> > case `pwd` in
> > *\ * | *\ *)
> > { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
> > @@ -12091,7 +12121,7 @@ else
> > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> > lt_status=$lt_dlunknown
> > cat > conftest.$ac_ext <<_LT_EOF
> > -#line 12094 "configure"
> > +#line 12124 "configure"
> > #include "confdefs.h"
> >
> > #if HAVE_DLFCN_H
> > @@ -12197,7 +12227,7 @@ else
> > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> > lt_status=$lt_dlunknown
> > cat > conftest.$ac_ext <<_LT_EOF
> > -#line 12200 "configure"
> > +#line 12230 "configure"
> > #include "confdefs.h"
> >
> > #if HAVE_DLFCN_H
> > diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
> > index c2ec512880f..ba34a5d0ca1 100644
> > --- a/lto-plugin/configure.ac
> > +++ b/lto-plugin/configure.ac
> > @@ -91,6 +91,23 @@ AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_SUN, [test "x$lto_plugin_use_symver" = xsun
> > AC_CHECK_HEADER(pthread.h,
> > [AC_DEFINE(HAVE_PTHREAD_H, 1, [Define to 1 if pthread.h is present.])])
> >
> > +dnl Test whether the compiler supports the -pthread option.
> > +AC_CACHE_CHECK([whether -pthread is supported],
> > +[lto_plugin_cv_lib_pthread],
> > +[CFLAGS_hold=$CFLAGS
> > +CFLAGS="$CFLAGS -pthread -L../$build/libatomic/.libs"
> > +AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
> > +[lto_plugin_cv_lib_pthread=yes],
> > +[lto_plugin_cv_lib_pthread=no])
> > +CFLAGS=$CFLAGS_hold])
> > +PTHREAD_CFLAGS=
> > +if test "$libgo_cv_lib_pthread" = yes; then
> > + # RISC-V apparently adds -latomic when using -pthread.
> > + PTHREAD_CFLAGS="-pthread -L../$build/libatomic/.libs"
> > +fi
> > +AC_SUBST(PTHREAD_CFLAGS)
> > +
> > +
> > AM_PROG_LIBTOOL
> > ACX_LT_HOST_FLAGS
> > AC_SUBST(target_noncanonical)
> > --
> > 2.36.1
> >
On 7/4/22 14:28, Richard Biener wrote:
> ... but ... is libatomic properly built for the host? libgo is a
> target library.
You're correct.
Well, so the host library should be taken, which works for stage1 lto-plugin:
[ 668s] libtool: link: gcc -shared -fPIC -DPIC .libs/lto-plugin.o -pthread -static-libgcc -Wl,--version-script=../../lto-plugin/lto-plugin.map -static-libstdc++ -static-libgcc ../libiberty/pic/libiberty.a -pthread -Wl,-soname -Wl,liblto_plugin.so -o .libs/liblto_p
while it fails in stage2:
[ 7129s] libtool: link: /home/abuild/rpmbuild/BUILD/gcc-13.0.0+git194120/obj-riscv64-suse-linux/./prev-gcc/xgcc -B/home/abuild/rpmbuild/BUILD/gcc-13.0.0+git194120/obj-riscv64-suse-linux/./prev-gcc/ -B/usr/riscv64-suse-linux/bin/ -B/usr/riscv64-suse-linux/bin/ -B/usr/riscv64-suse-linux/lib/ -isystem /usr/riscv64-suse-linux/include -isystem /usr/riscv64-suse-linux/sys-include -fno-checking -shared -fPIC -DPIC .libs/lto-plugin.o -pthread -static-libgcc -Wl,--version-script=../../lto-plugin/lto-plugin.map -static-libstdc++ -static-libgcc ../libiberty/pic/libiberty.a -pthread -Wl,-soname -Wl,liblto_plugin.so -o .libs/liblto_plugin.so
Where the system compiler takes the library from:
/usr/lib/gcc/riscv64-linux-gnu/11/libatomic.so
that points to system library location:
ls -l /usr/lib/gcc/riscv64-linux-gnu/11/libatomic.so
lrwxrwxrwx 1 root root 41 Mar 24 14:22 /usr/lib/gcc/riscv64-linux-gnu/11/libatomic.so -> ../../../riscv64-linux-gnu/libatomic.so.1
So the question is how to fix that?
Martin
On Mon, Jul 4, 2022 at 3:09 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 7/4/22 14:28, Richard Biener wrote:
> > ... but ... is libatomic properly built for the host? libgo is a
> > target library.
>
> You're correct.
>
> Well, so the host library should be taken, which works for stage1 lto-plugin:
>
> [ 668s] libtool: link: gcc -shared -fPIC -DPIC .libs/lto-plugin.o -pthread -static-libgcc -Wl,--version-script=../../lto-plugin/lto-plugin.map -static-libstdc++ -static-libgcc ../libiberty/pic/libiberty.a -pthread -Wl,-soname -Wl,liblto_plugin.so -o .libs/liblto_p
>
> while it fails in stage2:
>
> [ 7129s] libtool: link: /home/abuild/rpmbuild/BUILD/gcc-13.0.0+git194120/obj-riscv64-suse-linux/./prev-gcc/xgcc -B/home/abuild/rpmbuild/BUILD/gcc-13.0.0+git194120/obj-riscv64-suse-linux/./prev-gcc/ -B/usr/riscv64-suse-linux/bin/ -B/usr/riscv64-suse-linux/bin/ -B/usr/riscv64-suse-linux/lib/ -isystem /usr/riscv64-suse-linux/include -isystem /usr/riscv64-suse-linux/sys-include -fno-checking -shared -fPIC -DPIC .libs/lto-plugin.o -pthread -static-libgcc -Wl,--version-script=../../lto-plugin/lto-plugin.map -static-libstdc++ -static-libgcc ../libiberty/pic/libiberty.a -pthread -Wl,-soname -Wl,liblto_plugin.so -o .libs/liblto_plugin.so
>
> Where the system compiler takes the library from:
> /usr/lib/gcc/riscv64-linux-gnu/11/libatomic.so
>
> that points to system library location:
> ls -l /usr/lib/gcc/riscv64-linux-gnu/11/libatomic.so
> lrwxrwxrwx 1 root root 41 Mar 24 14:22 /usr/lib/gcc/riscv64-linux-gnu/11/libatomic.so -> ../../../riscv64-linux-gnu/libatomic.so.1
>
> So the question is how to fix that?
We'd need to add libatomic as host_module in Makefile.def and also
bootstrap that (since lto-plugin is bootstrapped), plus adding
the required dependency. At least for the targets that need this.
Or give up and use better means of serialization or use a whitelist
for now (via lto-plugin configury) and leave
all not covered targets not thread-safe (see also the mingw bugreport).
Richard.
>
> Martin
>
@@ -10,7 +10,7 @@ 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)
# The plug-in depends on pthreads.
-AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
+AM_LDFLAGS = $(PTHREAD_CFLAGS) @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))
@@ -264,6 +264,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -345,7 +346,7 @@ 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)
# The plug-in depends on pthreads.
-AM_LDFLAGS = -pthread @ac_lto_plugin_ldflags@
+AM_LDFLAGS = $(PTHREAD_CFLAGS) @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))
@@ -650,6 +650,7 @@ LD
FGREP
SED
LIBTOOL
+PTHREAD_CFLAGS
LTO_PLUGIN_USE_SYMVER_SUN_FALSE
LTO_PLUGIN_USE_SYMVER_SUN_TRUE
LTO_PLUGIN_USE_SYMVER_GNU_FALSE
@@ -6020,6 +6021,35 @@ fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5
+$as_echo_n "checking whether -pthread is supported... " >&6; }
+if ${lto_plugin_cv_lib_pthread+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -pthread -L../$build/libatomic/.libs"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int i;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ lto_plugin_cv_lib_pthread=yes
+else
+ lto_plugin_cv_lib_pthread=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS=$CFLAGS_hold
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lto_plugin_cv_lib_pthread" >&5
+$as_echo "$lto_plugin_cv_lib_pthread" >&6; }
+PTHREAD_CFLAGS=
+if test "$libgo_cv_lib_pthread" = yes; then
+ # RISC-V apparently adds -latomic when using -pthread.
+ PTHREAD_CFLAGS="-pthread -L../$build/libatomic/.libs"
+fi
+
+
+
case `pwd` in
*\ * | *\ *)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -12091,7 +12121,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12094 "configure"
+#line 12124 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12197,7 +12227,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12200 "configure"
+#line 12230 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -91,6 +91,23 @@ AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_SUN, [test "x$lto_plugin_use_symver" = xsun
AC_CHECK_HEADER(pthread.h,
[AC_DEFINE(HAVE_PTHREAD_H, 1, [Define to 1 if pthread.h is present.])])
+dnl Test whether the compiler supports the -pthread option.
+AC_CACHE_CHECK([whether -pthread is supported],
+[lto_plugin_cv_lib_pthread],
+[CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -pthread -L../$build/libatomic/.libs"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
+[lto_plugin_cv_lib_pthread=yes],
+[lto_plugin_cv_lib_pthread=no])
+CFLAGS=$CFLAGS_hold])
+PTHREAD_CFLAGS=
+if test "$libgo_cv_lib_pthread" = yes; then
+ # RISC-V apparently adds -latomic when using -pthread.
+ PTHREAD_CFLAGS="-pthread -L../$build/libatomic/.libs"
+fi
+AC_SUBST(PTHREAD_CFLAGS)
+
+
AM_PROG_LIBTOOL
ACX_LT_HOST_FLAGS
AC_SUBST(target_noncanonical)