Skip to content

Commit

Permalink
Drop Init_pg_query from exported symbol map for macOS builds
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
stanhu committed Sep 17, 2022
1 parent 6274182 commit 48bad9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/pg_query/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions ext/pg_query/pg_query_ruby_darwin.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_Init_pg_query

0 comments on commit 48bad9f

Please sign in to comment.