-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
Using x86_64-unknown-linux-musl as a target for a module #85
Comments
Hmm, it should be possible. You probably need to build it inside docker on alpine image. |
Looks like it should be possible with this feature enabled, but it still requires libgcc as well: rust-lang/rust#82521 export RUSTFLAGS="-C target-feature=-crt-static"
cargo build --release --target x86_64-unknown-linux-musl |
It compiles and loads, which is great! I'm getting runtime errors right now, but I'm going to assume that this is user error on my part and am closing this out. If I dig in deeper and this turns out to be something else, I'll reopen. In case this does work just fine, you might want to add a note in the readme that you'll need the rust flags above as otherwise cargo rejects trying to build the module with a crate type of cdylib. |
Yeah, I have plan to publish even more comprehensive doc than readme/docs.rs |
@khvzak this may still not be compatible without installing a full-blown On Alpine, I installed
|
Okay, actually, it looks like if you build on the native machine - or in my case within the alpine docker container - the So something about the cross build using target |
@chipsenkbeil I think you still should be able to build a Lua module on x86_64-glibc machine, but using musl toolchain. Toolchain: https://musl.cc/x86_64-linux-musl-cross.tgz |
I've give that a try. I'm building both the gnu and musl Lua modules on the same Github runner. I had assumed that the change in target would also change the cc and linker used! |
@chipsenkbeil
and it produces library without requiring Unfortunately by default Rust uses just Could be related to rust-lang/cargo#4133 |
Closing this out as I think I finally got my deployment working with the extra flags per your rec. This is also out of scope for mlua and is actually a rust/cargo challenge. :) Appreciate all of your help here even though this wasn't an mlua problem! |
This is just an open question and I think the answer is no. Is it possible in some way to build a Lua module with musl as the target? If you try to build a
cdylib
, you get the immediate notification that the musl target doesn't support that crate type.You can use a
staticlib
crate type and it builds fine, but to my knowledge you cannot import*.a
or*.lib
(windows) using modulerequire(...)
in Lua. I've seen scattered mentioning of baking static libraries into programs that also embed lua like Lua EPICS module, but no mention for Lua 5.1+ or luajit about using them.With my lack of knowledge in the space, I'm assuming it doesn't make sense to link to a static library. The only reason this popped up for me is that some musl-based systems like Alpine linux don't have the needed libraries like ld-linux-x86-64.so for Lua to be able to load the module when built with the gnu target. This isn't a dealbreaker for me, but is a limitation of my move to a Lua module for distant.nvim.
The text was updated successfully, but these errors were encountered: