Thread: 8.0.0beta2: gcc: unrecognized option `-pthreads'

8.0.0beta2: gcc: unrecognized option `-pthreads'

From
"Ed L."
Date:
Is this pthreads warning of any concern?

gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations -pthread -pthreads  -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS -fpic -shared -Wl,-soname,libecpg.so.4 execute.o
typename.o descriptor.o data.o error.o prepare.o memory.o connect.o misc.o
path.o exec.o -L../../../../src/port -L../pgtypeslib -lpgtypes
-L../../../../src/interfaces/libpq -lpq -lcrypt -lm -lpthread
-Wl,-rpath,/opt/pgsql/installs/postgresql-8.0.0beta2/lib -o libecpg.so.4.2
gcc: unrecognized option `-pthreads'

Ed


Re: 8.0.0beta2: gcc: unrecognized option `-pthreads'

From
Bruce Momjian
Date:
Ed L. wrote:
> Is this pthreads warning of any concern?
>
> gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
> -Wmissing-declarations -pthread -pthreads  -D_REENTRANT -D_THREAD_SAFE
> -D_POSIX_PTHREAD_SEMANTICS -fpic -shared -Wl,-soname,libecpg.so.4 execute.o
> typename.o descriptor.o data.o error.o prepare.o memory.o connect.o misc.o
> path.o exec.o -L../../../../src/port -L../pgtypeslib -lpgtypes
> -L../../../../src/interfaces/libpq -lpq -lcrypt -lm -lpthread
> -Wl,-rpath,/opt/pgsql/installs/postgresql-8.0.0beta2/lib -o libecpg.so.4.2
> gcc: unrecognized option `-pthreads'

No.  The problem is that the test script just tries all options and if
it doesn't error out, it uses it.  Ideally we could test from configure
and ingnore meaningless options but we don't know how yet.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: 8.0.0beta2: gcc: unrecognized option `-pthreads'

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> No.  The problem is that the test script just tries all options and if
> it doesn't error out, it uses it.  Ideally we could test from configure
> and ingnore meaningless options but we don't know how yet.

Drop any options that cause the compiler to write anything on stderr.

            regards, tom lane

Re: 8.0.0beta2: gcc: unrecognized option `-pthreads'

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > No.  The problem is that the test script just tries all options and if
> > it doesn't error out, it uses it.  Ideally we could test from configure
> > and ingnore meaningless options but we don't know how yet.
>
> Drop any options that cause the compiler to write anything on stderr.

OK, the configure test is:

        AC_TRY_LINK([#include <pthread.h>],
                    [pthread_t th; pthread_join(th, 0);
                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
                    [acx_pthread_ok=yes], [acx_pthread_ok=no])

Seems we can't just jump in there and grab stderr so I added the
following code to CVS which should do the trick.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.391
diff -c -c -r1.391 configure
*** configure    10 Sep 2004 13:53:39 -0000    1.391
--- configure    10 Sep 2004 23:55:53 -0000
***************
*** 13325,13342 ****
  fi
  rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

          LIBS="$save_LIBS"
          CFLAGS="$save_CFLAGS"

          echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
  echo "${ECHO_T}$acx_pthread_ok" >&6
-         if test "x$acx_pthread_ok" = xyes; then
-             # we continue with more flags because Linux needs -lpthread
-             # for libpq builds on PostgreSQL.  The test above only
-             # tests for building binaries, not shared libraries.
-             PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
-             PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
-         fi
  done
  fi

--- 13325,13356 ----
  fi
  rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

+         if test "x$acx_pthread_ok" = xyes; then
+             # Don't use options that are ignored by the compiler.
+             # We find them by checking stderror.
+             cat >conftest.$ac_ext <<_ACEOF
+ int
+ main ()
+ {
+   return 0;
+ }
+ _ACEOF
+             rm -f conftest.$ac_objext conftest$ac_exeext
+             if test "`(eval $ac_link 2>&1 >/dev/null)`" = ""; then
+                 # we continue with more flags because Linux needs -lpthread
+                 # for libpq builds on PostgreSQL.  The test above only
+                 # tests for building binaries, not shared libraries.
+                 PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
+                 PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
+             else   acx_pthread_ok=no
+             fi
+         fi
+
          LIBS="$save_LIBS"
          CFLAGS="$save_CFLAGS"

          echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
  echo "${ECHO_T}$acx_pthread_ok" >&6
  done
  fi

Index: config/acx_pthread.m4
===================================================================
RCS file: /cvsroot/pgsql-server/config/acx_pthread.m4,v
retrieving revision 1.6
diff -c -c -r1.6 acx_pthread.m4
*** config/acx_pthread.m4    17 Aug 2004 15:19:09 -0000    1.6
--- config/acx_pthread.m4    10 Sep 2004 23:55:54 -0000
***************
*** 129,145 ****
                       pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
                      [acx_pthread_ok=yes], [acx_pthread_ok=no])

          LIBS="$save_LIBS"
          CFLAGS="$save_CFLAGS"

          AC_MSG_RESULT($acx_pthread_ok)
-         if test "x$acx_pthread_ok" = xyes; then
-             # we continue with more flags because Linux needs -lpthread
-             # for libpq builds on PostgreSQL.  The test above only
-             # tests for building binaries, not shared libraries.
-             PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
-             PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
-         fi
  done
  fi

--- 129,159 ----
                       pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
                      [acx_pthread_ok=yes], [acx_pthread_ok=no])

+         if test "x$acx_pthread_ok" = xyes; then
+             # Don't use options that are ignored by the compiler.
+             # We find them by checking stderror.
+             cat >conftest.$ac_ext <<_ACEOF
+ int
+ main ()
+ {
+   return 0;
+ }
+ _ACEOF
+             rm -f conftest.$ac_objext conftest$ac_exeext
+             if test "`(eval $ac_link 2>&1 >/dev/null)`" = ""; then
+                 # we continue with more flags because Linux needs -lpthread
+                 # for libpq builds on PostgreSQL.  The test above only
+                 # tests for building binaries, not shared libraries.
+                 PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
+                 PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
+             else   acx_pthread_ok=no
+             fi
+         fi
+
          LIBS="$save_LIBS"
          CFLAGS="$save_CFLAGS"

          AC_MSG_RESULT($acx_pthread_ok)
  done
  fi


Re: 8.0.0beta2: gcc: unrecognized option `-pthreads'

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>>> No.  The problem is that the test script just tries all options and if
>>> it doesn't error out, it uses it.  Ideally we could test from configure
>>> and ingnore meaningless options but we don't know how yet.
>>
>> Drop any options that cause the compiler to write anything on stderr.

> OK, the configure test is:

BTW, I had some second thoughts about this later: if the compiler
generates warnings only for certain *combinations* of switches, it
seems likely that a simplistic test would get things wrong.  Let's
try this patch, but be alert for possible problems.

            regards, tom lane

Re: 8.0.0beta2: gcc: unrecognized option `-pthreads'

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >>> No.  The problem is that the test script just tries all options and if
> >>> it doesn't error out, it uses it.  Ideally we could test from configure
> >>> and ingnore meaningless options but we don't know how yet.
> >>
> >> Drop any options that cause the compiler to write anything on stderr.
>
> > OK, the configure test is:
>
> BTW, I had some second thoughts about this later: if the compiler
> generates warnings only for certain *combinations* of switches, it
> seems likely that a simplistic test would get things wrong.  Let's
> try this patch, but be alert for possible problems.

Ah, but we test the accumulation of flags, not just each flag in
isolation:

        LIBS="$tryPTHREAD_LIBS $PTHREAD_LIBS $LIBS"
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"

so we should be fine.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073