https://gcc.gnu.org/g:7cf4c1e16755f7adab3bff983d980d6ae0b9a6f3

commit 7cf4c1e16755f7adab3bff983d980d6ae0b9a6f3
Author: Andreas Tobler <andre...@gcc.gnu.org>
Date:   Sun Jun 9 23:18:04 2024 +0200

    FreeBSD: Stop linking _p libs for -pg as of FreeBSD 14
    
    As of FreeBSD version 14, FreeBSD no longer provides profiled system
    libraries like libc_p and libpthread_p. Stop linking against them if
    the FreeBSD major version is 14 or more.
    
    gcc:
            * config/freebsd-spec.h: Change fbsd-lib-spec for FreeBSD > 13,
            do not link against profiled system libraries if -pg is invoked.
            Add a define to note about this change.
            * config/aarch64/aarch64-freebsd.h: Use the note to inform if
            -pg is invoked on FreeBSD > 13.
            * config/arm/freebsd.h: Likewise.
            * config/i386/freebsd.h: Likewise.
            * config/i386/freebsd64.h: Likewise.
            * config/riscv/freebsd.h: Likewise.
            * config/rs6000/freebsd64.h: Likewise.
            * config/rs6000/sysv4.h: Likeise.
    (cherry picked from commit 48abb540701447b0cd9df7542720ab65a34fc1b1)

Diff:
---
 gcc/config/aarch64/aarch64-freebsd.h |  1 +
 gcc/config/arm/freebsd.h             |  1 +
 gcc/config/freebsd-spec.h            | 18 ++++++++++++++----
 gcc/config/i386/freebsd.h            |  1 +
 gcc/config/i386/freebsd64.h          |  1 +
 gcc/config/riscv/freebsd.h           |  1 +
 gcc/config/rs6000/freebsd64.h        |  1 +
 gcc/config/rs6000/sysv4.h            |  1 +
 8 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-freebsd.h 
b/gcc/config/aarch64/aarch64-freebsd.h
index 53cc17a1caf..e26d69ce46c 100644
--- a/gcc/config/aarch64/aarch64-freebsd.h
+++ b/gcc/config/aarch64/aarch64-freebsd.h
@@ -35,6 +35,7 @@
 #undef  FBSD_TARGET_LINK_SPEC
 #define FBSD_TARGET_LINK_SPEC "                                 \
     %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}  \
+    " FBSD_LINK_PG_NOTE "                                      \
     %{v:-V}                                                     \
     %{assert*} %{R*} %{rpath*} %{defsym*}                       \
     %{shared:-Bshareable %{h*} %{soname*}}                      \
diff --git a/gcc/config/arm/freebsd.h b/gcc/config/arm/freebsd.h
index 9d0a5a842ab..ee4860ae637 100644
--- a/gcc/config/arm/freebsd.h
+++ b/gcc/config/arm/freebsd.h
@@ -47,6 +47,7 @@
 #undef LINK_SPEC
 #define LINK_SPEC "                                                    \
   %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}           \
+  " FBSD_LINK_PG_NOTE "                                                        
\
   %{v:-V}                                                              \
   %{assert*} %{R*} %{rpath*} %{defsym*}                                        
\
   %{shared:-Bshareable %{h*} %{soname*}}                               \
diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h
index a6d1ad1280f..f43056bf2cf 100644
--- a/gcc/config/freebsd-spec.h
+++ b/gcc/config/freebsd-spec.h
@@ -92,19 +92,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
    libc, depending on whether we're doing profiling or need threads support.
    (similar to the default, except no -lg, and no -p).  */
 
+#if FBSD_MAJOR < 14
+#define FBSD_LINK_PG_NOTHREADS "%{!pg: -lc}  %{pg: -lc_p}"
+#define FBSD_LINK_PG_THREADS   "%{!pg: %{pthread:-lpthread} -lc} "     \
+                               "%{pg: %{pthread:-lpthread} -lc_p}"
+#define FBSD_LINK_PG_NOTE ""
+#else
+#define FBSD_LINK_PG_NOTHREADS "%{-lc} "
+#define FBSD_LINK_PG_THREADS   "%{pthread:-lpthread} -lc "
+#define FBSD_LINK_PG_NOTE "%{pg:%nFreeBSD no longer provides profiled "\
+                         "system libraries}"
+#endif
+
 #ifdef FBSD_NO_THREADS
 #define FBSD_LIB_SPEC "                                                        
\
   %{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}                                                      \
+    " FBSD_LINK_PG_NOTHREADS "                                         \
   }"
 #else
 #define FBSD_LIB_SPEC "                                                        
\
   %{!shared:                                                           \
-    %{!pg: %{pthread:-lpthread} -lc}                                   \
-    %{pg:  %{pthread:-lpthread_p} -lc_p}                               \
+    " FBSD_LINK_PG_THREADS "                                           \
   }                                                                    \
   %{shared:                                                            \
     %{pthread:-lpthread} -lc                                           \
diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h
index 3c57dc7cfae..583c752bb76 100644
--- a/gcc/config/i386/freebsd.h
+++ b/gcc/config/i386/freebsd.h
@@ -80,6 +80,7 @@ along with GCC; see the file COPYING3.  If not see
 #undef LINK_SPEC
 #define LINK_SPEC "\
   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
+  " FBSD_LINK_PG_NOTE " \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
   %{shared:-Bshareable %{h*} %{soname*}} \
diff --git a/gcc/config/i386/freebsd64.h b/gcc/config/i386/freebsd64.h
index af3fc3018b7..12985e22ef9 100644
--- a/gcc/config/i386/freebsd64.h
+++ b/gcc/config/i386/freebsd64.h
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
   %{m32:-m elf_i386_fbsd}%{!m32:-m elf_x86_64_fbsd} \
   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
+  " FBSD_LINK_PG_NOTE " \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
   %{shared:-Bshareable %{h*} %{soname*}} \
diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h
index 5dd4d51c42b..6063861e704 100644
--- a/gcc/config/riscv/freebsd.h
+++ b/gcc/config/riscv/freebsd.h
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "                                            \
   -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv                  \
   %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}   \
+  " FBSD_LINK_PG_NOTES "                                               \
   %{v:-V}                                                      \
   %{assert*} %{R*} %{rpath*} %{defsym*}                                \
   -X                                                           \
diff --git a/gcc/config/rs6000/freebsd64.h b/gcc/config/rs6000/freebsd64.h
index 55e75cfb66a..6740170d3cc 100644
--- a/gcc/config/rs6000/freebsd64.h
+++ b/gcc/config/rs6000/freebsd64.h
@@ -112,6 +112,7 @@ extern int dot_symbols;
 
 #define LINK_OS_FREEBSD_SPEC_DEF "\
   %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
+  " FBSD_LINK_PG_NOTE " \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
   %{shared:-Bshareable %{h*} %{soname*}} \
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index bcafa9d0cf4..e997dd77e5e 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -748,6 +748,7 @@ GNU_USER_TARGET_CC1_SPEC
 
 #define LINK_OS_FREEBSD_SPEC "\
   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
+  " FBSD_LINK_PG_NOTE " \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
   %{shared:-Bshareable %{h*} %{soname*}} \

Reply via email to