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

Fix C module loading on windows #38

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

Conversation

leso-kn
Copy link
Contributor

@leso-kn leso-kn commented Oct 27, 2023

This PR addresses #39 and introduces 2 changes to the windows plain lua build:

  • Installs luaxx.dll next to lua.exe (bin/) where it can be picked up at runtime by native libraries linked against it
  • Links lua.exe against luaxx.dll to avoid "multiple lua VMs" errors

@hishamhm
Copy link
Contributor

hishamhm commented Mar 8, 2024

@leafo I've tested this in the CI runs for luasystem at lunarmodules/luasystem#17 and I confirm this works! Without this patch, the resulting binary can only run pure Lua code (which meant LuaRocks ran fine, but then the C-based packages built by it wouldn't load in the interpreter).

Comment on lines +189 to 190
await install_files(pathJoin(luaInstallPath, "bin"), luaExtractPath, [ "lua.exe", "luac.exe", dllFile ])
await install_files(pathJoin(luaInstallPath, "lib"), luaExtractPath, [ dllFile, libFile ])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the dll should be installed in only one place, not in both lib and bin:

Suggested change
await install_files(pathJoin(luaInstallPath, "bin"), luaExtractPath, [ "lua.exe", "luac.exe", dllFile ])
await install_files(pathJoin(luaInstallPath, "lib"), luaExtractPath, [ dllFile, libFile ])
await install_files(pathJoin(luaInstallPath, "bin"), luaExtractPath, [ "lua.exe", "luac.exe", dllFile ])
await install_files(pathJoin(luaInstallPath, "lib"), luaExtractPath, [ libFile ])

Copy link
Contributor

@hishamhm hishamhm May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying the file in both places won't hurt (it's a small file in a temporary CI environment), and I can't tell for certain that not copying the file to lib won't break someone else's flows which are relying on that file being there. What I do know is that this PR as is fixes the C module loading behavior.

@leafo Can we merge this as-is? Let's not get this held back on whether it produces a redundant file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply, must have overseen this. @hishamhm Agreed, I believe to remember seeing some linking problems with some rocks when the file was not present in lib, I think it was related to stub-libs on Windows / MSVC.

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.

4 participants