Skip to content

Commit 79d306c

Browse files
committed
Support for Sun Studio compiler on Linux
This basically takes some build system code that was previously labeled "Solaris" and ties it to the compiler rather than the operating system. Author: Julius Stroffek <[email protected]>
1 parent 3276599 commit 79d306c

File tree

9 files changed

+125
-25
lines changed

9 files changed

+125
-25
lines changed

configure

+52-2
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ CPPFLAGS
686686
ac_ct_CC
687687
EXEEXT
688688
OBJEXT
689+
SUN_STUDIO_CC
689690
CPP
690691
GCC
691692
TAS
@@ -3758,6 +3759,54 @@ fi
37583759

37593760
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
37603761

3762+
# Check if it's Sun Studio compiler. We assume that
3763+
# __SUNPRO_C will be defined for Sun Studio compilers
3764+
cat >conftest.$ac_ext <<_ACEOF
3765+
/* confdefs.h. */
3766+
_ACEOF
3767+
cat confdefs.h >>conftest.$ac_ext
3768+
cat >>conftest.$ac_ext <<_ACEOF
3769+
/* end confdefs.h. */
3770+
3771+
int
3772+
main ()
3773+
{
3774+
#ifndef __SUNPRO_C
3775+
choke me
3776+
#endif
3777+
;
3778+
return 0;
3779+
}
3780+
_ACEOF
3781+
rm -f conftest.$ac_objext
3782+
if { (ac_try="$ac_compile"
3783+
case "(($ac_try" in
3784+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3785+
*) ac_try_echo=$ac_try;;
3786+
esac
3787+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3788+
(eval "$ac_compile") 2>conftest.er1
3789+
ac_status=$?
3790+
grep -v '^ *+' conftest.er1 >conftest.err
3791+
rm -f conftest.er1
3792+
cat conftest.err >&5
3793+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3794+
(exit $ac_status); } && {
3795+
test -z "$ac_c_werror_flag" ||
3796+
test ! -s conftest.err
3797+
} && test -s conftest.$ac_objext; then
3798+
SUN_STUDIO_CC=yes
3799+
else
3800+
echo "$as_me: failed program was:" >&5
3801+
sed 's/^/| /' conftest.$ac_ext >&5
3802+
3803+
SUN_STUDIO_CC=no
3804+
fi
3805+
3806+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3807+
3808+
3809+
37613810
unset CFLAGS
37623811

37633812
#
@@ -26726,6 +26775,7 @@ CPPFLAGS!$CPPFLAGS$ac_delim
2672626775
ac_ct_CC!$ac_ct_CC$ac_delim
2672726776
EXEEXT!$EXEEXT$ac_delim
2672826777
OBJEXT!$OBJEXT$ac_delim
26778+
SUN_STUDIO_CC!$SUN_STUDIO_CC$ac_delim
2672926779
CPP!$CPP$ac_delim
2673026780
GCC!$GCC$ac_delim
2673126781
TAS!$TAS$ac_delim
@@ -26754,7 +26804,6 @@ ELF_SYS!$ELF_SYS$ac_delim
2675426804
LDFLAGS_SL!$LDFLAGS_SL$ac_delim
2675526805
LD!$LD$ac_delim
2675626806
with_gnu_ld!$with_gnu_ld$ac_delim
26757-
ld_R_works!$ld_R_works$ac_delim
2675826807
_ACEOF
2675926808

2676026809
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -26796,6 +26845,7 @@ _ACEOF
2679626845
ac_delim='%!_!# '
2679726846
for ac_last_try in false false false false false :; do
2679826847
cat >conf$$subs.sed <<_ACEOF
26848+
ld_R_works!$ld_R_works$ac_delim
2679926849
RANLIB!$RANLIB$ac_delim
2680026850
STRIP!$STRIP$ac_delim
2680126851
STRIP_STATIC_LIB!$STRIP_STATIC_LIB$ac_delim
@@ -26850,7 +26900,7 @@ vpath_build!$vpath_build$ac_delim
2685026900
LTLIBOBJS!$LTLIBOBJS$ac_delim
2685126901
_ACEOF
2685226902

26853-
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 52; then
26903+
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 53; then
2685426904
break
2685526905
elif $ac_last_try; then
2685626906
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

configure.in

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.568 2008/10/29 09:27:24 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.569 2008/10/29 16:06:46 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -379,6 +379,14 @@ AC_TRY_COMPILE([], [@%:@ifndef __INTEL_COMPILER
379379
choke me
380380
@%:@endif], [ICC=[yes]], [ICC=[no]])
381381

382+
# Check if it's Sun Studio compiler. We assume that
383+
# __SUNPRO_C will be defined for Sun Studio compilers
384+
AC_TRY_COMPILE([], [@%:@ifndef __SUNPRO_C
385+
choke me
386+
@%:@endif], [SUN_STUDIO_CC=yes], [SUN_STUDIO_CC=no])
387+
388+
AC_SUBST(SUN_STUDIO_CC)
389+
382390
unset CFLAGS
383391

384392
#

src/Makefile.global.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.244 2008/10/03 15:35:17 petere Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.245 2008/10/29 16:06:46 petere Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -213,6 +213,7 @@ endif # not PGXS
213213

214214
CC = @CC@
215215
GCC = @GCC@
216+
SUN_STUDIO_CC = @SUN_STUDIO_CC@
216217
CFLAGS = @CFLAGS@
217218

218219
# Kind-of compilers

src/backend/port/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# be converted to Method 2.
1414
#
1515
# IDENTIFICATION
16-
# $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.26 2008/02/19 15:29:58 petere Exp $
16+
# $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.27 2008/10/29 16:06:46 petere Exp $
1717
#
1818
#-------------------------------------------------------------------------
1919

