Re: Profiled libraries on freebsd-current

From: Steve Kargl <sgk_at_troutmask.apl.washington.edu>
Date: Sun, 01 May 2022 15:54:14 UTC
On Sat, Apr 30, 2022 at 04:07:48PM -0400, Ed Maste wrote:
> On Sat, 30 Apr 2022 at 11:34, Steve Kargl
> <sgk@troutmask.apl.washington.edu> wrote:
> >
> > On Sat, Apr 30, 2022 at 09:39:32AM -0400, Ed Maste wrote:
> > > On Fri, 29 Apr 2022 at 01:58, Steve Kargl
> > > <sgk@troutmask.apl.washington.edu> wrote:
> > > >
> > > > If one looks at src.conf(5), one finds
> > > >
> > > >    WITH_PROFILE
> > > >          Build profiled libraries for use with gprof(8).  This option is
> > > >          deprecated and is not present in FreeBSD 14.
> > > >
> > > > I assume that the *_p.a libraries will no longer be built and
> > > > installed on FreeBSD 14 and later.  Is this correct?
> > >
> > > FreeBSD 14 is not yet released, of course, but that is indeed the
> > > intent. PR256874 reports that a GCC patch (to stop linking against
> > > _p.a) is in the works but unfortunately has not had an update for some
> > > time.
> >
> > I see.  It only took me 2+ years to get
> >
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89125
> >
> > committed to the GCC repository.  Good luck with
> > getting your patch upstream.
> 
> Heh, thanks.
> 
> I have just now changed the WITH_PROFILE description to state "a
> future version of FreeBSD" since it may well not happen for FreeBSD
> 14.
> 
> We could also just install libc_p.a as a symlink to libc.a (and same
> for the other _p.a archives).

This works for me, but there is one addition place dealing with -pg
in freebsd-spec.h


diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h
index 594487829b5..1e8ab2e1827 100644
--- a/gcc/config/freebsd-spec.h
+++ b/gcc/config/freebsd-spec.h
@@ -93,14 +93,22 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    (similar to the default, except no -lg, and no -p).  */
 
 #ifdef FBSD_NO_THREADS
+#if FBSD_MAJOR < 14
 #define FBSD_LIB_SPEC "							\
-  %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
+ %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
 is built with the --enable-threads configure-time option.}		\
   %{!shared:								\
     %{!pg: -lc}								\
     %{pg:  -lc_p}							\
   }"
 #else
+#define FBSD_LIB_SPEC "							\
+ %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
+is built with the --enable-threads configure-time option.}		\
+  }"
+#endif
+#else
+#if FBSD_MAJOR < 14
 #define FBSD_LIB_SPEC "							\
   %{!shared:								\
     %{!pg: %{pthread:-lpthread} -lc}					\
@@ -109,6 +117,15 @@ is built with the --enable-threads configure-time option.}		\
   %{shared:								\
     %{pthread:-lpthread} -lc						\
   }"
+#else
+#define FBSD_LIB_SPEC "							\
+  %{!shared:								\
+    %{pthread:-lpthread} -lc						\
+  }									\
+  %{shared:								\
+    %{pthread:-lpthread} -lc						\
+  }"
+#endif
 #endif
 
 /* To make matters interesting, we can't actually use __FreeBSD_version
-- 
Steve