Re: [PATCHES] Sun Studio on Linux spinlock patch

2008-04-24 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes:
> So, is this a feature we want?

I have no objection to being able to use Sun Studio, but the submitted
patch seemed to need a lot of work yet ...

regards, tom lane

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Sun Studio on Linux spinlock patch

2008-04-24 Thread Bruce Momjian

So, is this a feature we want?

---

Julius Stroffek wrote:
> Tom Lane wrote:
> > This patch seems broken in a number of ways.  Why are you removing
> > -DLINUX_PROFILE, for example?  Are you sure you don't need -D_GNU_SOURCE?
> > And why add -DSUNOS4_CC, which is a Solaris-specific define (not that
> > we seem to be using it anywhere anymore)?  Do we really have to have a
> > configure-time probe to detect this particular compiler?
> >   
> You are right, removing -DLINUX_PROFILE seems to break profiling
> on linux when compiled with sun studio.
> 
> I am not quite sure about the desired usage of _GNU_SOURCE and SUNOS4_CC 
> macros.
> I would not expect _GNU_SOURCE to be defined when compiling sources with 
> Sun Studio.
> I am not quite sure why SUNOS4_CC was supposed to be defined at all for 
> Solaris as well.
> There are already enough macros defined -- "__sun" is defined on Solaris 
> by both Sun
> Studio and gcc and "__SUNPRO_C" is defined by Sun Studio on both Linux 
> and Solaris.
> 
> Should we then remove _GNU_SOURCE and SUNOS4_CC macro definitions from
> the build scripts since they are not used at all in the source code?
> 
> Configure-time probe for sun studio is required to create tas.s link to 
> the proper
> file - sunstudio_x86.s (or sunstudio_sparc.s). This is done during a run 
> of a configure
> script based on settings for the platform. Since these settings may vary 
> on the same platform
> based on the compiler we need to have a configure-time probe.
> > But I guess the *real* question is why anyone would care ... what
> > benefit is there to using Sun's compiler on Linux?
> >   
> Some tools bundled with sun studio might be used. I personally run into this
> when I wanted to debug postgres with sun studio ide and wanted to compile
> it first. It is based on netbeans, written in java so it needs a big 
> enough memory,
> however it offers a great possibility to explore postgres internals during
> a query execution, etc. It is especially useful, if you do not know what 
> you are
> interested in during a compilation. I am using this to step over join 
> order search
> plugins. I mostly use Solaris for this but I switched to linux for a while.
> 
> I wrote a blog with more details about this.
> http://blogs.sun.com/databases/entry/debugging_postgresql_backends_on_solaris
> There is also a screenshot showing how it looks in action
> http://mediacast.sun.com/users/%7Ejulo/media/pgss_debugging.png
> 
> Also, there was some message a while back on pgsql-bugs from Len Zaifman 
> requesting
> this as well.
> 
> Cheers
> 
> Julo
> 
> -- 
> Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-patches

-- 
  Bruce Momjian  <[EMAIL PROTECTED]>http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Sun Studio on Linux spinlock patch

2008-03-10 Thread Julius Stroffek

Tom Lane wrote:

This patch seems broken in a number of ways.  Why are you removing
-DLINUX_PROFILE, for example?  Are you sure you don't need -D_GNU_SOURCE?
And why add -DSUNOS4_CC, which is a Solaris-specific define (not that
we seem to be using it anywhere anymore)?  Do we really have to have a
configure-time probe to detect this particular compiler?
  

You are right, removing -DLINUX_PROFILE seems to break profiling
on linux when compiled with sun studio.

I am not quite sure about the desired usage of _GNU_SOURCE and SUNOS4_CC 
macros.
I would not expect _GNU_SOURCE to be defined when compiling sources with 
Sun Studio.
I am not quite sure why SUNOS4_CC was supposed to be defined at all for 
Solaris as well.
There are already enough macros defined -- "__sun" is defined on Solaris 
by both Sun
Studio and gcc and "__SUNPRO_C" is defined by Sun Studio on both Linux 
and Solaris.


Should we then remove _GNU_SOURCE and SUNOS4_CC macro definitions from
the build scripts since they are not used at all in the source code?

Configure-time probe for sun studio is required to create tas.s link to 
the proper
file - sunstudio_x86.s (or sunstudio_sparc.s). This is done during a run 
of a configure
script based on settings for the platform. Since these settings may vary 
on the same platform

based on the compiler we need to have a configure-time probe.

But I guess the *real* question is why anyone would care ... what
benefit is there to using Sun's compiler on Linux?
  

Some tools bundled with sun studio might be used. I personally run into this
when I wanted to debug postgres with sun studio ide and wanted to compile
it first. It is based on netbeans, written in java so it needs a big 
enough memory,

however it offers a great possibility to explore postgres internals during
a query execution, etc. It is especially useful, if you do not know what 
you are
interested in during a compilation. I am using this to step over join 
order search

plugins. I mostly use Solaris for this but I switched to linux for a while.

I wrote a blog with more details about this.
http://blogs.sun.com/databases/entry/debugging_postgresql_backends_on_solaris
There is also a screenshot showing how it looks in action
http://mediacast.sun.com/users/%7Ejulo/media/pgss_debugging.png

Also, there was some message a while back on pgsql-bugs from Len Zaifman 
requesting

this as well.

Cheers

Julo

--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Sun Studio on Linux spinlock patch

2008-03-05 Thread Zdenek Kotala

Tom Lane napsal(a):



But I guess the *real* question is why anyone would care ... what
benefit is there to using Sun's compiler on Linux?


There are severals benefits:

1) Sun Studio is not only compiler. It has a lot of tools like 
performance analyzer/profiler, memory checker ... There are group of 
people who prefers these tools.


2) Compiler generates faster code on SPARC than GCC. If somebody uses 
Linux on SPARC it helps him a lot. Code is faster on x86 as well, but it 
is not so significant.


See http://blogs.sun.com/tatkar/resource/SunStudio.pdf
Pages 12-13


Zdenek



--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-patches


Re: [PATCHES] Sun Studio on Linux spinlock patch

2008-03-05 Thread Tom Lane
Julius Stroffek <[EMAIL PROTECTED]> writes:
> I have made PostgreSQL to compile on linux using sun studio with 
> spinlock support. The patch is attached. Here is the explanation of 
> changes I made:

This patch seems broken in a number of ways.  Why are you removing
-DLINUX_PROFILE, for example?  Are you sure you don't need -D_GNU_SOURCE?
And why add -DSUNOS4_CC, which is a Solaris-specific define (not that
we seem to be using it anywhere anymore)?  Do we really have to have a
configure-time probe to detect this particular compiler?

But I guess the *real* question is why anyone would care ... what
benefit is there to using Sun's compiler on Linux?

regards, tom lane

--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-patches


[PATCHES] Sun Studio on Linux spinlock patch

2008-03-05 Thread Julius Stroffek

Hi All,

I have made PostgreSQL to compile on linux using sun studio with 
spinlock support. The patch is attached. Here is the explanation of 
changes I made:


I renamed the following files
solaris_x86.s
solaris_sparch.s

to
sunstudio_x86.s
sunstudio_sparch.s

because the code is used on linux as well and is not related to solaris 
but sunstudio.


I added the detection of Sun Studio to configure script, changed the 
template for linux, so it gives same settings for sun studio as for solaris.


Finally, I changed the #ifdef of __sun macro to __SUNPRO_C macro in 
s_lock.h. Macro __sun is defined on solaris by both gcc and sun studio 
and it is not defined on linux. Macro __SUNPRO_C is defined on linux as 
well as solaris by sun studio and is never defined by gcc.


I tested the patch (build process & make check) without any problems on:
x86, solaris nevada build 79; gcc 3.4.3 (csl-sol210-3_4-20050802)
x86, solaris nevada build 79; sun studio 12
x86, debian etch, gcc 4.1.2 (20061115)
x86, debian etch, sun studio 12
sparc, solaris 10U3, gcc 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
sparc, solaris 10U3, sun studio 12

I do not have an access to linux sparc machine.

Thanks for your comments.

Cheers

Julo
Index: configure
--- configure
+++ configure
@@ -682,6 +682,7 @@
 ac_ct_CC
 EXEEXT
 OBJEXT
+SSCC
 CPP
 GCC
 TAS
@@ -3353,6 +3354,54 @@
 
 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 >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __SUNPRO_C
+choke me
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+   } && test -s conftest.$ac_objext; then
+  SSCC=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	SSCC=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+
 unset CFLAGS
 
 #
@@ -25545,6 +25594,7 @@
 ac_ct_CC!$ac_ct_CC$ac_delim
 EXEEXT!$EXEEXT$ac_delim
 OBJEXT!$OBJEXT$ac_delim
+SSCC!$SSCC$ac_delim
 CPP!$CPP$ac_delim
 GCC!$GCC$ac_delim
 TAS!$TAS$ac_delim
@@ -25577,7 +25627,6 @@
 RANLIB!$RANLIB$ac_delim
 STRIP!$STRIP$ac_delim
 STRIP_STATIC_LIB!$STRIP_STATIC_LIB$ac_delim
-STRIP_SHARED_LIB!$STRIP_SHARED_LIB$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -25619,6 +25668,7 @@
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+STRIP_SHARED_LIB!$STRIP_SHARED_LIB$ac_delim
 TAR!$TAR$ac_delim
 LN_S!$LN_S$ac_delim
 AWK!$AWK$ac_delim
@@ -25669,7 +25719,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 48; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 49; then
 break
   elif $ac_last_try; then
 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
Index: configure.in
--- configure.in
+++ configure.in
@@ -241,6 +241,14 @@
 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_TRY_COMPILE([], [EMAIL PROTECTED]:@ifndef __SUNPRO_C
+choke me
[EMAIL PROTECTED]:@endif], [SSCC=[yes]], [SSCC=[no]])
+
+AC_SUBST(SSCC)
+
 unset CFLAGS
 
 #
Index: src/Makefile.global.in
--- src/Makefile.global.in
+++ src/Makefile.global.in
@@ -304,6 +304,7 @@
 
 # Name of the "template"
 PORTNAME= @PORTNAME@
+SUN_STUDIO_COMPILER = @SSCC@
 
 host_tuple = @host@
 host_os = @host_os@
Index: src/backend/port/Makefile
--- src/backend/port/Makefile
+++ src/backend/port/Makefile
@@ -33,12 +33,14 @@
 include $(top_srcdir)/src/backend/common.mk
 
 tas.o: tas.s
-ifeq ($(PORTNAME), solaris)
+ifeq ($(SUN_STUDIO_COMPILER), yes)
 # preprocess assembler file with cpp, used by x86
+	echo YES.
 	$(CC) $(CFLAGS) -c -P $<
 	mv $*.i $*_cpp.s
 	$(CC) $(CFLAGS) -c $*_cpp.s -o $@
 else
+	echo NO.
 	$(CC) $(CFLAGS) -c $<
 endif
 
Index: src/backend/port/tas/solaris_sparc.s
--- src/backend/port/tas/solaris_sparc.s
+++ src/backend/port/tas/solaris_sparc.s
@@ -1,42 +0,0 @@
-!===
-! solaris_sparc.s -- compare and swap for solaris_sparc
-!===
-
-! Fortunately the Sun compiler can process cpp conditionals with -P
-
-! '/' is th