Link against system-provided libpg_query and xxhash, and respect our CFLAGS. --- a/ext/pg_query/extconf.rb +++ b/ext/pg_query/extconf.rb @@ -5,9 +5,11 @@ require 'open-uri' require 'pathname' -$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/] +$CFLAGS << " -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable" -$CFLAGS << " -I#{File.join(__dir__, 'include')} -O3 -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable -g" +$LDFLAGS << " -lpg_query -lxxhash" SYMFILE = File.join(__dir__, 'pg_query_ruby.sym') if RUBY_PLATFORM =~ /darwin/ --- 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);