# Installing postgresql from ports



## neolix (Nov 21, 2012)

I have attempted to install postgresql-server 8.4, 9.0, 9.1, and 9.2 on FreeBSD 8.2 and all have failed with this during configure:


```
checking thread safety of required library functions... no
configure: error: thread test program failed
This platform is not thread-safe.  Check the file 'config.log' or compile
and run src/test/thread/thread_test for the exact reason.
Use --disable-thread-safety to disable thread safety.
===>  Script "configure" failed unexpectedly.
Please report the problem to pgsql@FreeBSD.org [maintainer] and attach the
"/usr/ports/databases/postgresql91-client/work/postgresql-9.1.6/config.log"
including the output of the failure of your make command. Also, it might be
a good idea to provide an overview of all packages installed on your system
(e.g. a /usr/sbin/pkg_info -Ea).
*** Error code 1

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

Stop in /usr/ports/databases/postgresql91-server.
*** Error code 1

Stop in /usr/ports/databases/postgresql91-server.
```


I assume I am missing some sort of dependency somewhere?


----------



## UNIXgod (Nov 21, 2012)

have you tried installing it first with defaults on?


----------



## neolix (Nov 22, 2012)

I am installing it with defaults, just 'make install clean'


----------



## neolix (Nov 22, 2012)

I have attached a list of my installed ports if that helps.


----------



## neolix (Nov 22, 2012)

My config.log file is here if that may help.

Thanks for any ideas.


----------



## neolix (Nov 22, 2012)

I have been trying to figure it out further and it seems to fail with:


```
conftest.c:23:1: error: unknown type name 'choke'
```

I do not know much about build files but I am starting to suspect 
this is a build issue on AMD64.


----------



## neolix (Nov 22, 2012)

Here's the rest of it:


```
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "PostgreSQL"
| #define PACKAGE_TARNAME "postgresql"
| #define PACKAGE_VERSION "9.1.6"
| #define PACKAGE_STRING "PostgreSQL 9.1.6"
| #define PACKAGE_BUGREPORT "pgsql-bugs@postgresql.org"
| #define PG_VERSION "9.1.6"
| #define PG_MAJORVERSION "9.1"
| #define USE_INTEGER_DATETIMES 1
| #define ENABLE_NLS 1
| #define DEF_PGPORT 5432
| #define DEF_PGPORT_STR "5432"
| #define BLCKSZ 8192
| #define RELSEG_SIZE 131072
| #define XLOG_BLCKSZ 8192
| #define XLOG_SEG_SIZE (16 * 1024 * 1024)
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| #ifndef __INTEL_COMPILER
| choke me
| #endif
|   ;
|   return 0;
| }
```


----------



## wblock@ (Nov 22, 2012)

Check /etc/make.conf for custom settings.  In particular, are you using clang to build ports?


----------



## neolix (Nov 22, 2012)

Thanks for the thought wblock. I am not using clang; my make.conf is pretty bare. I attempted installing ports-mgtm/portconf which has not helped. I also tried building with gcc 4.6 but that has not helped either.


----------



## neolix (Nov 22, 2012)

Here's what I have in my /etc/make.conf:


```
RUBY_VERSION=1.9.3
RUBY_DEFAULT_VER=1.9
# added by use.perl 2012-11-17 02:10:46
PERL_VERSION=5.14.2

.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc46)
CC=gcc46
CXX=g++46
CPP=cpp46
.endif

# CPUTYPE?=nocona
# CFLAGS=-O2 -pipe -fno-strict-aliasing
# COPTFLAGS=-O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing
# OPTIMIZED_CFLAGS=YES
# WITHOUT_X11=YES
# BUILD_OPTIMIZED=YES
# WITH_CPUFLAGS=YES
# WITH_OPTIMIZED_CFLAGS=YES
# WITHOUT_DEBUG=YES
# BUILD_STATIC=YES
# NO_PROFILE=YES

# Begin portconf settings
# Do not touch these lines
.if !empty(.CURDIR:M/usr/ports*) && exists(/usr/local/libexec/portconf)
_PORTCONF!=/usr/local/libexec/portconf
.for i in ${_PORTCONF:S/|/ /g}
${i:S/%/ /g}
.endfor
.endif
# End portconf settings
```


----------



## UNIXgod (Nov 22, 2012)

wblock@ said:
			
		

> Check /etc/make.conf for custom settings.  In particular, are you using clang to build ports?



I have a jail which defaults to clang and 9.x up to the latest compiles fine with clang.



			
				neolix said:
			
		

> Here's what I have in my /etc/make.conf:
> 
> 
> ```
> ...



You should use either the base gcc or base clang.

gcc46 is probably causing the issue here.


----------



## neolix (Nov 23, 2012)

Thanks UNIXgod. I only tried gcc4.6 after it failed with the default gcc. Let me try clang.


----------



## neolix (Nov 23, 2012)

@UNIXgod, thanks for your help but it still fails with the same error with clang.


----------



## neolix (Nov 23, 2012)

I have narrowed down the error to:


```
configure:29426: checking thread safety of required library functions
configure:29459: clang -o conftest -O2 -pipe -fno-strict-aliasing -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE  -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include -I/usr/local/include  -L/usr/local/lib -rpath=/usr/lib:/usr/local/lib -L/usr/local/lib -L/usr/local/lib  -L/usr/local/lib conftest.c -lintl -lxml2 -lssl -lcrypto -lz -lreadline -lcrypt -lm  -pthread >&5
clang: warning: argument unused during compilation: '-rpath=/usr/lib:/usr/local/lib'
configure:29463: $? = 0
configure:29469: ./conftest
errno not thread-safe **
exiting
```

So errno is not thread-safe. I assume this should not be the case? If so does that mean I have some how screwed up libc?


----------



## kpa (Nov 23, 2012)

Can you try the same on FreeBSD 8.3? 8.2 is end of life and there might have been some changes to postgresql ports that break on FreeBSD 8.2.


----------



## neolix (Nov 23, 2012)

Thanks kpa, you might be right. At this point I am considering wiping the slate clean and starting with a fresh FreeBSD 9.0 system. Even if I get it working I won't have great confidence that something wont fail unexpectedly at any point.


----------



## neolix (Nov 25, 2012)

I finally solved it. It seems I had somehow commented out the posix scheduler in my custom kernel! Thanks for your help guys.


----------

