From 48bad9f82621edadf20ea835fbfd1ecb9d9e03c3 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 15 Sep 2022 21:40:07 -0700 Subject: [PATCH] Drop `Init_pg_query` from exported symbol map for macOS builds `Init_pg_query` isn't actually exported, but `_Init_pg_query` is: ``` % nm pg_query_ruby.o | grep Init 0000000000000000 T _Init_pg_query 0000000000003b40 b _Init_pg_query.rb_intern_id_cache ``` A Ruby compiler compiled with XCode 14 without the flag `-undefined,dynamic_lookup` will see this error: ``` linking shared-object pg_query/pg_query.bundle Undefined symbols for architecture arm64: "Init_pg_query", referenced from: -exported_symbol[s_list] command line option (maybe you meant: _Init_pg_query) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [pg_query.bundle] Error 1 ``` Closes #255 --- ext/pg_query/extconf.rb | 7 ++++--- ext/pg_query/pg_query_ruby_darwin.sym | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 ext/pg_query/pg_query_ruby_darwin.sym diff --git a/ext/pg_query/extconf.rb b/ext/pg_query/extconf.rb index ee6936e9..87fdcb27 100644 --- a/ext/pg_query/extconf.rb +++ b/ext/pg_query/extconf.rb @@ -11,11 +11,12 @@ $INCFLAGS = "-I#{File.join(__dir__, 'include')} " + $INCFLAGS -SYMFILE = File.join(__dir__, 'pg_query_ruby.sym') if RUBY_PLATFORM =~ /darwin/ - $DLDFLAGS << " -Wl,-exported_symbols_list #{SYMFILE}" unless defined?(::Rubinius) + symfile = File.join(__dir__, 'pg_query_ruby_darwin.sym') + $DLDFLAGS << " -Wl,-exported_symbols_list #{symfile}" unless defined?(::Rubinius) else - $DLDFLAGS << " -Wl,--retain-symbols-file=#{SYMFILE}" + symfile = File.join(__dir__, 'pg_query_ruby.sym') + $DLDFLAGS << " -Wl,--retain-symbols-file=#{symfile}" end create_makefile 'pg_query/pg_query' diff --git a/ext/pg_query/pg_query_ruby_darwin.sym b/ext/pg_query/pg_query_ruby_darwin.sym new file mode 100644 index 00000000..ff9b69a6 --- /dev/null +++ b/ext/pg_query/pg_query_ruby_darwin.sym @@ -0,0 +1 @@ +_Init_pg_query