Skip to content

Instantly share code, notes, and snippets.

@hennevogel
Last active February 9, 2022 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hennevogel/d22b0e16a87b32914075754f700e0934 to your computer and use it in GitHub Desktop.
Save hennevogel/d22b0e16a87b32914075754f700e0934 to your computer and use it in GitHub Desktop.
pg compile error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20220209-7003-7jrib8pg-1.3.1/gems/pg-1.3.1/ext
/usr/bin/ruby.ruby3.1 -I /usr/lib64/ruby/3.1.0 -r ./siteconf20220209-7003-dspmoi.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for whether -Wl,-rpath,/usr/lib/postgresql12/lib64 is accepted as LDFLAGS... yes
Using libpq from /usr/lib/postgresql12/lib64
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for PQenterPipelineMode()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for rb_gc_mark_movable()... yes
checking for rb_io_wait()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile
current directory: /tmp/bundler20220209-7003-7jrib8pg-1.3.1/gems/pg-1.3.1/ext
make DESTDIR\= clean
current directory: /tmp/bundler20220209-7003-7jrib8pg-1.3.1/gems/pg-1.3.1/ext
make DESTDIR\=
compiling gvl_wrappers.c
compiling pg.c
In file included from /usr/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26:0,
from /usr/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23,
from /usr/include/ruby-3.1.0/ruby/internal/arithmetic.h:23,
from /usr/include/ruby-3.1.0/ruby/ruby.h:27,
from /usr/include/ruby-3.1.0/ruby.h:38,
from pg.h:21,
from pg.c:49:
pg.c: In function 'Init_pg_ext':
pg.c:554:66: error: 'PGRES_PIPELINE_SYNC' undeclared (first use in this function); did you mean 'PGRES_POLLING_OK'?
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:350:30: note: in definition of macro 'INT2FIX'
__builtin_constant_p(i), \
^
pg.c:554:66: note: each undeclared identifier is reported only once for each function it appears in
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:350:30: note: in definition of macro 'INT2FIX'
__builtin_constant_p(i), \
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:349:5: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr( \
^
pg.c:554:58: note: in expansion of macro 'INT2FIX'
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
^~~~~~~
pg.c:560:69: error: 'PGRES_PIPELINE_ABORTED' undeclared (first use in this function); did you mean 'PGRES_PIPELINE_SYNC'?
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_ABORTED", INT2FIX(PGRES_PIPELINE_ABORTED));
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:350:30: note: in definition of macro 'INT2FIX'
__builtin_constant_p(i), \
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:349:5: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr( \
^
pg.c:560:61: note: in expansion of macro 'INT2FIX'
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_ABORTED", INT2FIX(PGRES_PIPELINE_ABORTED));
^~~~~~~
pg.c:687:61: error: 'PQ_PIPELINE_ON' undeclared (first use in this function); did you mean 'PGRES_PIPELINE_SYNC'?
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ON", INT2FIX(PQ_PIPELINE_ON));
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:350:30: note: in definition of macro 'INT2FIX'
__builtin_constant_p(i), \
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:349:5: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr( \
^
pg.c:687:53: note: in expansion of macro 'INT2FIX'
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ON", INT2FIX(PQ_PIPELINE_ON));
^~~~~~~
pg.c:693:62: error: 'PQ_PIPELINE_OFF' undeclared (first use in this function); did you mean 'PQ_PIPELINE_ON'?
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_OFF", INT2FIX(PQ_PIPELINE_OFF));
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:350:30: note: in definition of macro 'INT2FIX'
__builtin_constant_p(i), \
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:349:5: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr( \
^
pg.c:693:54: note: in expansion of macro 'INT2FIX'
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_OFF", INT2FIX(PQ_PIPELINE_OFF));
^~~~~~~
pg.c:700:66: error: 'PQ_PIPELINE_ABORTED' undeclared (first use in this function); did you mean 'PGRES_PIPELINE_ABORTED'?
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ABORTED", INT2FIX(PQ_PIPELINE_ABORTED));
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:350:30: note: in definition of macro 'INT2FIX'
__builtin_constant_p(i), \
^
/usr/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:349:5: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr( \
^
pg.c:700:58: note: in expansion of macro 'INT2FIX'
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ABORTED", INT2FIX(PQ_PIPELINE_ABORTED));
^~~~~~~
make: *** [Makefile:255: pg.o] Error 1
make failed, exit code 2
Gem files will remain installed in /tmp/bundler20220209-7003-7jrib8pg-1.3.1/gems/pg-1.3.1 for inspection.
Results logged to /tmp/bundler20220209-7003-7jrib8pg-1.3.1/extensions/x86_64-linux/3.1.0/pg-1.3.1/gem_make.out
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:44:in `block in make'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:36:in `each'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:36:in `make'
/usr/lib64/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
/usr/lib64/ruby/3.1.0/tempfile.rb:317:in `open'
/usr/lib64/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
/usr/lib64/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib64/ruby/3.1.0/rubygems/installer.rb:847:in `build_extensions'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/source/rubygems.rb:204:in `install'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/worker.rb:62:in `apply_func'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/worker.rb:54:in `loop'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/worker.rb:54:in `process_queue'
/usr/lib64/ruby/gems/3.1.0/gems/bundler-2.3.3/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing pg (1.3.1), and Bundler cannot continue.
In Gemfile:
pg
@hennevogel
Copy link
Author

hennevogel commented Feb 8, 2022

This is with

GCC

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/7/lto-wrapper
OFFLOAD_TARGET_NAMES=hsa:nvptx-none
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,ada,go --enable-offload-targets=hsa,nvptx-none, --without-cuda-driver --enable-checking=release --disable-werror --with-gxx-include-dir=/usr/include/c++/7 --enable-ssp --disable-libssp --disable-libvtv --disable-libcc1 --disable-plugin --with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-7 --without-system-libunwind --enable-multilib --with-arch-32=x86-64 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 7.5.0 (SUSE Linux) 

pg_config

$ pg_config 
BINDIR = /usr/lib/postgresql12/bin
DOCDIR = /usr/share/doc/packages/postgresql12
HTMLDIR = /usr/share/doc/packages/postgresql12
INCLUDEDIR = /usr/include/pgsql
PKGINCLUDEDIR = /usr/include/pgsql
INCLUDEDIR-SERVER = /usr/include/pgsql/server
LIBDIR = /usr/lib/postgresql12/lib64
PKGLIBDIR = /usr/lib/postgresql12/lib64
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/man
SHAREDIR = /usr/share/postgresql12
SYSCONFDIR = /etc/postgresql
PGXS = /usr/lib/postgresql12/lib64/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--host=x86_64-suse-linux-gnu' '--build=x86_64-suse-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/lib' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--bindir=/usr/lib/postgresql12/bin' '--libdir=/usr/lib/postgresql12/lib64' '--includedir=/usr/include/pgsql' '--datadir=/usr/share/postgresql12' '--docdir=/usr/share/doc/packages/postgresql12' '--mandir=/usr/share/man' '--disable-rpath' '--enable-nls' '--enable-thread-safety' '--enable-integer-datetimes' '--with-python' '--with-perl' '--with-tcl' '--with-tclconfig=/usr/lib64' '--with-pam' '--with-uuid=e2fs' '--with-libxml' '--with-libxslt' '--with-systemd' '--with-selinux' '--with-icu' '--with-llvm' '--with-openssl' '--with-ldap' '--with-gssapi' '--with-krb5' '--with-system-tzdata=/usr/share/zoneinfo' 'build_alias=x86_64-suse-linux-gnu' 'host_alias=x86_64-suse-linux-gnu' 'CFLAGS=-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g' 'CXXFLAGS=-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g' 'PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig' 'PYTHON=python3'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE -I/usr/include/libxml2
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g
CFLAGS_SL = -fPIC
LDFLAGS = -L/usr/lib64 -Wl,--as-needed
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgcommon -lpgport -lpthread -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lrt -lcrypt -ldl -lm 
VERSION = PostgreSQL 12.9
$ rpm -qf /usr/include/pgsql/*|sort -u
postgresql12-devel-12.9-8.26.1.x86_64
postgresql12-server-devel-12.9-8.26.1.x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment