Skip to content

fix(lua): export all lua symbols on macos#159

Merged
tarleb merged 1 commit into
hslua:mainfrom
benniekiss:dyn_symbols
Apr 20, 2026
Merged

fix(lua): export all lua symbols on macos#159
tarleb merged 1 commit into
hslua:mainfrom
benniekiss:dyn_symbols

Conversation

@benniekiss

Copy link
Copy Markdown
Contributor

This PR fixes an issue where some lua symbols were not visible on macOS, causing errors when loading compiled modules. See the pandoc issue here: jgm/pandoc#11587

The linker flag in question is not documented in any official capacity, at least from what I could find. It was suggested by Claude after some lengthy debugging. Researching the flag, I came across a postgres mailing list thread, a meson bug report, and a wayback machine snapshot of some no-longer-published apple documentation. All indicate that this flag serves a similar purpose as the linux/freebsd export-dynamic flag.

I've tested this on macOS 26, building pandoc from source and directing it to use my fork. The symbols now seem appropriately exported, as loading my module succeeds!

I also tested to see if the issue was present on linux, but I could not reproduce it with a non-static build through the fedora repo. I also tested applying the flags to the pandoc binary, but that did not have any impact.

For consideration, this flag does not work on versions of macOS older than 10.7 (Lion), as mentioned in the meson issue, but that is quite an old version and probably not relevant in this instance.

* this fixes an issue where some lua symbols were
* not visible on macos, causing errors when loading
* compiled lua modules.
* see: jgm/pandoc#11587
@benniekiss benniekiss changed the title fix: export all lua symbols on macos fix(lua): export all lua symbols on macos Apr 18, 2026
@tarleb tarleb merged commit 82c983a into hslua:main Apr 20, 2026
5 checks passed
@tarleb

tarleb commented Apr 20, 2026

Copy link
Copy Markdown
Member

Thank you!

@tarleb

tarleb commented Apr 20, 2026

Copy link
Copy Markdown
Member

I'm wondering if we should make this the default for macOS instead of setting those linker flags only with export-dynamic. My understanding is that static builds are not possible on macOS the way they are on Linux, so export-dynamic should be implied in that case.

One question: could you check if this has a big effect on the pandoc executable size? Just to make sure that we're not suddenly exporting all symbols in a binary. If there's no noticeable difference, then we should probably make export-dynamic the default on macOS.

@benniekiss

Copy link
Copy Markdown
Contributor Author

can do! I'll follow up here

@benniekiss

benniekiss commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

So the version of pandoc I built with the patch is 270M, the version of pandoc in the most recent github release is 187M, and the homebrew version of pandoc is 260M.

It makes sense to me to make it the default option, since the flag wasn't even previously registered for macOS builds

EDIT: I also built pandoc locally without the patch, and it is the same size at 270M. I'm fairly certain it was a fresh build (running cabal clean, etc), so there seems to be no size difference.

@tarleb

tarleb commented Apr 20, 2026

Copy link
Copy Markdown
Member

Great, thank you. Could you set up a second PR for this?

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.

2 participants