On 03.09.25 07:47, Peter Eisentraut wrote:
So, can we declare that we don't support this compiler anymore?

Ok, looks like we're calling it.

Here is a patch set to remove what turns out to be a significant amount of code and documentation to support this compiler.

I also added in one tiny cosmetic bug fix that this compiler found, as its parting gift.

In passing, I also removed some version checks for no longer supported old GCC versions, since they touched some of the same #ifdef etc. lines.

In src/include/storage/s_lock.h, there was a comment to look in src/backend/port/tas/sunstudio_sparc.s for some explanation. But the latter is to be removed, so I copied the comment over and tried to fit it in. But I don't understand it much, and it makes some claims about gcc support for sparc, so it could be that some more code for newer sparc variants is dead, or maybe gcc has caught up in the meantime. Also, that cvs.opensolaris.org link no longer works. But I think this all could be a separate project to sort out.
From 99e0591b71034f2fd51ede22be7b6b072caf4812 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Wed, 3 Sep 2025 17:25:51 +0200
Subject: [PATCH 1/3] Remove stray semicolon at global scope

The Sun Studio compiler complains about an empty declaration here.

Note for future historians:  This does not mean that this compiler is
still of current interest for anyone using PostgreSQL.  But we can let
this small fix be its parting gift.

Discussion: 
https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org
---
 src/backend/replication/logical/slotsync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/replication/logical/slotsync.c 
b/src/backend/replication/logical/slotsync.c
index 9d0072a49ed..8c061d55bdb 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -1337,7 +1337,7 @@ reset_syncing_flag()
        SpinLockRelease(&SlotSyncCtx->mutex);
 
        syncing_slots = false;
-};
+}
 
 /*
  * The main loop of our worker process.

base-commit: 01d6e5b2cf90737395344a8233cae5891c191357
-- 
2.51.0

From 58c151b7bd062dee6744f5c1d3fe2ee0863e5349 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 4 Sep 2025 11:38:04 +0200
Subject: [PATCH 2/3] Remove checks for no longer supported GCC versions

Since commit f5e0186f865 (Raise C requirement to C11), we effectively
require at least GCC version 4.7, so checks for older versions can be
removed.

Discussion: 
https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org
---
 src/include/c.h                        | 8 ++++----
 src/include/port/atomics/generic-gcc.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/include/c.h b/src/include/c.h
index 39022f8a9dd..b580cfa7d31 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -259,8 +259,8 @@
  * choose not to.  But, if possible, don't force inlining in unoptimized
  * debug builds.
  */
-#if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || 
defined(__SUNPRO_C)
-/* GCC > 3 and Sunpro support always_inline via __attribute__ */
+#if (defined(__GNUC__) && defined(__OPTIMIZE__)) || defined(__SUNPRO_C)
+/* GCC and Sunpro support always_inline via __attribute__ */
 #define pg_attribute_always_inline __attribute__((always_inline)) inline
 #elif defined(_MSC_VER)
 /* MSVC has a special keyword for this */
@@ -277,7 +277,7 @@
  * above, this should be placed before the function's return type and name.
  */
 /* GCC and Sunpro support noinline via __attribute__ */
-#if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C)
 #define pg_noinline __attribute__((noinline))
 /* msvc via declspec */
 #elif defined(_MSC_VER)
@@ -369,7 +369,7 @@
  * These should only be used sparingly, in very hot code paths. It's very easy
  * to mis-estimate likelihoods.
  */
-#if __GNUC__ >= 3
+#ifdef __GNUC__
 #define likely(x)      __builtin_expect((x) != 0, 1)
 #define unlikely(x) __builtin_expect((x) != 0, 0)
 #else
diff --git a/src/include/port/atomics/generic-gcc.h 
b/src/include/port/atomics/generic-gcc.h
index d8f04c89cca..e7dfad4f0d5 100644
--- a/src/include/port/atomics/generic-gcc.h
+++ b/src/include/port/atomics/generic-gcc.h
@@ -30,14 +30,14 @@
 #define pg_compiler_barrier_impl()     __asm__ __volatile__("" ::: "memory")
 
 /*
- * If we're on GCC 4.1.0 or higher, we should be able to get a memory barrier
+ * If we're on GCC, we should be able to get a memory barrier
  * out of this compiler built-in.  But we prefer to rely on platform specific
  * definitions where possible, and use this only as a fallback.
  */
 #if !defined(pg_memory_barrier_impl)
 #      if defined(HAVE_GCC__ATOMIC_INT32_CAS)
 #              define pg_memory_barrier_impl()         
__atomic_thread_fence(__ATOMIC_SEQ_CST)
-#      elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+#      elif defined(__GNUC__)
 #              define pg_memory_barrier_impl()         __sync_synchronize()
 #      endif
 #endif /* !defined(pg_memory_barrier_impl) */
-- 
2.51.0

From 9519e84aab99ddeb45771fc65add4d94078ac5bb Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 4 Sep 2025 12:13:28 +0200
Subject: [PATCH 3/3] Remove traces of support for Sun Studio compiler

Per discussion, this compiler suite is no longer maintained, and
it has not been able to compile PostgreSQL since at least PostgreSQL
17.

This removes all the remaining support code for this compiler.

Note that the Solaris operating system continues to be supported, but
using GCC as the compiler.

Discussion: 
https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org
---
 config/c-compiler.m4                      |   2 +-
 configure                                 |  31 +-----
 configure.ac                              |  12 +--
 doc/src/sgml/dfunc.sgml                   |   9 +-
 doc/src/sgml/installation.sgml            |  62 +-----------
 meson.build                               |   2 +-
 src/Makefile.global.in                    |   1 -
 src/backend/port/Makefile                 |   7 --
 src/backend/port/tas/sunstudio_sparc.s    |  53 ----------
 src/backend/port/tas/sunstudio_x86.s      |  43 --------
 src/include/c.h                           |  15 ++-
 src/include/port/atomics.h                |   2 -
 src/include/port/atomics/arch-x86.h       |   2 +-
 src/include/port/atomics/generic-sunpro.h | 113 ----------------------
 src/include/port/solaris.h                |  21 ----
 src/include/storage/s_lock.h              |  33 +++----
 src/makefiles/meson.build                 |   2 -
 src/template/linux                        |  23 -----
 src/template/solaris                      |  29 +-----
 src/tools/pginclude/headerscheck          |   1 -
 20 files changed, 32 insertions(+), 431 deletions(-)
 delete mode 100644 src/backend/port/tas/sunstudio_sparc.s
 delete mode 100644 src/backend/port/tas/sunstudio_x86.s
 delete mode 100644 src/include/port/atomics/generic-sunpro.h

diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index da40bd6a647..236a59e8536 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -83,7 +83,7 @@ if test x"$pgac_cv__128bit_int" = xyes ; then
   AC_CACHE_CHECK([for __int128 alignment bug], [pgac_cv__128bit_int_bug],
   [AC_RUN_IFELSE([AC_LANG_PROGRAM([
 /* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__)
 #define pg_attribute_aligned(a) __attribute__((aligned(a)))
 #elif defined(_MSC_VER)
 #define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/configure b/configure
index 39c68161cec..aa151b5a3ae 100755
--- a/configure
+++ b/configure
@@ -760,7 +760,6 @@ CLANG
 LLVM_CONFIG
 AWK
 with_llvm
-SUN_STUDIO_CC
 ac_ct_CXX
 CXXFLAGS
 CXX
@@ -4799,30 +4798,6 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-# Check if it's Sun Studio compiler. We assume that
-# __SUNPRO_C will be defined for Sun Studio compilers
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __SUNPRO_C
-choke me
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  SUN_STUDIO_CC=yes
-else
-  SUN_STUDIO_CC=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-
 
 #
 # LLVM
@@ -6748,7 +6723,7 @@ fi
 # __attribute__((visibility("hidden"))) is supported, if we encounter a
 # compiler that supports one of the supported variants of -fvisibility=hidden
 # but uses a different syntax to mark a symbol as exported.
-if test "$GCC" = yes -o "$SUN_STUDIO_CC" = yes ; then
+if test "$GCC" = yes; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports 
-fvisibility=hidden, for CFLAGS_SL_MODULE" >&5
 $as_echo_n "checking whether ${CC} supports -fvisibility=hidden, for 
CFLAGS_SL_MODULE... " >&6; }
 if ${pgac_cv_prog_CC_cflags__fvisibility_hidden+:} false; then :
@@ -17141,7 +17116,7 @@ else
 /* end confdefs.h.  */
 
 /* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__)
 #define pg_attribute_aligned(a) __attribute__((aligned(a)))
 #elif defined(_MSC_VER)
 #define pg_attribute_aligned(a) __declspec(align(a))
@@ -19344,8 +19319,6 @@ fi
 if test x"$GCC" = x"yes" ; then
   cc_string=`${CC} --version | sed q`
   case $cc_string in [A-Za-z]*) ;; *) cc_string="GCC $cc_string";; esac
-elif test x"$SUN_STUDIO_CC" = x"yes" ; then
-  cc_string=`${CC} -V 2>&1 | sed q`
 else
   cc_string=$CC
 fi
diff --git a/configure.ac b/configure.ac
index 066e3976c0a..d37e192ff78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -400,14 +400,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifndef 
__INTEL_COMPILER
 choke me
 @%:@endif])], [ICC=yes], [ICC=no])
 
-# Check if it's Sun Studio compiler. We assume that
-# __SUNPRO_C will be defined for Sun Studio compilers
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifndef __SUNPRO_C
-choke me
-@%:@endif])], [SUN_STUDIO_CC=yes], [SUN_STUDIO_CC=no])
-
-AC_SUBST(SUN_STUDIO_CC)
-
 
 #
 # LLVM
@@ -618,7 +610,7 @@ fi
 # __attribute__((visibility("hidden"))) is supported, if we encounter a
 # compiler that supports one of the supported variants of -fvisibility=hidden
 # but uses a different syntax to mark a symbol as exported.
-if test "$GCC" = yes -o "$SUN_STUDIO_CC" = yes ; then
+if test "$GCC" = yes; then
   PGAC_PROG_CC_VAR_OPT(CFLAGS_SL_MODULE, [-fvisibility=hidden])
   # For C++ we additionally want -fvisibility-inlines-hidden
   PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS_SL_MODULE, [-fvisibility=hidden])
@@ -2478,8 +2470,6 @@ AC_SUBST(LDFLAGS_EX_BE)
 if test x"$GCC" = x"yes" ; then
   cc_string=`${CC} --version | sed q`
   case $cc_string in [[A-Za-z]]*) ;; *) cc_string="GCC $cc_string";; esac
-elif test x"$SUN_STUDIO_CC" = x"yes" ; then
-  cc_string=`${CC} -V 2>&1 | sed q`
 else
   cc_string=$CC
 fi
diff --git a/doc/src/sgml/dfunc.sgml b/doc/src/sgml/dfunc.sgml
index b94aefcd0ca..3778efc83eb 100644
--- a/doc/src/sgml/dfunc.sgml
+++ b/doc/src/sgml/dfunc.sgml
@@ -157,19 +157,12 @@ <title>Compiling and Linking Dynamically-Loaded 
Functions</title>
     <listitem>
      <para>
       The compiler flag to create <acronym>PIC</acronym> is
-      <option>-KPIC</option> with the Sun compiler and
       <option>-fPIC</option> with <application>GCC</application>.  To
       link shared libraries, the compiler option is
-      <option>-G</option> with either compiler or alternatively
       <option>-shared</option> with <application>GCC</application>.
 <programlisting>
-cc -KPIC -c foo.c
-cc -G -o foo.so foo.o
-</programlisting>
-      or
-<programlisting>
 gcc -fPIC -c foo.c
-gcc -G -o foo.so foo.o
+gcc -shared -o foo.so foo.o
 </programlisting>
      </para>
     </listitem>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index a4ad80a6782..5310182445d 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1676,10 +1676,6 @@ <title>Developer Options</title>
          using the GCC compiler:
 <screen>
 ./configure CC='gcc -m64' --enable-dtrace DTRACEFLAGS='-64' ...
-</screen>
-         Using Sun's compiler:
-<screen>
-./configure CC='/opt/SUNWspro/bin/cc -xtarget=native64' --enable-dtrace 
DTRACEFLAGS='-64' ...
 </screen>
         </para>
        </listitem>
@@ -3705,7 +3701,7 @@ <title>Solaris</title>
    </indexterm>
 
    <para>
-    PostgreSQL is well-supported on Solaris.  The more up to date your
+    PostgreSQL is supported on Solaris.  The more up to date your
     operating system, the fewer issues you will experience.
    </para>
 
@@ -3713,24 +3709,13 @@ <title>Solaris</title>
     <title>Required Tools</title>
 
     <para>
-     You can build with either GCC or Sun's compiler suite.  For
-     better code optimization, Sun's compiler is strongly recommended
-     on the SPARC architecture.  If
-     you are using Sun's compiler, be careful not to select
-     <filename>/usr/ucb/cc</filename>;
-     use <filename>/opt/SUNWspro/bin/cc</filename>.
+     Only GCC is supported as the compiler.  Sun's compiler suite is no longer
+     supported.
     </para>
 
     <para>
-     You can download Sun Studio
-     from <ulink 
url="https://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/";></ulink>.
-     Many GNU tools are integrated into Solaris 10, or they are
-     present on the Solaris companion CD.  If you need packages for
-     older versions of Solaris, you can find these tools
-     at <ulink url="http://www.sunfreeware.com";></ulink>.
-     If you prefer
-     sources, look
-     at <ulink url="https://www.gnu.org/prep/ftp";></ulink>.
+     Many additional dependencies can be installed via the package management
+     system.
     </para>
    </sect3>
 
@@ -3753,27 +3738,6 @@ <title>configure Complains About a Failed Test 
Program</title>
     </para>
    </sect3>
 
-   <sect3 id="installation-notes-solaris-comp-opt-perf">
-    <title>Compiling for Optimal Performance</title>
-
-    <para>
-     On the SPARC architecture, Sun Studio is strongly recommended for
-     compilation.  Try using the <option>-xO5</option> optimization
-     flag to generate significantly faster binaries.  Do not use any
-     flags that modify behavior of floating-point operations
-     and <varname>errno</varname> processing (e.g.,
-     <option>-fast</option>).
-    </para>
-
-    <para>
-     If you do not have a reason to use 64-bit binaries on SPARC,
-     prefer the 32-bit version.  The 64-bit operations are slower and
-     64-bit binaries are slower than the 32-bit variants.  On the
-     other hand, 32-bit code on the AMD64 CPU family is not native,
-     so 32-bit code is significantly slower on that CPU family.
-    </para>
-   </sect3>
-
    <sect3 id="installation-notes-solaris-using-dtrace">
     <title>Using DTrace for Tracing PostgreSQL</title>
 
@@ -3781,22 +3745,6 @@ <title>Using DTrace for Tracing PostgreSQL</title>
      Yes, using DTrace is possible.  See <xref linkend="dynamic-trace"/> for
      further information.
     </para>
-
-    <para>
-     If you see the linking of the <command>postgres</command> executable 
abort with an
-     error message like:
-<screen>
-Undefined                       first referenced
- symbol                             in file
-AbortTransaction                    utils/probes.o
-CommitTransaction                   utils/probes.o
-ld: fatal: Symbol referencing errors. No output written to postgres
-collect2: ld returned 1 exit status
-make: *** [postgres] Error 1
-</screen>
-     your DTrace installation is too old to handle probes in static
-     functions.  You need Solaris 10u4 or newer to use DTrace.
-    </para>
    </sect3>
   </sect2>
 
diff --git a/meson.build b/meson.build
index ab8101d67b2..d71c7c8267e 100644
--- a/meson.build
+++ b/meson.build
@@ -1809,7 +1809,7 @@ if cc.links('''
   if not meson.is_cross_build()
     r = cc.run('''
     /* This must match the corresponding code in c.h: */
-    #if defined(__GNUC__) || defined(__SUNPRO_C)
+    #if defined(__GNUC__)
     #define pg_attribute_aligned(a) __attribute__((aligned(a)))
     #elif defined(_MSC_VER)
     #define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 8b1b357beaa..ea2b02517b2 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -267,7 +267,6 @@ endif # not PGXS
 
 CC = @CC@
 GCC = @GCC@
-SUN_STUDIO_CC = @SUN_STUDIO_CC@
 CXX = @CXX@
 CFLAGS = @CFLAGS@
 CFLAGS_SL = @CFLAGS_SL@
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 47338d99229..430d154a636 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -34,14 +34,7 @@ endif
 include $(top_srcdir)/src/backend/common.mk
 
 tas.o: tas.s
-ifeq ($(SUN_STUDIO_CC), yes)
-# preprocess assembler file with cpp
-       $(CC) $(CFLAGS) -c -P $<
-       mv $*.i $*_cpp.s
-       $(CC) $(CFLAGS) -c $*_cpp.s -o $@
-else
        $(CC) $(CFLAGS) -c $<
-endif
 
 clean:
        rm -f tas_cpp.s
diff --git a/src/backend/port/tas/sunstudio_sparc.s 
b/src/backend/port/tas/sunstudio_sparc.s
deleted file mode 100644
index 8e0a0965b64..00000000000
--- a/src/backend/port/tas/sunstudio_sparc.s
+++ /dev/null
@@ -1,53 +0,0 @@
-!-------------------------------------------------------------------------
-!
-! sunstudio_sparc.s
-!        compare and swap for Sun Studio on Sparc
-!
-! Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
-! Portions Copyright (c) 1994, Regents of the University of California
-!
-! IDENTIFICATION
-!        src/backend/port/tas/sunstudio_sparc.s
-!
-!-------------------------------------------------------------------------
-
-! Fortunately the Sun compiler can process cpp conditionals with -P
-
-! '/' is the comment for x86, while '!' is the comment for Sparc
-
-#if defined(__sparcv9) || defined(__sparc)
-
-       .section        ".text"
-       .align  8
-       .skip   24
-       .align  4
-
-       .global pg_atomic_cas
-pg_atomic_cas:
-
-       ! "cas" only works on sparcv9 and sparcv8plus chips, and
-       ! requires a compiler targeting these CPUs.  It will fail
-       ! on a compiler targeting sparcv8, and of course will not
-       ! be understood by a sparcv8 CPU.  gcc continues to use
-       ! "ldstub" because it targets sparcv7.
-       !
-       ! There is actually a trick for embedding "cas" in a
-       ! sparcv8-targeted compiler, but it can only be run
-       ! on a sparcv8plus/v9 cpus:
-       !
-       !   
http://cvs.opensolaris.org/source/xref/on/usr/src/lib/libc/sparc/threads/sparc.il
-       !
-       ! NB: We're assuming we're running on a TSO system here - solaris
-       ! userland luckily always has done so.
-
-#if defined(__sparcv9) || defined(__sparcv8plus)
-       cas     [%o0],%o2,%o1
-#else
-       ldstub [%o0],%o1
-#endif
-       mov     %o1,%o0
-       retl
-       nop
-       .type   pg_atomic_cas,2
-       .size   pg_atomic_cas,(.-pg_atomic_cas)
-#endif
diff --git a/src/backend/port/tas/sunstudio_x86.s 
b/src/backend/port/tas/sunstudio_x86.s
deleted file mode 100644
index 0111ffde45c..00000000000
--- a/src/backend/port/tas/sunstudio_x86.s
+++ /dev/null
@@ -1,43 +0,0 @@
-/-------------------------------------------------------------------------
-/
-/ sunstudio_x86.s
-/        compare and swap for Sun Studio on x86
-/
-/ Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
-/ Portions Copyright (c) 1994, Regents of the University of California
-/
-/ IDENTIFICATION
-/        src/backend/port/tas/sunstudio_x86.s
-/
-/-------------------------------------------------------------------------
-
-/ Fortunately the Sun compiler can process cpp conditionals with -P
-
-/ '/' is the comment for x86, while '!' is the comment for Sparc
-
-       .file   "tas.s"
-
-#if defined(__amd64)
-       .code64
-#endif
-
-       .globl pg_atomic_cas
-       .type pg_atomic_cas, @function
-
-       .section .text, "ax"
-       .align 16
-
-pg_atomic_cas:
-#if defined(__amd64)
-       movl       %edx,%eax
-       lock
-       cmpxchgl   %esi,(%rdi)
-#else
-       movl    4(%esp), %edx
-       movl    8(%esp), %ecx
-       movl    12(%esp), %eax
-       lock
-       cmpxchgl %ecx, (%edx)
-#endif
-       ret
-       .size pg_atomic_cas, . - pg_atomic_cas
diff --git a/src/include/c.h b/src/include/c.h
index b580cfa7d31..f303ba0605a 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -114,7 +114,6 @@
  * GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
  * GCC: https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
  * Clang: https://clang.llvm.org/docs/AttributeReference.html
- * Sunpro: https://docs.oracle.com/cd/E18659_01/html/821-1384/gjzke.html
  */
 
 /*
@@ -157,7 +156,7 @@
  */
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
 #define pg_noreturn _Noreturn
-#elif defined(__GNUC__) || defined(__SUNPRO_C)
+#elif defined(__GNUC__)
 #define pg_noreturn __attribute__((noreturn))
 #elif defined(_MSC_VER)
 #define pg_noreturn __declspec(noreturn)
@@ -233,8 +232,8 @@
 #define pg_attribute_printf(f,a)
 #endif
 
-/* GCC and Sunpro support aligned and packed */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+/* GCC supports aligned and packed */
+#if defined(__GNUC__)
 #define pg_attribute_aligned(a) __attribute__((aligned(a)))
 #define pg_attribute_packed() __attribute__((packed))
 #elif defined(_MSC_VER)
@@ -259,8 +258,8 @@
  * choose not to.  But, if possible, don't force inlining in unoptimized
  * debug builds.
  */
-#if (defined(__GNUC__) && defined(__OPTIMIZE__)) || defined(__SUNPRO_C)
-/* GCC and Sunpro support always_inline via __attribute__ */
+#if defined(__GNUC__) && defined(__OPTIMIZE__)
+/* GCC supports always_inline via __attribute__ */
 #define pg_attribute_always_inline __attribute__((always_inline)) inline
 #elif defined(_MSC_VER)
 /* MSVC has a special keyword for this */
@@ -276,8 +275,8 @@
  * for proper cost attribution.  Note that unlike the pg_attribute_XXX macros
  * above, this should be placed before the function's return type and name.
  */
-/* GCC and Sunpro support noinline via __attribute__ */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+/* GCC supports noinline via __attribute__ */
+#if defined(__GNUC__)
 #define pg_noinline __attribute__((noinline))
 /* msvc via declspec */
 #elif defined(_MSC_VER)
diff --git a/src/include/port/atomics.h b/src/include/port/atomics.h
index 074136fe4c4..96f1858da97 100644
--- a/src/include/port/atomics.h
+++ b/src/include/port/atomics.h
@@ -88,8 +88,6 @@
 #include "port/atomics/generic-gcc.h"
 #elif defined(_MSC_VER)
 #include "port/atomics/generic-msvc.h"
-#elif defined(__SUNPRO_C) && !defined(__GNUC__)
-#include "port/atomics/generic-sunpro.h"
 #else
 /* Unknown compiler. */
 #endif
diff --git a/src/include/port/atomics/arch-x86.h 
b/src/include/port/atomics/arch-x86.h
index 8983dd89d53..4ba2ccc0591 100644
--- a/src/include/port/atomics/arch-x86.h
+++ b/src/include/port/atomics/arch-x86.h
@@ -241,6 +241,6 @@ pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 
*ptr, int64 add_)
  */
 #if defined(__i568__) || defined(__i668__) || /* gcc i586+ */  \
        (defined(_M_IX86) && _M_IX86 >= 500) || /* msvc i586+ */ \
-       defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) /* gcc, 
sunpro, msvc */
+       defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) /* gcc, 
msvc */
 #define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY
 #endif /* 8 byte single-copy atomicity */
diff --git a/src/include/port/atomics/generic-sunpro.h 
b/src/include/port/atomics/generic-sunpro.h
deleted file mode 100644
index 09bba0be203..00000000000
--- a/src/include/port/atomics/generic-sunpro.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * generic-sunpro.h
- *       Atomic operations for solaris' CC
- *
- * Portions Copyright (c) 2013-2025, PostgreSQL Global Development Group
- *
- * NOTES:
- *
- * Documentation:
- * * manpage for atomic_cas(3C)
- *   http://www.unix.com/man-page/opensolaris/3c/atomic_cas/
- *   http://docs.oracle.com/cd/E23824_01/html/821-1465/atomic-cas-3c.html
- *
- * src/include/port/atomics/generic-sunpro.h
- *
- * -------------------------------------------------------------------------
- */
-
-#ifdef HAVE_MBARRIER_H
-#include <mbarrier.h>
-
-#define pg_compiler_barrier_impl()     __compiler_barrier()
-
-#ifndef pg_memory_barrier_impl
-/*
- * Despite the name this is actually a full barrier. Expanding to mfence/
- * membar #StoreStore | #LoadStore | #StoreLoad | #LoadLoad on x86/sparc
- * respectively.
- */
-#      define pg_memory_barrier_impl()         __machine_rw_barrier()
-#endif
-#ifndef pg_read_barrier_impl
-#      define pg_read_barrier_impl()           __machine_r_barrier()
-#endif
-#ifndef pg_write_barrier_impl
-#      define pg_write_barrier_impl()          __machine_w_barrier()
-#endif
-
-#endif /* HAVE_MBARRIER_H */
-
-/* Older versions of the compiler don't have atomic.h... */
-#ifdef HAVE_ATOMIC_H
-
-#include <atomic.h>
-
-#define PG_HAVE_ATOMIC_U32_SUPPORT
-typedef struct pg_atomic_uint32
-{
-       volatile uint32 value;
-} pg_atomic_uint32;
-
-#define PG_HAVE_ATOMIC_U64_SUPPORT
-typedef struct pg_atomic_uint64
-{
-       /*
-        * Syntax to enforce variable alignment should be supported by versions
-        * supporting atomic.h, but it's hard to find accurate documentation. If
-        * it proves to be a problem, we'll have to add more version checks for 
64
-        * bit support.
-        */
-       volatile uint64 value pg_attribute_aligned(8);
-} pg_atomic_uint64;
-
-#endif /* HAVE_ATOMIC_H */
-
-
-#ifdef HAVE_ATOMIC_H
-
-#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32
-static inline bool
-pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr,
-                                                                       uint32 
*expected, uint32 newval)
-{
-       bool    ret;
-       uint32  current;
-
-       current = atomic_cas_32(&ptr->value, *expected, newval);
-       ret = current == *expected;
-       *expected = current;
-       return ret;
-}
-
-#define PG_HAVE_ATOMIC_EXCHANGE_U32
-static inline uint32
-pg_atomic_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 newval)
-{
-       return atomic_swap_32(&ptr->value, newval);
-}
-
-#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64
-static inline bool
-pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
-                                                                       uint64 
*expected, uint64 newval)
-{
-       bool    ret;
-       uint64  current;
-
-       AssertPointerAlignment(expected, 8);
-       current = atomic_cas_64(&ptr->value, *expected, newval);
-       ret = current == *expected;
-       *expected = current;
-       return ret;
-}
-
-#define PG_HAVE_ATOMIC_EXCHANGE_U64
-static inline uint64
-pg_atomic_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 newval)
-{
-       return atomic_swap_64(&ptr->value, newval);
-}
-
-#endif /* HAVE_ATOMIC_H */
diff --git a/src/include/port/solaris.h b/src/include/port/solaris.h
index 8ff40007c7f..c352361c81d 100644
--- a/src/include/port/solaris.h
+++ b/src/include/port/solaris.h
@@ -1,26 +1,5 @@
 /* src/include/port/solaris.h */
 
-/*
- * Sort this out for all operating systems some time.  The __xxx
- * symbols are defined on both GCC and Solaris CC, although GCC
- * doesn't document them.  The __xxx__ symbols are only on GCC.
- */
-#if defined(__i386) && !defined(__i386__)
-#define __i386__
-#endif
-
-#if defined(__amd64) && !defined(__amd64__)
-#define __amd64__
-#endif
-
-#if defined(__x86_64) && !defined(__x86_64__)
-#define __x86_64__
-#endif
-
-#if defined(__sparc) && !defined(__sparc__)
-#define __sparc__
-#endif
-
 #if defined(__i386__)
 #include <sys/isa_defs.h>
 #endif
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 2f73f9fcf57..19062128d81 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -333,9 +333,18 @@ tas(volatile slock_t *lock)
        slock_t         _res;
 
        /*
-        *      See comment in src/backend/port/tas/sunstudio_sparc.s for why 
this
-        *      uses "ldstub", and that file uses "cas".  gcc currently 
generates
-        *      sparcv7-targeted binaries, so "cas" use isn't possible.
+        * "cas" only works on sparcv9 and sparcv8plus chips, and requires a
+        * compiler targeting these CPUs.  It will fail on a compiler targeting
+        * sparcv8, and of course will not be understood by a sparcv8 CPU.  gcc
+        * continues to use "ldstub" because it targets sparcv7.
+        *
+        * There is actually a trick for embedding "cas" in a sparcv8-targeted
+        * compiler, but it can only be run on a sparcv8plus/v9 cpus:
+        *
+        *   
http://cvs.opensolaris.org/source/xref/on/usr/src/lib/libc/sparc/threads/sparc.il
+        *
+        * NB: We're assuming we're running on a TSO system here - solaris
+        * userland luckily always has done so.
         */
        __asm__ __volatile__(
                "       ldstub  [%2], %0        \n"
@@ -594,24 +603,6 @@ tas(volatile slock_t *lock)
 
 #if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
 
-/* These are in sunstudio_(sparc|x86).s */
-
-#if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || 
defined(__sparc__) || defined(__sparc))
-#define HAS_TEST_AND_SET
-
-#if defined(__i386) || defined(__x86_64__) || defined(__sparcv9) || 
defined(__sparcv8plus)
-typedef unsigned int slock_t;
-#else
-typedef unsigned char slock_t;
-#endif
-
-extern slock_t pg_atomic_cas(volatile slock_t *lock, slock_t with,
-                                                                         
slock_t cmp);
-
-#define TAS(a) (pg_atomic_cas((a), 1, 0) != 0)
-#endif
-
-
 #ifdef _MSC_VER
 typedef LONG slock_t;
 
diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build
index 54dbc059ada..5fd6ab3804c 100644
--- a/src/makefiles/meson.build
+++ b/src/makefiles/meson.build
@@ -63,8 +63,6 @@ pgxs_kv = {
   'DLSUFFIX': dlsuffix,
   'EXEEXT': exesuffix,
 
-  'SUN_STUDIO_CC': 'no', # not supported so far
-
   # want the chosen option, rather than the library
   'with_ssl' : ssl_library,
   'with_uuid': uuidopt,
diff --git a/src/template/linux b/src/template/linux
index ec3302c4a22..faefe64254a 100644
--- a/src/template/linux
+++ b/src/template/linux
@@ -14,26 +14,3 @@ CFLAGS_SL="-fPIC"
 
 # If --enable-profiling is specified, we need -DLINUX_PROFILE
 PLATFORM_PROFILE_FLAGS="-DLINUX_PROFILE"
-
-if test "$SUN_STUDIO_CC" = "yes" ; then
-  CC="$CC -Xa"                 # relaxed ISO C mode
-  CFLAGS="-v"                  # -v is like gcc -Wall
-  if test "$enable_debug" != yes; then
-    CFLAGS="$CFLAGS -O"                # any optimization breaks debug
-  fi
-
-  # Pick the right test-and-set (TAS) code for the Sun compiler.
-  # We would like to use in-line assembler, but the compiler
-  # requires *.il files to be on every compile line, making
-  # the build system too fragile.
-  case $host_cpu in
-    sparc)
-       need_tas=yes
-       tas_file=sunstudio_sparc.s
-    ;;
-    i?86|x86_64)
-       need_tas=yes
-       tas_file=sunstudio_x86.s
-    ;;
-  esac
-fi
diff --git a/src/template/solaris b/src/template/solaris
index f88b1cdad37..a4d8d38a8f8 100644
--- a/src/template/solaris
+++ b/src/template/solaris
@@ -1,31 +1,4 @@
 # src/template/solaris
 
 # Extra CFLAGS for code that will go into a shared library
-if test "$GCC" = yes ; then
-  CFLAGS_SL="-fPIC"
-else
-  CFLAGS_SL="-KPIC"
-fi
-
-if test "$SUN_STUDIO_CC" = yes ; then
-  CC="$CC -Xa"                 # relaxed ISO C mode
-  CFLAGS="-v"                  # -v is like gcc -Wall
-  if test "$enable_debug" != yes; then
-    CFLAGS="$CFLAGS -O"                # any optimization breaks debug
-  fi
-
-  # Pick the right test-and-set (TAS) code for the Sun compiler.
-  # We would like to use in-line assembler, but the compiler
-  # requires *.il files to be on every compile line, making
-  # the build system too fragile.
-  case $host_cpu in
-    sparc)
-       need_tas=yes
-       tas_file=sunstudio_sparc.s
-    ;;
-    i?86|x86_64)
-       need_tas=yes
-       tas_file=sunstudio_x86.s
-    ;;
-  esac
-fi
+CFLAGS_SL="-fPIC"
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 17138a7569e..d017490a538 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -114,7 +114,6 @@ do
        test "$f" = src/include/port/atomics/generic.h && continue
        test "$f" = src/include/port/atomics/generic-gcc.h && continue
        test "$f" = src/include/port/atomics/generic-msvc.h && continue
-       test "$f" = src/include/port/atomics/generic-sunpro.h && continue
 
        # sepgsql.h depends on headers that aren't there on most platforms.
        test "$f" = contrib/sepgsql/sepgsql.h && continue
-- 
2.51.0

Reply via email to