Skip to content

staticlib does not include lua lib inside of it #728

Description

@Kamilcuk

Hello. I have the following cargo.toml:

[lib]
name = "l_builtin"
crate-type = ["staticlib"]
[dependencies]
mlua = { version = "0.10", features = ["lua51", "vendored"] }
# mlua = { version = "0.11", features = ["lua51", "vendored"] }
# mlua = { version = "0.12", features = ["lua51", "vendored"] }

Then I use if from cmakelists.txt with corrosion:

corrosion_import_crate(
    MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml
    IMPORTED_CRATES L_BUILTIN_RS_TARGETS
    FEATURES ${L_BUILTIN_RS_FEATURES}
)
add_library(L_builtin_module MODULE ...)
target_link_libraries(L_builtin_module PRIVATE .... ${L_BUILTIN_RS_TARGETS})

Bottom line, the goal is to embed lua into a rust .a library and that to embed that inside a .so file.

With mlua version 0.10 every is ok and it works.

However, when I switch into mlua version 0.11 and 0.12, execute cargo update, clean the build directory, and recompile, I get undefined symbols:

cannot open shared object build/system/build//L_builtin.so: build/system/build//L_builtin.so: undefined symbol: lua_atpanic

On version 0.11 or version 0.12 then the liblua5.1.a of mlua-sys contains the symbol:

$ nm ./cargo/L_builtin_756e9/x86_64-unknown-linux-gnu/debug/build/mlua-sys-c6e31cfd437d18a3/out/lib/liblua5.1.a | grep lua_atpanic
0000000000000000 T lua_atpanic
                 U lua_atpanic

When building with mlua verison 0.11 or 0.12, the .a file library build by corrosion build by cargo does not include the lua_atpanic symbols inside of it.

$ nm ./cargo/L_builtin_756e9/x86_64-unknown-linux-gnu/debug/libl_builtin.a | grep lua_atpanic
                 U lua_atpanic

However, when building with mlua version 0.10, then symbol is included inside the .a library build by corrosion build by cargo:

$ nm ./cargo/L_builtin_756e9/x86_64-unknown-linux-gnu/debug/libl_builtin.a | grep lua_atpanic
                 U lua_atpanic
0000000000000000 T lua_atpanic
                 U lua_atpanic

Is there anything wrong I am doing with features = ["lua51", "vendored"] to include the lua inside the .a library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions