# postgresql-client-8.3.3 build error



## Ghirai (Nov 16, 2008)

*postgresql-client-8.3.5 build error*

I'm running 7.0-RELEASE-p5, amd64.


```
# pkg_version -vL =
postgresql-client-8.3.3             <   needs updating (port has 8.3.5)
postgresql-server-8.3.3             <   needs updating (port has 8.3.5)
```

'make' gives this error:


```
...
cc -O2 -fno-strict-aliasing -pipe  -O3 -funroll-loops -Wall
-Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-fwrapv -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fPIC
-DPIC -shared -Wl,-x,-soname,libpq.so.5  fe-auth.o fe-connect.o
fe-exec.o fe-misc.o fe-print.o fe-lobj.o fe-protocol2.o fe-protocol3.o
pqexpbuffer.o pqsignal.o fe-secure.o md5.o ip.o wchar.o encnames.o
noblock.o pgstrcasecmp.o thread.o   -L../../../src/port
-L/usr/local/lib -lintl -lssl -lcrypto -lcrypt -pthread
-Wl,-R'/usr/local/lib' -o libpq.so.5 /usr/bin/ld: /usr/lib/libpthread.a
(thr_syscalls.o): relocation R_X86_64_32S can not be used when making a
shared object; recompile with -fPIC /usr/lib/libpthread.a: could not
read symbols: Bad value gmake[1]: *** [libpq.so.5] Error 1 gmake[1]:
Leaving directory
`/usr/ports/databases/postgresql83-client/work/postgresql-8.3.5/src/interfaces/libpq'
gmake: *** [all] Error 2 *** Error code 2

Stop in /usr/ports/databases/postgresql83-client.
*** Error code 1

Stop in /usr/ports/databases/postgresql83-client.
** Command failed [exit code 1]: /usr/bin/script
-qa /tmp/portupgrade.62208.0 env UPGRADE_TOOL=portupgrade
UPGRADE_PORT=postgresql-client-8.3.3 UPGRADE_PORT_VER=8.3.3 make ** Fix
the problem and try again.
--->  Skipping
'databases/postgresql83-server' (postgresql-server-8.3.3) because a
requisite package
'postgresql-client-8.3.3' (databases/postgresql83-client) failed
(specify -k to force) ** Listing the failed packages (-:ignored /
*:skipped / !:failed) ! databases/postgresql83-client
(postgresql-client-8.3.3)	(unknown build error)
	* databases/postgresql83-server (postgresql-server-8.3.3)
```

Anyone got any ideas? Ports tree is obviously up to date.

Thanks.


----------



## jfreund (Nov 16, 2008)

What were your config options? Have you set any CFLAGS or similar in /etc/make.conf? I guess this _could_ be the -O3 flag in the postgresql83-client configuration or some CFLAG which is too agressive...


----------



## Ghirai (Nov 16, 2008)

No, i haven't touched /etc/make.conf, everything is default.

I have another 7.0 box, and the same upgrade went fine there (and i suspect it works for (almost) everyone else, seeing that i'm the only one having problems with it).


----------



## jfreund (Nov 17, 2008)

```
cc [...] -O3 -funroll-loops [...]
```
This looks for me as if you'd have the chosen the optimization option in the configure dialogue. The relocation error could be related to that, so I'd suggest you try to run make config again for this port and disable the optimization option.


----------



## Ghirai (Nov 17, 2008)

You're right, i had OPTIMIZED_CFLAGS checked.
I disabled it, and make gives this:


```
cc -O2 -fno-strict-aliasing -pipe  -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fPIC -DPIC -shared -Wl,-x,-soname,libpq.so.5  fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o   -L../../../src/port -L/usr/local/lib -lintl -lssl -lcrypto -lcrypt -pthread -Wl,-R'/usr/local/lib' -o libpq.so.5
/usr/bin/ld: /usr/lib/libpthread.a(thr_syscalls.o): relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
/usr/lib/libpthread.a: could not read symbols: Bad value
gmake[1]: *** [libpq.so.5] Error 1
gmake[1]: Leaving directory `/usr/ports/databases/postgresql83-client/work/postgresql-8.3.5/src/interfaces/libpq'
gmake: *** [all] Error 2
*** Error code 2

Stop in /usr/ports/databases/postgresql83-client.
*** Error code 1

Stop in /usr/ports/databases/postgresql83-client.
```


----------



## ale (Nov 22, 2008)

Would you mind trying the attached patch?

Sorry, but I'm running i386 so I can't test it.


----------



## Ghirai (Nov 22, 2008)

Hey,

Here's the output with -fPIC:


```
cc -O2 -fno-strict-aliasing -pipe  -fPIC -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fPIC -DPIC -shared -Wl,-x,-soname,libpq.so.5  fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o   -L../../../src/port -L/usr/local/lib -lintl -lssl -lcrypto -lcrypt -pthread -Wl,-R'/usr/local/lib' -o libpq.so.5
/usr/bin/ld: /usr/lib/libpthread.a(thr_syscalls.o): relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
/usr/lib/libpthread.a: could not read symbols: Bad value
gmake[1]: *** [libpq.so.5] Error 1
gmake[1]: Leaving directory `/usr/ports/databases/postgresql83-client/work/postgresql-8.3.5/src/interfaces/libpq'
gmake: *** [all] Error 2
*** Error code 2
```


----------



## ale (Nov 22, 2008)

OK, sorry, remove my patch as it's totally useless.
I've seen you message in a ml.
I think that you should try sending an email to the maintainer.


----------



## Ghirai (Nov 22, 2008)

I already did, but no reply so far.

Thanks for the help anyway.


----------



## Mel_Flynn (Nov 23, 2008)

Can you post the output of:

```
ls -l /usr/lib/lib*thr*.so*
```


----------



## Ghirai (Nov 24, 2008)

```
# ls -l /usr/lib/lib*thr*.so*
lrwxr-xr-x  1 root  wheel     16 Oct 24 20:27 /usr/lib/libthr.so -> /lib/libthr.so.3
lrwxr-xr-x  1 root  wheel     17 Oct 24 20:27 /usr/lib/libthread_db.so -> libthread_db.so.3
-r--r--r--  1 root  wheel  26656 Oct 24 20:27 /usr/lib/libthread_db.so.3
```


----------



## Mel_Flynn (Nov 24, 2008)

So, you need to figure out why postgresql wants to link with libpthread where it should be linking with libthr on 7.0.

Does this problem disappear when you build postgres without NLS support? It's the only non-base library in the link list.

The cause for the original problem, is that there is no shared libpthread to link with. More info here.


----------



## Ghirai (Nov 24, 2008)

Mel_Flynn said:
			
		

> Does this problem disappear when you build postgres without NLS support? It's the only non-base library in the link list.



Sadly no.

I found that thread some time ago while searching for my problem; however i don't know how to solve the situation.

Is this only happening on this specific 7.0 box i have? If so, why (as i stated earlier, it worked fine on other identical set up boxes)?
Any chance i could fix it eventually, or is the only solution a reinstall?


----------



## Mel_Flynn (Nov 24, 2008)

Is there any chance you upgraded this from a previous major version and did not run make delete-old-libs?

On my 7.x systems, libpthread is symlinked to libthr. Or maybe the links got lost.

I'd go about it like this:

```
mkdir /tmp/pthread.bkp
mv /usr/lib/libpthread* /tmp/pthread.bkp/
cd /usr/lib
for ext in .a .so _p.a; do
    ln -vs libthr$ext libpthread$ext
done
```
then recompile.
If this works but other problems now manifest on your system, you need to figure out where this libpthread came from.


----------



## Ghirai (Nov 24, 2008)

The box was upgraded from 6.3 following this: http://www.daemonology.net/blog/2007-11-11-freebsd-major-version-upgrade.html

I'll try your suggestion and see what happens, hopefully it won't break anything :e

Thanks.


----------



## Ghirai (Nov 30, 2008)

It worked; everything seems fine, thanks :e


----------

