We are regularly teaching PostgreSQL courses at linuxhotel.de.
Starting from the course in November, PG doesn't compile anymore on
their default Debian Squeeze install laptops they hand out to the
participants. After ./configure && make, the error looks like this:

postmaster/postmaster.o: In function `PostmasterMain':
postmaster.c:(.text+0x40e2): undefined reference to `optreset'
tcop/postgres.o: In function `process_postgres_switches':
postgres.c:(.text+0x168c): undefined reference to `optreset'
utils/misc/ps_status.o: In function `set_ps_display':
ps_status.c:(.text+0xba): undefined reference to `setproctitle'
collect2: error: ld returned 1 exit status
make[2]: *** [postgres] Fehler 1
make[2]: Leaving directory 
`/home/cbe/projects/postgresql/postgresql/src/backend'

This is 9.2.2, but I've seen 9.1.6 failing in the same way. The
package set installed is a desktop install, plus what Debian
considers to be build dependencies of postgresql-9.2, that is,
libedit-dev is installed, but libreadline-dev isn't.

$ egrep 'edit|readline|setproc|optreset' configure.out
checking for library containing setproctitle... no
checking for library containing readline... -ledit
checking editline/readline.h usability... yes
checking editline/readline.h presence... yes
checking for editline/readline.h... yes
checking editline/history.h usability... yes
checking editline/history.h presence... yes
checking for editline/history.h... yes
checking for setproctitle... yes
checking for optreset... yes

I have no clue why no one else has seen this bug before, but the
reason for the error seems to be that configure is invoking the
setproctitle test including -ledit. libedit.so is linked to libbsd.so,
which in turn contains setproctitle(), so HAVE_SETPROCTITLE is set
even this is Linux, not BSD.

configure.in already contains a workaround for -ledit containing a
strlcpy() version, so I'd propose the attached patch to extend that
workaround to setproctitle. (Patch for 9.2's configure.in, but the
same moving of the two code blocks should work for head as well.)

optreset seems to be a similar problem, but I'm not yet sure the patch
really fixes it. (I've kind of got lost in too many configure runs...)

An alternative fix would be to move the __linux__ test in front of the
HAVE_SETPROCTITLE test in src/backend/utils/misc/ps_status.c.

Why is -ledit (or -lreadline) being passed to the function tests
anyway? Removing that would fix this as well, I guess.

(I can provide more verbose configure output on request.)

Christoph
-- 
c...@df7cb.de | http://www.df7cb.de/
diff --git a/configure.in b/configure.in
new file mode 100644
index af99340..2f019ea
*** a/configure.in
--- b/configure.in
*************** PGAC_VAR_INT_TIMEZONE
*** 1197,1202 ****
--- 1197,1207 ----
  AC_FUNC_ACCEPT_ARGTYPES
  PGAC_FUNC_GETTIMEOFDAY_1ARG
  
+ # Some versions of libedit contain strlcpy(); so disregard that library while
+ # checking for these standard libc functions.
+ pgac_save_LIBS="$LIBS"
+ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
+ 
  AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l])
  
  AC_REPLACE_FUNCS(fseeko)
*************** else
*** 1311,1321 ****
    AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
  fi
  
- # Some versions of libedit contain strlcpy(); so disregard that library while
- # checking for these standard libc functions.
- pgac_save_LIBS="$LIBS"
- LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
- 
  AC_REPLACE_FUNCS([crypt fls getopt getrusage inet_aton random rint srandom strerror strlcat strlcpy])
  
  case $host_os in
--- 1316,1321 ----
*************** case $host_os in
*** 1334,1341 ****
  esac
  
  
- LIBS="$pgac_save_LIBS"
- 
  # System's version of getaddrinfo(), if any, may be used only if we found
  # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
  # (Note: the AC_REPLACE_FUNCS probe fails on Windows, where the available
--- 1334,1339 ----
*************** if test x"$pgac_cv_gcc_int_atomics" = x"
*** 1446,1451 ****
--- 1444,1451 ----
    AC_DEFINE(HAVE_GCC_INT_ATOMICS, 1, [Define to 1 if you have __sync_lock_test_and_set(int *) and friends.])
  fi
  
+ LIBS="$pgac_save_LIBS"
+ 
  
  #
  # Pthreads
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to