Thread: State of the QNX Port

State of the QNX Port

From
"Tegge, Bernd"
Date:
Andreas Kardos has left for greener pastures, so for now I'm stuck with
maintaining postgres on QNX4. I have some 10+ years of experience with QNX
but I know little about DBMS (including postgres).

I have tried to build the postgresql-7.1beta5 on QNX4.25. I have succeeded
in getting it to compile and link. However, during 'make check' the
postmaster enters a never ending loop. Beta4 fails with "IpcSemaphoreCreate:
semget : Invalid argument". I will look into this problem over
the weekend. So far here is the list of obstacles encountered :


* config/prep_buildtree :
   * caused configure to exit, because the QNX shell may or may not return
     an exit code of 0 if a script just ends without an exit statement.
     added an 'exit 0' as last line
   * the script  called from configure replaced all Makefiles with
     symlinks to themselves. This is because configure notices a difference
     between $abs_top_builddir and $abs_top_srcdir. However they are the
     same; the former just contains a net absolute path (i.e. has a
     //<node> prefix ). This might also happen if the path contains a
     symlink that is being resolved in one of the variables.
     probably QNX specific
--- prep_buildtree.org  Wed Feb 28 22:02:04 2001
+++ prep_buildtree      Wed Feb 28 22:26:01 2001
@@ -19,16 +19,26 @@

  buildtree=${2:-'.'}

+# check if $buildtree is an alias of $sourcetree
+rm -f $buildtree/$$
+touch $sourcetree/$$
+if test -f $buildtree/$$ ; then
+  rm -f $sourcetree/$$
+  exit 0
+fi
+exit 0
  for item in `find "$sourcetree" -type d \( -name CVS -prune -o -print \)`; do
      subdir=`expr "$item" : "$sourcetree\(.*\)"`
      if test ! -d "$buildtree/$subdir"; then
-        mkdir -p "$buildtree/$subdir" || exit
+        mkdir -p "$buildtree/$subdir" || exit 1
      fi
  done

  for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
      subdir=`expr "$item" : "$sourcetree\(.*\)"`
      if test ! -f "${item}.in"; then
-        ln -fs "$item" "$buildtree/$subdir" || exit
+        ln -fs "$item" "$buildtree/$subdir" || exit 1
      fi
  done
+exit 0

* The shell command for remove-old-headers in ~/src/include/Makefile gave a
   syntax error, because of a missing semicolon:

--- Makefile    Wed Feb 28 20:33:33 2001
+++ Makefile.bck        Wed Feb 28 20:33:33 2001
@@ -78,7 +78,7 @@
                         : ; \
                 else \
                         rm -f $(DESTDIR)$(includedir)/$$file; \
-               fi ; \
+               fi \
         done

* missing -lz in ~/src/bin/pg_dump/Makefile for pg_dump and pg_restore.
   pg_dump and pg_restore make calls into the zlib, but have no -lz in the
   link command.

--- Makefile.org        Wed Feb 28 22:28:49 2001
+++ Makefile    Wed Feb 28 22:15:21 2001
@@ -21,10 +21,10 @@
  all: submake pg_dump pg_restore pg_dumpall

  pg_dump: pg_dump.o common.o $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) pg_dump.o common.o $(OBJS) $(libpq) $(LDFLAGS)
$(LIBS) -
o $@
+       $(CC) $(CFLAGS) pg_dump.o common.o $(OBJS) $(libpq) $(LDFLAGS)
$(LIBS) -
lz -o $@

  pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
+       $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -lz -o
$@

  ../../utils/strdup.o:
         $(MAKE) -C ../../utils strdup.o

Changes :

- replacement ~/src/backend/port/dynloader/qnx4.h
   (clashed with the new fmgr code )

