From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by sourceware.org (Postfix) with ESMTPS id 60020385BAE9 for ; Mon, 4 Jul 2022 12:28:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 60020385BAE9 Received: by mail-qt1-x82f.google.com with SMTP id k14so9654058qtm.3 for ; Mon, 04 Jul 2022 05:28:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=MS6n542fMlEeC/uima6K9UNZ2mnYDpMeP4wIzd2t2ws=; b=kLKJ2RsuMD2AO3wknJg/GmF23hleFnR29clfakkzaH4ICeMH1EWved3AraLxreYWwY 2FdDdESe+HdnsWl4Zq7LPq8hBXiH5EUiyw3wrR68iEH0Xm8749lF4wcNiN/aqt85AmVy QS94pq44P8otQsDreU8it1ymV2KA+w1kSOBjLUe8ulScsLcypDP6U7QO1O3EMaU8uk/F DTm+wY34xuswrjpBHUR0Gu8keG0mU1Z0iR5wTUk6I6SYmSn1MGI1zY9T/o9mYNQGOFql z/aON3kvLp+FibSY4u94QP1fpa+pVP9JZen7oEuCREKM92/G9QZlGZZNgG11e4QH2ACb RWgQ== X-Gm-Message-State: AJIora/neGEhlvngU4pTnCQPJzfjgAGn2jSn0kP1S/CGj+pnIgXqyzrr iXMcdOrFRRlEzfJDc1j1SO9KkzwQQS7FlFptBb0= X-Google-Smtp-Source: AGRyM1tKml7H+ggZMBXGv4Sp4Ea5fKLTJK05fYxdhSXeLcpOh4re7xXb80YmKiGRfmB9yegjdKs281aQ+cOcZUyacB0= X-Received: by 2002:ad4:5bc1:0:b0:472:d202:c40b with SMTP id t1-20020ad45bc1000000b00472d202c40bmr12043944qvt.78.1656937707654; Mon, 04 Jul 2022 05:28:27 -0700 (PDT) MIME-Version: 1.0 References: <31c1c05e-79c6-01d5-4fc1-d401f8b52384@suse.cz> In-Reply-To: <31c1c05e-79c6-01d5-4fc1-d401f8b52384@suse.cz> From: Richard Biener Date: Mon, 4 Jul 2022 14:28:16 +0200 Message-ID: Subject: Re: [PATCH] lto-plugin: Add path to libatomic for riscv64 To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches , Kito Cheng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 12:28:31 -0000 On Mon, Jul 4, 2022 at 1:32 PM Martin Li=C5=A1ka 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 :=3D $(libexecdir)/gcc/$(real_target_nonc= anonical)/$(gcc_version)$(a > AM_CPPFLAGS =3D -I$(top_srcdir)/../include $(DEFS) > AM_CFLAGS =3D @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS) > # The plug-in depends on pthreads. > -AM_LDFLAGS =3D -pthread @ac_lto_plugin_ldflags@ > +AM_LDFLAGS =3D $(PTHREAD_CFLAGS) @ac_lto_plugin_ldflags@ > AM_LIBTOOLFLAGS =3D --tag=3Ddisable-static > override CFLAGS :=3D $(filter-out -fsanitize=3Daddress -fsanitize=3Dhwad= dress,$(CFLAGS)) > override LDFLAGS :=3D $(filter-out -fsanitize=3Daddress -fsanitize=3Dhwa= ddress,$(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 =3D @PACKAGE_TARNAME@ > PACKAGE_URL =3D @PACKAGE_URL@ > PACKAGE_VERSION =3D @PACKAGE_VERSION@ > PATH_SEPARATOR =3D @PATH_SEPARATOR@ > +PTHREAD_CFLAGS =3D @PTHREAD_CFLAGS@ > RANLIB =3D @RANLIB@ > SED =3D @SED@ > SET_MAKE =3D @SET_MAKE@ > @@ -345,7 +346,7 @@ libexecsubdir :=3D $(libexecdir)/gcc/$(real_target_no= ncanonical)/$(gcc_version)$(a > AM_CPPFLAGS =3D -I$(top_srcdir)/../include $(DEFS) > AM_CFLAGS =3D @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS) > # The plug-in depends on pthreads. > -AM_LDFLAGS =3D -pthread @ac_lto_plugin_ldflags@ > +AM_LDFLAGS =3D $(PTHREAD_CFLAGS) @ac_lto_plugin_ldflags@ > AM_LIBTOOLFLAGS =3D --tag=3Ddisable-static > libexecsub_LTLIBRARIES =3D liblto_plugin.la > in_gcc_libs =3D $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_di= r)/$(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 su= pported" >&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=3D$CFLAGS > +CFLAGS=3D"$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=3Dyes > +else > + lto_plugin_cv_lib_pthread=3Dno > +fi > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > +CFLAGS=3D$CFLAGS_hold > +fi > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lto_plugin_cv_lib_pthr= ead" >&5 > +$as_echo "$lto_plugin_cv_lib_pthread" >&6; } > +PTHREAD_CFLAGS=3D > +if test "$libgo_cv_lib_pthread" =3D yes; then > + # RISC-V apparently adds -latomic when using -pthread. > + PTHREAD_CFLAGS=3D"-pthread -L../$build/libatomic/.libs" > +fi > + > + > + > case `pwd` in > *\ * | *\ *) > { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not c= ope well with whitespace in \`pwd\`" >&5 > @@ -12091,7 +12121,7 @@ else > lt_dlunknown=3D0; lt_dlno_uscore=3D1; lt_dlneed_uscore=3D2 > lt_status=3D$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=3D0; lt_dlno_uscore=3D1; lt_dlneed_uscore=3D2 > lt_status=3D$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" =3D 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=3D$CFLAGS > +CFLAGS=3D"$CFLAGS -pthread -L../$build/libatomic/.libs" > +AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], > +[lto_plugin_cv_lib_pthread=3Dyes], > +[lto_plugin_cv_lib_pthread=3Dno]) > +CFLAGS=3D$CFLAGS_hold]) > +PTHREAD_CFLAGS=3D > +if test "$libgo_cv_lib_pthread" =3D yes; then > + # RISC-V apparently adds -latomic when using -pthread. > + PTHREAD_CFLAGS=3D"-pthread -L../$build/libatomic/.libs" > +fi > +AC_SUBST(PTHREAD_CFLAGS) > + > + > AM_PROG_LIBTOOL > ACX_LT_HOST_FLAGS > AC_SUBST(target_noncanonical) > -- > 2.36.1 >