Compile error while building postgresql 10.3

Started by Terry Phelpsabout 8 years ago19 messageshackers
Jump to latest
#1Terry Phelps
tgphelps50@gmail.com

I'm new to PostgreSQL but not to Unix or databases, and am reading the
(wonderful) docs and learning. I tried to determine which mailing list to
send this to, and this one seems to fit best.

Just for fun, I am trying to build postgres from source on FreeBSD 11. Yes,
I know I don't need to, and I have already installed the 10.3 server and
client packages, and they run fine. I did a 'git clone' today, and have
hours-old source code.

So, I install the prereqs, and did a 'configure' and 'make', and expected
it to 'just work'. However, I get this compile error:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include
-c -o pg_crc32c_sse42.o pg_crc32c_sse42.c
pg_crc32c_sse42.c:37:18: error: always_inline function '_mm_crc32_u64'
requires
target feature 'ssse3', but would be inlined into function
'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
crc = (uint32) _mm_crc32_u64(crc, *((const uint64 *) p));
^
pg_crc32c_sse42.c:44:9: error: always_inline function '_mm_crc32_u32'
requires
target feature 'ssse3', but would be inlined into function
'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
crc = _mm_crc32_u32(crc, *((const unsigned int *) p));
^
pg_crc32c_sse42.c:63:9: error: always_inline function '_mm_crc32_u8'
requires
target feature 'ssse3', but would be inlined into function
'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
crc = _mm_crc32_u8(crc, *p);
^
3 errors generated.

I googled, and search the archives, and don't see anything applicable. My C
compiler is:

$ cc --version
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM
4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix

I don't know what else you might want to know, but I'll supply it, if you
ask.

Any ideas what's wrong?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Terry Phelps (#1)
Re: Compile error while building postgresql 10.3

Terry Phelps <tgphelps50@gmail.com> writes:

Just for fun, I am trying to build postgres from source on FreeBSD 11. Yes,
I know I don't need to, and I have already installed the 10.3 server and
client packages, and they run fine. I did a 'git clone' today, and have
hours-old source code.

FWIW, development-code issues generally belong on -hackers, so forwarding
this there.

So, I install the prereqs, and did a 'configure' and 'make', and expected
it to 'just work'. However, I get this compile error:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include
-c -o pg_crc32c_sse42.o pg_crc32c_sse42.c
pg_crc32c_sse42.c:37:18: error: always_inline function '_mm_crc32_u64'
requires
target feature 'ssse3', but would be inlined into function
'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
crc = (uint32) _mm_crc32_u64(crc, *((const uint64 *) p));
^
pg_crc32c_sse42.c:44:9: error: always_inline function '_mm_crc32_u32'
requires
target feature 'ssse3', but would be inlined into function
'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
crc = _mm_crc32_u32(crc, *((const unsigned int *) p));
^
pg_crc32c_sse42.c:63:9: error: always_inline function '_mm_crc32_u8'
requires
target feature 'ssse3', but would be inlined into function
'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
crc = _mm_crc32_u8(crc, *p);
^
3 errors generated.

I googled, and search the archives, and don't see anything applicable. My C
compiler is:
$ cc --version
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM
4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix

Huh. Apparently that compiler is stricter about the use of "ssse3" than
anything we've tested this code on before.

It's interesting that your "cc" line for pg_crc32c_sse42.c shows no sign
of any added options for SSE4.2 compiler intrinsics, which seems to be
what's needed here. The configure script is supposed to detect whether
such options are needed, but it looks like it failed to do so correctly.
Can you look into config.log and see what happened corresponding to this
bit of configure.in?

# Check for Intel SSE 4.2 intrinsics to do CRC calculations.
#
# First check if the _mm_crc32_u8 and _mm_crc32_u64 intrinsics can be used
# with the default compiler flags. If not, check if adding the -msse4.2
# flag helps. CFLAGS_SSE42 is set to -msse4.2 if that's required.
PGAC_SSE42_CRC32_INTRINSICS([])
if test x"$pgac_sse42_crc32_intrinsics" != x"yes"; then
PGAC_SSE42_CRC32_INTRINSICS([-msse4.2])
fi
AC_SUBST(CFLAGS_SSE42)