--
Bernd Tegge                  mailto:tegge@repas-aeg.de
Tel: ++49-511-87449-12       repas AEG Automation GmbH
Fax: ++49-511-87449-20       GS Hannover, Germany
/*-------------------------------------------------------------------------
 *
 * dynloader.h
 *      dynamic loader for QNX4 using the shared library mechanism
 *
 * Copyright (c) 1999,2001, repas AEG Automation GmbH
 *
 *
 * IDENTIFICATION
 *      $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/dynloader/qnx4.h,v 1.2 2000/05/28 17:56:02 tgl Exp
$
 *
 *    NOTES
 *
 *-------------------------------------------------------------------------
 */
/* System includes */
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H

#include "utils/dynamic_loader.h"

#endif

Re: State of the QNX Port

From
Peter Eisentraut
Date:
Tegge, Bernd writes:

> * config/prep_buildtree :
>    * caused configure to exit, because the QNX shell may or may not return
>      an exit code of 0 if a script just ends without an exit statement.
>      added an 'exit 0' as last line

Okay.

>    * the script  called from configure replaced all Makefiles with
>      symlinks to themselves. This is because configure notices a difference
>      between $abs_top_builddir and $abs_top_srcdir. However they are the
>      same; the former just contains a net absolute path (i.e. has a
>      //<node> prefix ). This might also happen if the path contains a
>      symlink that is being resolved in one of the variables.
>      probably QNX specific

I'm not sure I believe that.  We have

abs_top_srcdir=`cd $srcdir && pwd`
abs_top_builddir=`pwd`

($srcdir should be '.' in most cases.)  prep_buildtree is called only if
those are different.  This should not happen unless your pwd program has a
behaviour I've never heard of.  Please investigate.

> * The shell command for remove-old-headers in ~/src/include/Makefile gave a
>    syntax error, because of a missing semicolon:

Okay.

> * missing -lz in ~/src/bin/pg_dump/Makefile for pg_dump and pg_restore.
>    pg_dump and pg_restore make calls into the zlib, but have no -lz in the
>    link command.

-lz should be found by configure and should be in the LIBS variable.
Look for lines

checking for zlib.h... yes
checking for inflate in -lz... yes

when configuring.  As you seemingly do have libz installed, maybe you
could check in config.log why they're not found.

> - replacement ~/src/backend/port/dynloader/qnx4.h
>    (clashed with the new fmgr code )

Can you explain the nature of the "clash"?  I don't follow your change
offhand.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: State of the QNX Port

From
"Tegge, Bernd"
Date:
Am 17:24 01.03.01 +0100 schrieb Peter Eisentraut:
>Tegge, Bernd writes:
>
> > * config/prep_buildtree :
> >    * caused configure to exit, because the QNX shell may or may not return
> >      an exit code of 0 if a script just ends without an exit statement.
> >      added an 'exit 0' as last line
>
>Okay.
>
> >    * the script  called from configure replaced all Makefiles with
> >      symlinks to themselves. This is because configure notices a difference
> >      between $abs_top_builddir and $abs_top_srcdir. However they are the
> >      same; the former just contains a net absolute path (i.e. has a
> >      //<node> prefix ). This might also happen if the path contains a
> >      symlink that is being resolved in one of the variables.
> >      probably QNX specific
>
>I'm not sure I believe that.  We have
>
>abs_top_srcdir=`cd $srcdir && pwd`
>abs_top_builddir=`pwd`
>
>($srcdir should be '.' in most cases.)  prep_buildtree is called only if
>those are different.  This should not happen unless your pwd program has a
>behaviour I've never heard of.  Please investigate.

Believe it :-) I put a 'set -x' in front of the comparison and saw the
difference. Here are the relevant parts from configure:

repas@qnx4[7]:ttypd$ pwd
/CVStrees/pgsql
repas@qnx4[7]:ttypd$ ./configure
+ test -z
+ ac_srcdir_defaulted=yes
+ ac_prog=//7/part2/CVStrees/pgsql/configure
+ print //7/part2/CVStrees/pgsql/configure
+ sed s%/[^/][^/]*$%%
+ ac_confdir=//7/part2/CVStrees/pgsql
+ test x//7/part2/CVStrees/pgsql = x//7/part2/CVStrees/pgsql/configure
+ srcdir=//7/part2/CVStrees/pgsql
+ test ! -r //7/part2/CVStrees/pgsql/src/backend/access/common/heaptuple.c
+ test ! -r //7/part2/CVStrees/pgsql/src/backend/access/common/heaptuple.c
+ print //7/part2/CVStrees/pgsql
+ sed s%\([^/]\)/*$%\1%
+ srcdir=//7/part2/CVStrees/pgsql
+ set +x
loading cache ./config.cache
...
checking for nsgmls... no
+ test x//7/part2/CVStrees/pgsql != x/CVStrees/pgsql
+ print preparing build tree... \c
preparing build tree... + /bin/sh
//7/part2/CVStrees/pgsql/config/prep_buildtree
  //7/part2/CVStrees/pgsql /CVStrees/pgsql
+ print done
done
+ set +x




> > * The shell command for remove-old-headers in ~/src/include/Makefile gave a
> >    syntax error, because of a missing semicolon:
>
>Okay.
>
> > * missing -lz in ~/src/bin/pg_dump/Makefile for pg_dump and pg_restore.
> >    pg_dump and pg_restore make calls into the zlib, but have no -lz in the
> >    link command.
>
>-lz should be found by configure and should be in the LIBS variable.
>Look for lines
>
>checking for zlib.h... yes
>checking for inflate in -lz... yes
>
>when configuring.  As you seemingly do have libz installed, maybe you
>could check in config.log why they're not found.

They *are* found. I see the above lines when configure runs. config.log
shows no errors for zlib.h and inflate. I still get link errors if I don't
add '-lz' manually. Should I put it in '~src/makefiles/Makefile.qnx4' ?

> > - replacement ~/src/backend/port/dynloader/qnx4.h
> >    (clashed with the new fmgr code )
>
>Can you explain the nature of the "clash"?  I don't follow your change
>offhand.

Well, the contents of the previous version were practically identical to
dynamic_loader.h, except that fmgr.h was not included before the function
declarations. That led to compile errors in dfmgr.c and fmgr.c because
PGFunction was not declared.


>--
>Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: State of the QNX Port

From
Peter Eisentraut
Date:
Tegge, Bernd writes:

> >abs_top_srcdir=`cd $srcdir && pwd`
> >abs_top_builddir=`pwd`

> + test x//7/part2/CVStrees/pgsql != x/CVStrees/pgsql

Hmm, I don't understand the semantics of the //# specification, but in
your case the failure could probably be worked around if you ran configure
like this: './configure', instead of the full absolute path.  There are
other places that rely on the textual equality of these two variables, and
they're a bit harder to fix.

> They *are* found. I see the above lines when configure runs. config.log
> shows no errors for zlib.h and inflate. I still get link errors if I don't
> add '-lz' manually. Should I put it in '~src/makefiles/Makefile.qnx4' ?

Does -lz show up in LIBS in src/Makefile.global?  Does it show up on the
link command line?  Maybe an ordering dependency.

> Well, the contents of the previous version were practically identical to
> dynamic_loader.h, except that fmgr.h was not included before the function
> declarations. That led to compile errors in dfmgr.c and fmgr.c because
> PGFunction was not declared.

I see.  I misread the patch at first.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Re: State of the QNX Port

From
"Tegge, Bernd"
Date:
At 19:54 01.03.01 +0100, Peter Eisentraut wrote:
>Tegge, Bernd writes:
>
> > >abs_top_srcdir=`cd $srcdir && pwd`
> > >abs_top_builddir=`pwd`
>
> > + test x//7/part2/CVStrees/pgsql != x/CVStrees/pgsql
>
>Hmm, I don't understand the semantics of the //# specification, but in
>your case the failure could probably be worked around if you ran configure
>like this: './configure', instead of the full absolute path.  There are
>other places that rely on the textual equality of these two variables, and
>they're a bit harder to fix.

Just out of curiosity, what other places ?
If you reread my previous posting, you'll notice that I did "./configure"
at the shell prompt. As far as I can see the QNX sh will always show the
network absolute path for $0 in a script :
repas@qnx4[7]:ttypd$ cat xx.sh
#!/bin/sh
echo $0
repas@qnx4[7]:ttypd$ ./xx.sh
//7/home/repas/xx.sh
repas@qnx4[7]:ttypd$ /home/repas/xx.sh
//7/home/repas/xx.sh
repas@qnx4[7]:ttypd$ pwd
/home/repas
repas@qnx4[7]:ttypd$ cd //7/home/repas
repas@qnx4[7]:ttypd$ pwd
//7/home/repas
repas@qnx4[7]:ttypd$ cd /home/repas
repas@qnx4[7]:ttypd$ fullpath
/home/repas is //7/home/repas
repas@qnx4[7]:ttypd$

I currently see two ways to work around this problem :
1. set --srcdir to configure or
2. use the full path in cd command to the postgres directory.

Both are not really satisfying.


> > They *are* found. I see the above lines when configure runs. config.log
> > shows no errors for zlib.h and inflate. I still get link errors if I don't
> > add '-lz' manually. Should I put it in '~src/makefiles/Makefile.qnx4' ?
>
>Does -lz show up in LIBS in src/Makefile.global?  Does it show up on the
>link command line?  Maybe an ordering dependency.

Bingo. Yes, it's present in Makefile.global. Yes, LIBS is replaced by the
definition from Makefile.port (a.k.a. Makefile.qnx4). Now, how is one
supposed to add platform specific libraries to the LIBS variable ?
BTW, this also means that all the currently specified libraries from
Makefile.global except libz are redundant, and could be removed.

> > Well, the contents of the previous version were practically identical to
> > dynamic_loader.h, except that fmgr.h was not included before the function
> > declarations. That led to compile errors in dfmgr.c and fmgr.c because
> > PGFunction was not declared.
>
>I see.  I misread the patch at first.

BTW, I made progress concerning the looping postmaster. The problem are
conflicting definitions for spinlocks in s_lock.h and slock_t from qnx4.h.
The former uses semaphores as locks, but the latter defines slock_t as
'unsigned char' instead of sem_t. Interestingly enough, this seems to
work in 7.0X.
I'll try to contact Andreas tomorrow, but I suspect slock_t should be set
to sem_t. At least that way initdb succeeds, but now I'm somehow missing
all the sql files from the test/regress directory ... time to stop for
today.


Re: State of the QNX Port

From
Peter Eisentraut
Date:
Tegge, Bernd writes:

> > > >abs_top_srcdir=`cd $srcdir && pwd`
> > > >abs_top_builddir=`pwd`
> >
> > > + test x//7/part2/CVStrees/pgsql != x/CVStrees/pgsql

I've fixed this part.  The test is now based on 'test -ef'.

> Bingo. Yes, it's present in Makefile.global. Yes, LIBS is replaced by the
> definition from Makefile.port (a.k.a. Makefile.qnx4). Now, how is one
> supposed to add platform specific libraries to the LIBS variable ?

I've added a proper configure check.

> BTW, this also means that all the currently specified libraries from
> Makefile.global except libz are redundant, and could be removed.

This was probably the idea behind overriding the LIBS variable.  But
obviously there is a problem when adding non-system libraries, such as
libz or maybe readline.

The fact is that most of the libraries that configure finds are not needed
for any given system, but that is a legacy problem for PostgreSQL and a
design flaw in Autoconf that is not worthwhile to work around unless there
is a real problem.


Bonus project:  There are way too many things defined in qnx4.h.  At least

#include <sys/select.h>
#define HAVE_STRING_H

should be removed.  I'm also suspicious about

#include <process.h>                    /* for execv */

(who uses execv()?) and

#if !defined(__GNUC__)
#include <semaphore.h>                  /* for sem_t */
#endif

(What does this have to do with GNUC?)

Can you check that?

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/