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

Use -exported_symbol on macOS #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cho-m
Copy link

@cho-m cho-m commented Nov 6, 2024

--version-script is not supported on macOS ld while -export-symbols-regex seems to be specific to libtool. Previous macOS ld may have skipped this but Xcode 16 fails:

clang: error: unknown argument: '-export-symbols-regex=^jose_.*'

macOS instead has:

  • -exported_symbol <symbol>
  • -exported_symbols_list <filename>

Could alternatively use -exported_symbols_list and hardcode every name similar to libjose.map, but there is a good chance of it going out-of-sync without proper checks as it needs a different file with a flat list of symbols/patterns

May want to consider using visibility attributes instead which should allow better cross-compatibility.


The build failure was seen in Homebrew when trying to build jose on Sequoia (Xcode 16, based on LLVM 17).

Taking a look at binaries built from older Xcode, the flags were most likely never used, e.g.

nm -gU lib/libjose.dylib | grep -v jose
0000000000010ad6 T _add_entity
000000000001090b T _bn_decode
0000000000010917 T _bn_decode_json
000000000001099a T _bn_encode
0000000000010a26 T _bn_encode_json
0000000000010d3d T _copy_val
0000000000005810 T _encode_protected
0000000000005891 T _handle_zip_enc
0000000000006b84 T _hsh
0000000000006d03 T _hsh_buf
0000000000006ccd T _hsh_io
0000000000010810 T _str2enum
0000000000005886 T _zero
0000000000005997 T _zip_in_protected_headernm -gU lib/libjose.dylib | grep jose | wc -l
      59

Doing a build with -exported_symbol

nm -gU lib/libjose.dylib | grep -v josenm -gU lib/libjose.dylib | grep jose | wc -l
      59

`--version-script` is not supported on macOS ld while
`-export-symbols-regex` seems to be specific to libtool.
Previous macOS ld may have skipped this but Xcode 16 fails:
```
clang: error: unknown argument: '-export-symbols-regex=^jose_.*'
```

macOS instead has:
* `-exported_symbol <symbol>`
* `-exported_symbols_list <filename>`
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.

1 participant