Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Init_pg_query from exported symbol map #256

Merged
merged 1 commit into from
Sep 17, 2022

Conversation

stanhu
Copy link
Contributor

@stanhu stanhu commented Sep 16, 2022

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 uses a specific symbol map file for FreeBSD.

Closes #255

@stanhu
Copy link
Contributor Author

stanhu commented Sep 16, 2022

@lfittl macOS 12.6 fixes a zero-day vulnerability, and it appears that XCode 14 tends to be upgraded with that. I think this fix might be needed soon as more people start to use a Ruby interpreter compiled under XCode 14.

@lfittl
Copy link
Member

lfittl commented Sep 17, 2022

@stanhu Hmm, I think this may require some more thinking, because the symbol name without the _ was an addition to fix the FreeBSD build: #222

Since we already have a special case for RUBY_PLATFORM =~ /darwin/ in extconf.rb we could either make a separate symbol file for macOS that only has the _ prefixed version, or (possibly better) we make a special file for FreeBSD and make the default to be only the _ prefixed version.

@stanhu stanhu changed the title Drop Init_pg_query from exported symbol map Drop Init_pg_query from exported symbol map for macOS builds Sep 17, 2022
`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 pganalyze#222, FreeBSD needed `Init_pg_query`, so we uses a specific symbol
map file for FreeBSD.

Closes pganalyze#255
@stanhu
Copy link
Contributor Author

stanhu commented Sep 17, 2022

@lfittl Ah, thanks. I should have looked at the history to see that. I added a FreeBSD symbol file.

@stanhu stanhu changed the title Drop Init_pg_query from exported symbol map for macOS builds Drop Init_pg_query from exported symbol map Sep 17, 2022
@lfittl lfittl merged commit 684aa77 into pganalyze:main Sep 17, 2022
@lfittl
Copy link
Member

lfittl commented Sep 17, 2022

@stanhu Thanks!

In case you have the time, we'd also need to update the changelog for a new release - essentially a new version of #251 -- if you could work on that I should be able to stamp a release on Monday (otherwise I can also do that, just with a slight risk the release takes a bit longer)

@stanhu
Copy link
Contributor Author

stanhu commented Sep 17, 2022

@lfittl Sure, done in #257.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't install version 2.1.3 on MacOS 12.6 Monterey with ARM Apple Silicon
2 participants