From 826daf1c41d9ad27731127701d50b31b4cac7c1f61afb1da6a82d1014e384652 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 8 Feb 2012 08:17:08 +0000 Subject: [PATCH] Accepting request 101537 from home:-miska- - fixed build for arm - using atomic builtins from gcc - patch taken from upstream mailing list OBS-URL: https://build.opensuse.org/request/show/101537 OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=66 --- postgresql-atomic-builtins.patch | 173 +++++++++++++++++++++++++++++++ postgresql-libs.changes | 7 ++ postgresql-libs.spec | 6 +- postgresql.changes | 7 ++ postgresql.spec | 6 +- postgresql.spec.in | 4 + 6 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 postgresql-atomic-builtins.patch diff --git a/postgresql-atomic-builtins.patch b/postgresql-atomic-builtins.patch new file mode 100644 index 0000000..af91ede --- /dev/null +++ b/postgresql-atomic-builtins.patch @@ -0,0 +1,173 @@ +Description: Use gcc/intel cc builtin atomic operations for test-and-set, if available (http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html). Remove the custom implementation for arm as it does not work with recent hardware (like -mthumb2). +Author: Martin Pitt + +Index: postgresql-9.1-9.1.2/configure.in +=================================================================== +--- postgresql-9.1-9.1.2.orig/configure.in 2011-12-01 22:47:20.000000000 +0100 ++++ postgresql-9.1-9.1.2/configure.in 2011-12-19 16:54:00.619535943 +0100 +@@ -1522,6 +1522,18 @@ + AC_SUBST(LDAP_LIBS_FE) + AC_SUBST(LDAP_LIBS_BE) + ++# gcc and intel compiler provide builtin functions for atomic test-and-set ++AC_MSG_CHECKING([whether the C compiler provides atomic builtins]) ++AC_TRY_LINK([], [int lock = 0; __sync_lock_test_and_set(&lock, 1); __sync_lock_release(&lock);], ++ [have_cc_atomics="yes"], ++ [have_cc_atomics="no"] ++) ++if test "$have_cc_atomics" = yes; then ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_CC_ATOMICS, 1, [Define to 1 if compiler provides atomic builtins]) ++else ++ AC_MSG_RESULT(no) ++fi + + # This test makes sure that run tests work at all. Sometimes a shared + # library is found by the linker, but the runtime linker can't find it. +Index: postgresql-9.1-9.1.2/configure +=================================================================== +--- postgresql-9.1-9.1.2.orig/configure 2011-12-01 22:47:20.000000000 +0100 ++++ postgresql-9.1-9.1.2/configure 2011-12-19 16:54:00.635535943 +0100 +@@ -23602,6 +23602,69 @@ + + + ++# gcc and intel compiler provide builtin functions for atomic test-and-set ++{ $as_echo "$as_me:$LINENO: checking whether the C compiler provides atomic builtins" >&5 ++$as_echo_n "checking whether the C compiler provides atomic builtins... " >&6; } ++cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++int lock = 0; __sync_lock_test_and_set(&lock, 1); __sync_lock_release(&lock); ++ ; ++ return 0; ++} ++_ACEOF ++rm -f conftest.$ac_objext conftest$ac_exeext ++if { (ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" ++$as_echo "$ac_try_echo") >&5 ++ (eval "$ac_link") 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest$ac_exeext && { ++ test "$cross_compiling" = yes || ++ $as_test_x conftest$ac_exeext ++ }; then ++ have_cc_atomics="yes" ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ have_cc_atomics="no" ++ ++fi ++ ++rm -rf conftest.dSYM ++rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ ++ conftest$ac_exeext conftest.$ac_ext ++if test "$have_cc_atomics" = yes; then ++ { $as_echo "$as_me:$LINENO: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++cat >>confdefs.h <<\_ACEOF ++#define HAVE_CC_ATOMICS 1 ++_ACEOF ++ ++else ++ { $as_echo "$as_me:$LINENO: result: no" >&5 ++$as_echo "no" >&6; } ++fi + + # This test makes sure that run tests work at all. Sometimes a shared + # library is found by the linker, but the runtime linker can't find it. +Index: postgresql-9.1-9.1.2/src/include/pg_config.h.in +=================================================================== +--- postgresql-9.1-9.1.2.orig/src/include/pg_config.h.in 2011-12-01 22:47:20.000000000 +0100 ++++ postgresql-9.1-9.1.2/src/include/pg_config.h.in 2011-12-19 16:54:00.639535943 +0100 +@@ -87,6 +87,9 @@ + /* Define to 1 if you have the `cbrt' function. */ + #undef HAVE_CBRT + ++/* Define to 1 if compiler provides atomic builtins */ ++#undef HAVE_CC_ATOMICS ++ + /* Define to 1 if you have the `class' function. */ + #undef HAVE_CLASS + +Index: postgresql-9.1-9.1.2/src/include/storage/s_lock.h +=================================================================== +--- postgresql-9.1-9.1.2.orig/src/include/storage/s_lock.h 2011-12-01 22:47:20.000000000 +0100 ++++ postgresql-9.1-9.1.2/src/include/storage/s_lock.h 2011-12-19 16:56:31.135541667 +0100 +@@ -252,29 +252,6 @@ + #endif /* __ia64__ || __ia64 */ + + +-#if defined(__arm__) || defined(__arm) +-#define HAS_TEST_AND_SET +- +-typedef unsigned char slock_t; +- +-#define TAS(lock) tas(lock) +- +-static __inline__ int +-tas(volatile slock_t *lock) +-{ +- register slock_t _res = 1; +- +- __asm__ __volatile__( +- " swpb %0, %0, [%2] \n" +-: "+r"(_res), "+m"(*lock) +-: "r"(lock) +-: "memory"); +- return (int) _res; +-} +- +-#endif /* __arm__ */ +- +- + /* S/390 and S/390x Linux (32- and 64-bit zSeries) */ + #if defined(__s390__) || defined(__s390x__) + #define HAS_TEST_AND_SET +@@ -859,6 +836,24 @@ + + #endif /* !defined(HAS_TEST_AND_SET) */ + ++/************************************************************************* ++ * Use compiler provided atomic builtins if available (in particular, gcc and ++ * Intel provide them for many platforms). ++ */ ++#if !defined(HAS_TEST_AND_SET) && HAVE_CC_ATOMICS ++#define HAS_TEST_AND_SET ++typedef int slock_t; ++ ++#define TAS(lock) tas(lock) ++#define S_UNLOCK(lock) __sync_lock_release(lock) ++ ++static __inline__ int ++tas(volatile slock_t *lock) ++{ ++ return __sync_lock_test_and_set (lock, 1); ++} ++#endif ++ + + /* Blow up if we didn't have any way to do spinlocks */ + #ifndef HAS_TEST_AND_SET diff --git a/postgresql-libs.changes b/postgresql-libs.changes index b34d028..fe6eba5 100644 --- a/postgresql-libs.changes +++ b/postgresql-libs.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 25 17:36:50 CET 2012 - mhrusecky@suse.cz + +- fixed build for arm + - using atomic builtins from gcc + - patch taken from upstream mailing list + ------------------------------------------------------------------- Fri Dec 9 17:37:40 UTC 2011 - darin@darins.net diff --git a/postgresql-libs.spec b/postgresql-libs.spec index 5490a12..1b2e320 100644 --- a/postgresql-libs.spec +++ b/postgresql-libs.spec @@ -1,7 +1,7 @@ # # spec file for package postgresql-libs # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -53,6 +53,7 @@ Patch1: postgresql-conf.patch Patch2: postgresql-regress.patch Patch3: postgresql-sle10-timestamptz.patch Patch4: postgresql-plperl.patch +Patch5: postgresql-atomic-builtins.patch Url: http://www.postgresql.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-build Provides: postgresql = %pg_minor_version @@ -166,6 +167,9 @@ touch -r configure tmp %patch3 -p1 %endif %patch4 +%ifarch %arm +%patch5 -p1 +%endif touch -r tmp configure rm tmp diff --git a/postgresql.changes b/postgresql.changes index b34d028..fe6eba5 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 25 17:36:50 CET 2012 - mhrusecky@suse.cz + +- fixed build for arm + - using atomic builtins from gcc + - patch taken from upstream mailing list + ------------------------------------------------------------------- Fri Dec 9 17:37:40 UTC 2011 - darin@darins.net diff --git a/postgresql.spec b/postgresql.spec index e7503b3..d885b8c 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -1,7 +1,7 @@ # # spec file for package postgresql # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -60,6 +60,7 @@ Patch1: postgresql-conf.patch Patch2: postgresql-regress.patch Patch3: postgresql-sle10-timestamptz.patch Patch4: postgresql-plperl.patch +Patch5: postgresql-atomic-builtins.patch Url: http://www.postgresql.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-build Provides: postgresql = %pg_minor_version @@ -288,6 +289,9 @@ touch -r configure tmp %patch3 -p1 %endif %patch4 +%ifarch %arm +%patch5 -p1 +%endif touch -r tmp configure rm tmp diff --git a/postgresql.spec.in b/postgresql.spec.in index 2bfb083..ac919e4 100644 --- a/postgresql.spec.in +++ b/postgresql.spec.in @@ -61,6 +61,7 @@ Patch1: postgresql-conf.patch Patch2: postgresql-regress.patch Patch3: postgresql-sle10-timestamptz.patch Patch4: postgresql-plperl.patch +Patch5: postgresql-atomic-builtins.patch Url: http://www.postgresql.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-build Provides: postgresql = %pg_minor_version @@ -290,6 +291,9 @@ touch -r configure tmp %patch3 -p1 %endif %patch4 +%ifarch %arm +%patch5 -p1 +%endif touch -r tmp configure rm tmp