Link against system-provided libpg_query and xxhash, and respect our CFLAGS. --- a/ext/pg_query/extconf.rb +++ b/ext/pg_query/extconf.rb @@ -7,11 +7,11 @@ $objs = Dir.glob(File.join(__dir__, '*.c')).map { |f| Pathname.new(f).sub_ext('.o').to_s } +$CFLAGS << " #{ENV["CFLAGS"]}" +$CFLAGS << " -O3" unless $CFLAGS[/-O\d/] -# -Wno-deprecated-non-prototype avoids warnings on Clang 15.0+, this can be removed in Postgres 16: -# https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1c27d16e6e5c1f463bbe1e9ece88dda811235165 -$CFLAGS << " -fvisibility=hidden -O3 -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable -Wno-clobbered -Wno-sign-compare -Wno-discarded-qualifiers -Wno-deprecated-non-prototype -Wno-unknown-warning-option -g" +$CFLAGS << " -fvisibility=hidden -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable -Wno-clobbered -Wno-sign-compare -Wno-discarded-qualifiers" -$INCFLAGS = "-I#{File.join(__dir__, 'include')} " + $INCFLAGS +$LDFLAGS << " -lpg_query -lxxhash" SYMFILE = if RUBY_PLATFORM =~ /freebsd/ --- a/ext/pg_query/pg_query_ruby.c +++ b/ext/pg_query/pg_query_ruby.c @@ -1,5 +1,5 @@ -#include "pg_query.h" -#include "xxhash/xxhash.h" +#include +#include #include void raise_ruby_parse_error(PgQueryProtobufParseResult result);