https://gcc.gnu.org/g:5f872c363890540fab2432ac3c50012e820e504b

commit r13-9380-g5f872c363890540fab2432ac3c50012e820e504b
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.

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 c91a6bf0f4e5..d3b2d8a52fe1 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 5b6a08e8a129..3962ecb04752 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 9050a8dcbf9b..091d1ad5a0c8 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 7fa9e8a93ff4..4de5ec461bed 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 ce952f1abfce..07a07b0aaa5c 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 31320e281b94..3482c8873cf2 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*}                                \
   %{mbig-endian:-EB}                                           \
diff --git a/gcc/config/rs6000/freebsd64.h b/gcc/config/rs6000/freebsd64.h
index 111aa14bf9d0..84a99b30945d 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 ae932fc22f05..cf946e3ecd1b 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