regards, tom lane

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Terry Phelps (#1)
Re: Compile error while building postgresql 10.3

[ please keep the list cc'd ]

Terry Phelps <tgphelps50@gmail.com> writes:

I can barely read a configure.in file, but here's what I think you're
asking for. If not, I'll try again:

configure:15453: checking for _mm_crc32_u8 and _mm_crc32_u32 with
CFLAGS=-msse4.2
configure:15475: cc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-Wno-unused-command-line-argument -I/usr/local/include -msse4.2
-L/usr/local/lib conftest.c -lz -lreadline -lcrypt -lm >&5
configure:15475: $? = 0
configure:15484: result: yes

Interesting. So it looks like configure *did* decide that -msse4.2
is needed. What do you get from "grep sse4 src/Makefile.global" ?
What I'd expect is

CFLAGS_SSE42 = -msse4.2
PG_CRC32C_OBJS = pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o

If you see that, then the next question is why CFLAGS_SSE42 isn't
getting propagated into the build of pg_crc32c_sse42.o, which would
seem to suggest a problem with gmake. What make version are you
using?

regards, tom lane

#4Andres Freund
andres@anarazel.de
In reply to: Tom Lane (#3)
Re: Compile error while building postgresql 10.3

On 2018-03-19 15:50:10 -0400, Tom Lane wrote:

[ please keep the list cc'd ]

Terry Phelps <tgphelps50@gmail.com> writes:

I can barely read a configure.in file, but here's what I think you're
asking for. If not, I'll try again:

configure:15453: checking for _mm_crc32_u8 and _mm_crc32_u32 with
CFLAGS=-msse4.2
configure:15475: cc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-Wno-unused-command-line-argument -I/usr/local/include -msse4.2
-L/usr/local/lib conftest.c -lz -lreadline -lcrypt -lm >&5
configure:15475: $? = 0
configure:15484: result: yes

Interesting. So it looks like configure *did* decide that -msse4.2
is needed. What do you get from "grep sse4 src/Makefile.global" ?
What I'd expect is

CFLAGS_SSE42 = -msse4.2
PG_CRC32C_OBJS = pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o

If you see that, then the next question is why CFLAGS_SSE42 isn't
getting propagated into the build of pg_crc32c_sse42.o, which would
seem to suggest a problem with gmake. What make version are you
using?

There seems to be something sketchy afoot here, even outside of
CFLAGS_SSE42 itself. From the original email:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include
-c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

isn't this missing a number of important flags? Like at least
-fno-strict-aliasing -fwrapv -fexcess-precision=standard?

Greetings,

Andres Freund

#5Terry Phelps
tgphelps50@gmail.com
In reply to: Tom Lane (#3)
Re: Compile error while building postgresql 10.3

I get the following, which appears to be what you were expecting.

$ grep sse4 src/Makefile.global
CFLAGS_SSE42 = -msse4.2
PG_CRC32C_OBJS = pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o

Gmake's version is:

$ gmake --version
GNU Make 4.2.1
Built for amd64-portbld-freebsd11.1

I installed this via "pkg install gmake". I didn't build it myself.

On Mon, Mar 19, 2018 at 3:50 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

[ please keep the list cc'd ]

Terry Phelps <tgphelps50@gmail.com> writes:

I can barely read a configure.in file, but here's what I think you're
asking for. If not, I'll try again:

configure:15453: checking for _mm_crc32_u8 and _mm_crc32_u32 with
CFLAGS=-msse4.2
configure:15475: cc -o conftest -Wall -Wmissing-prototypes

-Wpointer-arith

-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-Wno-unused-command-line-argument -I/usr/local/include -msse4.2
-L/usr/local/lib conftest.c -lz -lreadline -lcrypt -lm >&5
configure:15475: $? = 0
configure:15484: result: yes

Interesting. So it looks like configure *did* decide that -msse4.2
is needed. What do you get from "grep sse4 src/Makefile.global" ?
What I'd expect is

CFLAGS_SSE42 = -msse4.2
PG_CRC32C_OBJS = pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o

If you see that, then the next question is why CFLAGS_SSE42 isn't
getting propagated into the build of pg_crc32c_sse42.o, which would
seem to suggest a problem with gmake. What make version are you
using?

regards, tom lane

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andres Freund (#4)
Re: Compile error while building postgresql 10.3

Andres Freund <andres@anarazel.de> writes:

There seems to be something sketchy afoot here, even outside of
CFLAGS_SSE42 itself. From the original email:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include
-c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

isn't this missing a number of important flags? Like at least
-fno-strict-aliasing -fwrapv -fexcess-precision=standard?

Good point ... seems like we lost *all* CFLAGS not just the SSE42 ones.
I believe the options we see here are all from CPPFLAGS not CFLAGS.

Terry, could we see a full "make" trace from src/port/? Something like

cd src/port
make -s clean
make

I'm curious whether the flags lossage affects all .c files in that
directory, or only ones that are trying to add on custom flags.

regards, tom lane

#7Terry Phelps
tgphelps50@gmail.com
In reply to: Tom Lane (#6)
Re: Compile error while building postgresql 10.3

Tom, I'll get what you asked for in a minute. But first, I want to make
sure that y'all see that the compiler is clang, and not gcc. Perhaps that's
not important.

On Mon, Mar 19, 2018 at 4:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Andres Freund <andres@anarazel.de> writes:

There seems to be something sketchy afoot here, even outside of
CFLAGS_SSE42 itself. From the original email:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include
-c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

isn't this missing a number of important flags? Like at least
-fno-strict-aliasing -fwrapv -fexcess-precision=standard?

Good point ... seems like we lost *all* CFLAGS not just the SSE42 ones.
I believe the options we see here are all from CPPFLAGS not CFLAGS.

Terry, could we see a full "make" trace from src/port/? Something like

cd src/port
make -s clean
make

I'm curious whether the flags lossage affects all .c files in that
directory, or only ones that are trying to add on custom flags.

regards, tom lane

#8Terry Phelps
tgphelps50@gmail.com
In reply to: Tom Lane (#6)
Re: Compile error while building postgresql 10.3

I did:
cd src/port
gmake -s clean
gmake

It says:

gmake -C ../backend submake-errcodes
gmake[1]: Entering directory '/usr/home/tgphelps/postgresql/src/backend'
gmake[1]: Nothing to be done for 'submake-errcodes'.
gmake[1]: Leaving directory '/usr/home/tgphelps/postgresql/src/backend'
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -DFRONTEND
-I../../src/include -c -o pg_crc32c_sse42.o pg_crc32c_sse42.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pg_crc32c_sb8.o pg_crc32c_sb8.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pg_crc32c_choose.o pg_crc32c_choose.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o chklocale.o chklocale.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o erand48.o erand48.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o inet_net_ntop.o inet_net_ntop.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o noblock.o noblock.c
echo "#define PGBINDIR \"/usr/local/pgsql/bin\"" >pg_config_paths.h
echo "#define PGSHAREDIR \"/usr/local/pgsql/share\"" >>pg_config_paths.h
echo "#define SYSCONFDIR \"/usr/local/pgsql/etc\"" >>pg_config_paths.h
echo "#define INCLUDEDIR \"/usr/local/pgsql/include\"" >>pg_config_paths.h
echo "#define PKGINCLUDEDIR \"/usr/local/pgsql/include\""

pg_config_paths.h

echo "#define INCLUDEDIRSERVER \"/usr/local/pgsql/include/server\""

pg_config_paths.h

echo "#define LIBDIR \"/usr/local/pgsql/lib\"" >>pg_config_paths.h
echo "#define PKGLIBDIR \"/usr/local/pgsql/lib\"" >>pg_config_paths.h
echo "#define LOCALEDIR \"/usr/local/pgsql/share/locale\""

pg_config_paths.h

echo "#define DOCDIR \"/usr/local/pgsql/share/doc/\"" >>pg_config_paths.h
echo "#define HTMLDIR \"/usr/local/pgsql/share/doc/\"" >>pg_config_paths.h
echo "#define MANDIR \"/usr/local/pgsql/share/man\"" >>pg_config_paths.h
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o path.o path.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pgcheckdir.o pgcheckdir.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pgmkdirp.o pgmkdirp.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pgsleep.o pgsleep.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pgstrcasecmp.o pgstrcasecmp.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pqsignal.o pqsignal.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o qsort.o qsort.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o qsort_arg.o qsort_arg.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o quotes.o quotes.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o sprompt.o sprompt.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o tar.o tar.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -D_THREAD_SAFE -pthread -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS -I../../src/port -DFRONTEND
-I../../src/include -c -o thread.o thread.c
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include -c
-o pg_strong_random.o pg_strong_random.c
rm -f libpgport.a
ar cr libpgport.a pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o
chklocale.o erand48.o inet_net_ntop.o noblock.o path.o pgcheckdir.o
pgmkdirp.o pgsleep.o pgstrcasecmp.o pqsignal.o qsort.o qsort_arg.o quotes.o
sprompt.o tar.o thread.o pg_strong_random.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -I../../src/include -c
pg_crc32c_sse42.c -o pg_crc32c_sse42_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
pg_crc32c_sb8.c -o pg_crc32c_sb8_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
pg_crc32c_choose.c -o pg_crc32c_choose_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
chklocale.c -o chklocale_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c erand48.c
-o erand48_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
inet_net_ntop.c -o inet_net_ntop_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c noblock.c
-o noblock_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c path.c -o
path_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
pgcheckdir.c -o pgcheckdir_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c pgmkdirp.c
-o pgmkdirp_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c pgsleep.c
-o pgsleep_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
pgstrcasecmp.c -o pgstrcasecmp_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c pqsignal.c
-o pqsignal_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c qsort.c -o
qsort_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
qsort_arg.c -o qsort_arg_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c quotes.c
-o quotes_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c sprompt.c
-o sprompt_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c tar.c -o
tar_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c thread.c
-o thread_srv.o
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -I../../src/port -I../../src/include -c
pg_strong_random.c -o pg_strong_random_srv.o
rm -f libpgport_srv.a
ar cr libpgport_srv.a pg_crc32c_sse42_srv.o pg_crc32c_sb8_srv.o
pg_crc32c_choose_srv.o chklocale_srv.o erand48_srv.o inet_net_ntop_srv.o
noblock_srv.o path_srv.o pgcheckdir_srv.o pgmkdirp_srv.o pgsleep_srv.o
pgstrcasecmp_srv.o pqsignal_srv.o qsort_srv.o qsort_arg_srv.o quotes_srv.o
sprompt_srv.o tar_srv.o thread_srv.o pg_strong_random_srv.o

On Mon, Mar 19, 2018 at 4:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Andres Freund <andres@anarazel.de> writes:

There seems to be something sketchy afoot here, even outside of
CFLAGS_SSE42 itself. From the original email:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include
-c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

isn't this missing a number of important flags? Like at least
-fno-strict-aliasing -fwrapv -fexcess-precision=standard?

Good point ... seems like we lost *all* CFLAGS not just the SSE42 ones.
I believe the options we see here are all from CPPFLAGS not CFLAGS.

Terry, could we see a full "make" trace from src/port/? Something like

cd src/port
make -s clean
make

I'm curious whether the flags lossage affects all .c files in that
directory, or only ones that are trying to add on custom flags.

regards, tom lane

#9Andres Freund
andres@anarazel.de
In reply to: Terry Phelps (#8)
Re: Compile error while building postgresql 10.3

Hi,

On 2018-03-19 16:07:17 -0400, Terry Phelps wrote:

I did:
cd src/port
gmake -s clean
gmake

It says:

cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -DFRONTEND
-I../../src/include -c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -I../../src/include -c
pg_crc32c_sse42.c -o pg_crc32c_sse42_srv.o

So the build actually succeeds now? Or are you getting the error while
you're in some other directory?

Greetings,

Andres Freund

#10Terry Phelps
tgphelps50@gmail.com
In reply to: Andres Freund (#9)
Re: Compile error while building postgresql 10.3

The above was in response to Tom Lane's request to show him a listing of:

cd src/port
gmake

I didn't get any errors when I did that.

On Mon, Mar 19, 2018 at 4:11 PM, Andres Freund <andres@anarazel.de> wrote:

Show quoted text

Hi,

On 2018-03-19 16:07:17 -0400, Terry Phelps wrote:

I did:
cd src/port
gmake -s clean
gmake

It says:

cc -Wall -Wmissing-prototypes -Wpointer-arith

-Wdeclaration-after-statement

-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -DFRONTEND
-I../../src/include -c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

cc -Wall -Wmissing-prototypes -Wpointer-arith

-Wdeclaration-after-statement

-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -I../../src/include -c
pg_crc32c_sse42.c -o pg_crc32c_sse42_srv.o

So the build actually succeeds now? Or are you getting the error while
you're in some other directory?

Greetings,

Andres Freund

#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Terry Phelps (#8)
Re: Compile error while building postgresql 10.3

Terry Phelps <tgphelps50@gmail.com> writes:

I did:
cd src/port
gmake -s clean
gmake

It says:

cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -DFRONTEND
-I../../src/include -c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

Now I'm even more confused, because that's fine --- and you'll notice
it didn't fail. So why doesn't this agree with your original run?
Did you do anything different from plain "gmake" that time?

regards, tom lane

#12Terry Phelps
tgphelps50@gmail.com
In reply to: Tom Lane (#11)
Re: Compile error while building postgresql 10.3

Only slight different. Here is exact what I entered to get the error:

I ran configure like this, because it got errors otherwise. OHHHH. I wonder
if CFLAGS caused this.

LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include ./configure

And then I ran gmake like this:

gmake LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include

And I again touched CFLAGS. I fear that I caused this.

On Mon, Mar 19, 2018 at 4:15 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Terry Phelps <tgphelps50@gmail.com> writes:

I did:
cd src/port
gmake -s clean
gmake

It says:

cc -Wall -Wmissing-prototypes -Wpointer-arith

-Wdeclaration-after-statement

-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -msse4.2 -I../../src/port -DFRONTEND
-I../../src/include -c -o pg_crc32c_sse42.o pg_crc32c_sse42.c

Now I'm even more confused, because that's fine --- and you'll notice
it didn't fail. So why doesn't this agree with your original run?
Did you do anything different from plain "gmake" that time?

regards, tom lane

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: Terry Phelps (#12)
Re: Compile error while building postgresql 10.3

Terry Phelps <tgphelps50@gmail.com> writes:

I ran configure like this, because it got errors otherwise. OHHHH. I wonder
if CFLAGS caused this.

LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include ./configure

That would've been fine, but configure then adds onto what you specified
as CFLAGS.

And then I ran gmake like this:
gmake LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include

And here you overrode the additions. Just do "gmake" without these
overrides. If you look into src/Makefile.global you should see that
your initial specifications got into the selected flag variables.

regards, tom lane

#14Terry Phelps
tgphelps50@gmail.com
In reply to: Tom Lane (#13)
Re: Compile error while building postgresql 10.3

Thank you for your help. That resolved the problem. My bad.

The build ran much further and then got another error, which I'll mention
here, and go research it, since it could be just my bleeding edge source
code.

cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -D_THREAD_SAFE -pthread -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS -fPIC -DPIC -I../include
-I../../../../src/interfaces/ecpg/include -DFRONTEND
-I../../../../src/include -DSO_MAJOR_VERSION=3 -c -o datetime.o
datetime.c
datetime.c:332:1: error: conflicting types for 'PGTYPESdate_defmt_asc'
PGTYPESdate_defmt_asc(date * d, const char *fmt, const char *str)
^
/usr/local/include/pgtypes_date.h:24:12: note: previous declaration is here
extern int PGTYPESdate_defmt_asc(date *, const char *, char *);
^
1 error generated.
gmake[4]: *** [<builtin>: datetime.o] Error 1

On Mon, Mar 19, 2018 at 4:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Terry Phelps <tgphelps50@gmail.com> writes:

I ran configure like this, because it got errors otherwise. OHHHH. I

wonder

if CFLAGS caused this.

LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include ./configure

That would've been fine, but configure then adds onto what you specified
as CFLAGS.

And then I ran gmake like this:
gmake LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include

And here you overrode the additions. Just do "gmake" without these
overrides. If you look into src/Makefile.global you should see that
your initial specifications got into the selected flag variables.

regards, tom lane

#15Thomas Munro
thomas.munro@gmail.com
In reply to: Terry Phelps (#14)
Re: Compile error while building postgresql 10.3

On Tue, Mar 20, 2018 at 9:28 AM, Terry Phelps <tgphelps50@gmail.com> wrote:

Thank you for your help. That resolved the problem. My bad.

The build ran much further and then got another error, which I'll mention
here, and go research it, since it could be just my bleeding edge source
code.

cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -D_THREAD_SAFE -pthread -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS -fPIC -DPIC -I../include
-I../../../../src/interfaces/ecpg/include -DFRONTEND
-I../../../../src/include -DSO_MAJOR_VERSION=3 -c -o datetime.o
datetime.c
datetime.c:332:1: error: conflicting types for 'PGTYPESdate_defmt_asc'
PGTYPESdate_defmt_asc(date * d, const char *fmt, const char *str)
^
/usr/local/include/pgtypes_date.h:24:12: note: previous declaration is here
extern int PGTYPESdate_defmt_asc(date *, const char *, char *);

That header is coming from /usr/local/include instead of your
development tree, from an older version of PG from before const was
added there.

BTW it looks like 0e1539ba0d0a added const qualifiers to that function
but didn't update the documentation in doc/src/sgml/ecpg.sgml.

--
Thomas Munro
http://www.enterprisedb.com

#16Tom Lane
tgl@sss.pgh.pa.us
In reply to: Terry Phelps (#14)
Re: Compile error while building postgresql 10.3

Terry Phelps <tgphelps50@gmail.com> writes:

Thank you for your help. That resolved the problem. My bad.
The build ran much further and then got another error, which I'll mention
here, and go research it, since it could be just my bleeding edge source
code.

cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -D_THREAD_SAFE -pthread -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS -fPIC -DPIC -I../include
-I../../../../src/interfaces/ecpg/include -DFRONTEND
-I../../../../src/include -DSO_MAJOR_VERSION=3 -c -o datetime.o
datetime.c
datetime.c:332:1: error: conflicting types for 'PGTYPESdate_defmt_asc'
PGTYPESdate_defmt_asc(date * d, const char *fmt, const char *str)
^
/usr/local/include/pgtypes_date.h:24:12: note: previous declaration is here
extern int PGTYPESdate_defmt_asc(date *, const char *, char *);
^
1 error generated.

It looks like you've got -I/usr/local/include in front of the build's
own -I switches, and that's allowing it to pull in back-version copies
of PG-related include files instead of the ones in the source tree.

I'm not totally sure, but if you inject -I/usr/local/include through
CPPFLAGS not CFLAGS, configure might do the right thing automatically.
Otherwise, you could manually edit CPPFLAGS in src/Makefile.global
after configuring to get the right -I order.

regards, tom lane

#17Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Munro (#15)
Re: Compile error while building postgresql 10.3

Thomas Munro <thomas.munro@enterprisedb.com> writes:

/usr/local/include/pgtypes_date.h:24:12: note: previous declaration is here
extern int PGTYPESdate_defmt_asc(date *, const char *, char *);

BTW it looks like 0e1539ba0d0a added const qualifiers to that function
but didn't update the documentation in doc/src/sgml/ecpg.sgml.

Good catch, please send a patch.

regards, tom lane

#18Terry Phelps
tgphelps50@gmail.com
In reply to: Tom Lane (#16)
Re: Compile error while building postgresql 10.3

I put that include from /usr/local/include because 'configure' wasn't
finding readline.h (I think). I'll look into this.

Thanks again for the help.

On Mon, Mar 19, 2018 at 4:44 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Terry Phelps <tgphelps50@gmail.com> writes:

Thank you for your help. That resolved the problem. My bad.
The build ran much further and then got another error, which I'll mention
here, and go research it, since it could be just my bleeding edge source
code.

cc -Wall -Wmissing-prototypes -Wpointer-arith

-Wdeclaration-after-statement

-Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
-I/usr/local/include -D_THREAD_SAFE -pthread -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS -fPIC -DPIC -I../include
-I../../../../src/interfaces/ecpg/include -DFRONTEND
-I../../../../src/include -DSO_MAJOR_VERSION=3 -c -o datetime.o
datetime.c
datetime.c:332:1: error: conflicting types for 'PGTYPESdate_defmt_asc'
PGTYPESdate_defmt_asc(date * d, const char *fmt, const char *str)
^
/usr/local/include/pgtypes_date.h:24:12: note: previous declaration is

here

extern int PGTYPESdate_defmt_asc(date *, const char *, char *);
^
1 error generated.

It looks like you've got -I/usr/local/include in front of the build's
own -I switches, and that's allowing it to pull in back-version copies
of PG-related include files instead of the ones in the source tree.

I'm not totally sure, but if you inject -I/usr/local/include through
CPPFLAGS not CFLAGS, configure might do the right thing automatically.
Otherwise, you could manually edit CPPFLAGS in src/Makefile.global
after configuring to get the right -I order.

regards, tom lane

#19Achilleas Mantzios
achill@matrix.gatewaynet.com
In reply to: Terry Phelps (#1)
Re: Compile error while building postgresql 10.3

On 19/03/2018 21:10, Terry Phelps wrote:

I'm new to PostgreSQL but not to Unix or databases, and am reading the (wonderful) docs and learning. I tried to determine which mailing list to send this to, and this one seems to fit best.

Just for fun, I am trying to build postgres from source on FreeBSD 11. Yes, I know I don't need to, and I have already installed the 10.3 server and client packages, and they run fine. I did a 'git
clone' today, and have hours-old source code.

So, I install the prereqs, and did a 'configure' and 'make', and expected it to 'just work'. However, I get this compile error:

cc -I/usr/local/include -I../../src/port -DFRONTEND -I../../src/include    -c -o pg_crc32c_sse42.o pg_crc32c_sse42.c
pg_crc32c_sse42.c:37:18: error: always_inline function '_mm_crc32_u64' requires
      target feature 'ssse3', but would be inlined into function
      'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
                crc = (uint32) _mm_crc32_u64(crc, *((const uint64 *) p));
                               ^
pg_crc32c_sse42.c:44:9: error: always_inline function '_mm_crc32_u32' requires
      target feature 'ssse3', but would be inlined into function
      'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
                crc = _mm_crc32_u32(crc, *((const unsigned int *) p));
                      ^
pg_crc32c_sse42.c:63:9: error: always_inline function '_mm_crc32_u8' requires
      target feature 'ssse3', but would be inlined into function
      'pg_comp_crc32c_sse42' that is compiled without support for 'ssse3'
                crc = _mm_crc32_u8(crc, *p);
                      ^
3 errors generated.

I googled, and search the archives, and don't see anything applicable. My C compiler is:

$ cc --version
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix

What I do is just install gcc :
pkg install gcc-6
(you may search for other gcc related pkgs as well)

I don't know what else you might want to know, but I'll supply it, if you ask.

Any ideas what's wrong?

--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt