Skip to content

Commit

Permalink
Drop Init_pg_query from exported symbol map
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
```

In #222, FreeBSD needed `Init_pg_query`, so we FreeBSD uses its own
exported symbols file.

Closes #255
  • Loading branch information
stanhu committed Sep 17, 2022
1 parent 6274182 commit ca0b260
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ext/pg_query/extconf.rb
Expand Up @@ -11,7 +11,13 @@

$INCFLAGS = "-I#{File.join(__dir__, 'include')} " + $INCFLAGS

SYMFILE = File.join(__dir__, 'pg_query_ruby.sym')
SYMFILE =
if RUBY_PLATFORM =~ /freebsd/
File.join(__dir__, 'pg_query_ruby_freebsd.sym')
else
File.join(__dir__, 'pg_query_ruby.sym')
end

if RUBY_PLATFORM =~ /darwin/
$DLDFLAGS << " -Wl,-exported_symbols_list #{SYMFILE}" unless defined?(::Rubinius)
else
Expand Down
1 change: 0 additions & 1 deletion ext/pg_query/pg_query_ruby.sym
@@ -1,2 +1 @@
_Init_pg_query
Init_pg_query
2 changes: 2 additions & 0 deletions ext/pg_query/pg_query_ruby_freebsd.sym
@@ -0,0 +1,2 @@
_Init_pg_query
Init_pg_query

0 comments on commit ca0b260

Please sign in to comment.