@@ -33,8 +33,8 @@ endif
3333
include $(top_srcdir)/src/backend/common.mk
3434

3535
tas.o: tas.s
36-
ifeq ($(PORTNAME), solaris)
37-
# preprocess assembler file with cpp, used by x86
36+
ifeq ($(SUN_STUDIO_CC), yes)
37+
# preprocess assembler file with cpp
3838
$(CC) $(CFLAGS) -c -P $<
3939
mv $*.i $*_cpp.s
4040
$(CC) $(CFLAGS) -c $*_cpp.s -o $@

src/backend/port/tas/solaris_sparc.s renamed to src/backend/port/tas/sunstudio_sparc.s

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
!=======================================================================
2-
! solaris_sparc.s -- compare and swap for solaris_sparc
3-
!=======================================================================
1+
!-------------------------------------------------------------------------
2+
!
3+
! sunstudio_sparc.s
4+
! compare and swap for Sun Studio on Sparc
5+
!
6+
! Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7+
! Portions Copyright (c) 1994, Regents of the University of California
8+
!
9+
! IDENTIFICATION
10+
! $PostgreSQL: pgsql/src/backend/port/tas/sunstudio_sparc.s,v 1.1 2008/10/29 16:06:47 petere Exp $
11+
!
12+
!-------------------------------------------------------------------------
413

514
! Fortunately the Sun compiler can process cpp conditionals with -P
615

src/backend/port/tas/solaris_x86.s renamed to src/backend/port/tas/sunstudio_x86.s

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
/=======================================================================
2-
/ solaris_i386.s -- compare and swap for solaris_i386
3-
/=======================================================================
1+
/-------------------------------------------------------------------------
2+
/
3+
/ sunstudio_x86.s
4+
/ compare and swap for Sun Studio on x86
5+
/
6+
/ Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7+
/ Portions Copyright (c) 1994, Regents of the University of California
8+
/
9+
/ IDENTIFICATION
10+
/ $PostgreSQL: pgsql/src/backend/port/tas/sunstudio_x86.s,v 1.1 2008/10/29 16:06:47 petere Exp $
11+
/
12+
/-------------------------------------------------------------------------
413

514
/ Fortunately the Sun compiler can process cpp conditionals with -P
615

src/include/storage/s_lock.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6767
* Portions Copyright (c) 1994, Regents of the University of California
6868
*
69-
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.164 2008/01/01 19:45:59 momjian Exp $
69+
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.165 2008/10/29 16:06:47 petere Exp $
7070
*
7171
*-------------------------------------------------------------------------
7272
*/
@@ -578,7 +578,7 @@ typedef unsigned char slock_t;
578578
#endif
579579

580580

581-
#endif /* __GNUC__ */
581+
#endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */
582582

583583

584584

@@ -782,7 +782,7 @@ typedef unsigned char slock_t;
782782
#endif
783783

784784

785-
#if defined(__sun) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
785+
#if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
786786
#define HAS_TEST_AND_SET
787787

788788
#if defined(__i386) || defined(__x86_64__) || defined(__sparcv9) || defined(__sparcv8plus)

src/template/linux

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1-
# $PostgreSQL: pgsql/src/template/linux,v 1.30 2007/09/21 02:33:46 tgl Exp $
1+
# $PostgreSQL: pgsql/src/template/linux,v 1.31 2008/10/29 16:06:47 petere Exp $
22

33
# Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise
44
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
55

66
# If --enable-profiling is specified, we need -DLINUX_PROFILE
77
PLATFORM_PROFILE_FLAGS="-DLINUX_PROFILE"
8+
9+
if test "$SUN_STUDIO_CC" = "yes" ; then
10+
CC="$CC -Xa" # relaxed ISO C mode
11+
CFLAGS="-v" # -v is like gcc -Wall
12+
if test "$enable_debug" != yes; then
13+
CFLAGS="$CFLAGS -O" # any optimization breaks debug
14+
fi
15+
16+
# Pick the right test-and-set (TAS) code for the Sun compiler.
17+
# We would like to use in-line assembler, but the compiler
18+
# requires *.il files to be on every compile line, making
19+
# the build system too fragile.
20+
case $host_cpu in
21+
sparc)
22+
need_tas=yes
23+
tas_file=sunstudio_sparc.s
24+
;;
25+
i?86|x86_64)
26+
need_tas=yes
27+
tas_file=sunstudio_x86.s
28+
;;
29+
esac
30+
fi

src/template/solaris

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
if test "$GCC" != yes ; then
1+
if test "$SUN_STUDIO_CC" = yes ; then
22
CC="$CC -Xa" # relaxed ISO C mode
3-
CFLAGS="-v -DSUNOS4_CC" # -v is like gcc -Wall
3+
CFLAGS="-v" # -v is like gcc -Wall
44
if test "$enable_debug" != yes; then
55
CFLAGS="$CFLAGS -O" # any optimization breaks debug
66
fi
77

88
# Pick the right test-and-set (TAS) code for the Sun compiler.
99
# We would like to use in-line assembler, but the compiler
10-
# requires *.il files to be on every compile line, making
10+
# requires *.il files to be on every compile line, making
1111
# the build system too fragile.
12-
case $host in
13-
sparc-*-solaris*)
12+
case $host_cpu in
13+
sparc)
1414
need_tas=yes
15-
tas_file=solaris_sparc.s
15+
tas_file=sunstudio_sparc.s
1616
;;
17-
i?86-*-solaris*)
17+
i?86|x86_64)
1818
need_tas=yes
19-
tas_file=solaris_x86.s
19+
tas_file=sunstudio_x86.s
2020
;;
2121
esac
2222
fi

0 commit comments

Comments
 (0)