pgspider / influxdb_fdw

InfluxDB Foreign Data Wrapper for PostgreSQL.
Other
58 stars 14 forks source link

Compile not working - invalid bitcode #5

Closed taterhead closed 5 years ago

taterhead commented 5 years ago

I'm not sure if this is a PGXS issue. make USE_PGXS=1 works, but then make USE_PGXS=1 install fails like this:

/usr/bin/install -c -m 644 option.bc '/usr/lib/postgresql/11/lib/bitcode'/influxdb_fdw/./
/usr/bin/install -c -m 644 deparse.bc '/usr/lib/postgresql/11/lib/bitcode'/influxdb_fdw/./
/usr/bin/install -c -m 644 influxdb_query.bc '/usr/lib/postgresql/11/lib/bitcode'/influxdb_fdw/./
/usr/bin/install -c -m 644 influxdb_fdw.bc '/usr/lib/postgresql/11/lib/bitcode'/influxdb_fdw/./
/usr/bin/install -c -m 644 query.a '/usr/lib/postgresql/11/lib/bitcode'/influxdb_fdw/./
cd '/usr/lib/postgresql/11/lib/bitcode' && /usr/lib/llvm-6.0/bin/llvm-lto -thinlto -thinlto-action=thinlink -o influxdb_fdw.index.bc influxdb_fdw/option.bc influxdb_fdw/deparse.bc influxdb_fdw/influxdb_query.bc influxdb_fdw/influxdb_fdw.bc influxdb_fdw/query.a
error: Invalid bitcode signature
/usr/lib/postgresql/11/lib/pgxs/src/makefiles/pgxs.mk:229: recipe for target 'install' failed
make: *** [install] Error 1

I'm on ubuntu xenial, using postgres 11.

If I edit the Makefile after running the first 'make', and remove 'query.a' from the OBJS, 'make install' works, and I can actually do a 'create extension influxdb_fdw' in the DB.

mochizk commented 5 years ago

Thanks for creating the issue. I think you are using llvm with lto. Could you build without lto?

taterhead commented 5 years ago

Any idea how to do that? I've tried some googling as well as checking this Makefile and the PGXS Makefile for flags, but I'm definitely not super familiar with LLVM and PGXS

mochizk commented 5 years ago

Could you execute pg_config and attach output?

taterhead commented 5 years ago

Here it is:

BINDIR = /usr/lib/postgresql/11/bin
DOCDIR = /usr/share/doc/postgresql-doc-11
HTMLDIR = /usr/share/doc/postgresql-doc-11
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/11/server
LIBDIR = /usr/lib/x86_64-linux-gnu
PKGLIBDIR = /usr/lib/postgresql/11/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/11/man
SHAREDIR = /usr/share/postgresql/11
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/11/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=/usr/include' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=/usr/lib/x86_64-linux-gnu' '--libexecdir=/usr/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' 'PYTHON=/usr/bin/python' '--mandir=/usr/share/postgresql/11/man' '--docdir=/usr/share/doc/postgresql-doc-11' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/11' '--bindir=/usr/lib/postgresql/11/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 11.3-1.pgdg16.04+1)' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' '--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' '--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' 'TAR=/bin/tar' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -pie -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' '--with-includes=/usr/include/mit-krb5' '--with-libs=/usr/lib/mit-krb5' '--with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5' 'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
CC = gcc
CPPFLAGS = -I/usr/include/x86_64-linux-gnu -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/mit-krb5
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -pie -fno-omit-frame-pointer
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-6.0/lib -L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,--as-needed
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgcommon -lpgport -lpthread -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -ledit -lrt -lcrypt -ldl -lm 
VERSION = PostgreSQL 11.3 (Ubuntu 11.3-1.pgdg16.04+1)
mochizk commented 5 years ago

Thanks. I'm able to reproduce it with ./configure --with_llvm. Could you try make install USE_PGXS=1 with_llvm=no?

taterhead commented 5 years ago

yep, that fixed it! Just tested from a clean VM build. Thanks!

mochizk commented 5 years ago

Thanks.