Closed
Description
Perhaps the issue description isn't exactly correct, but here's the gist:
Expected behavior: when a cdylib crate contains pub use foo;
then any pub extern "C"
functions within foo
should be present in the generated dynamic library. This appears currently to not be the case.
To reproduce:
(using cargo 1.61.0 (a028ae4 2022-04-29) and rustc 1.61.0 (fe5b13d 2022-05-18) on Linux, using stable-x86_64-unknown-linux-gnu toolchain)
Set up a folder-structure (with the shown file content) as follows:
mydylib
├── Cargo.lock
├── Cargo.toml
├── foo
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
└── src
└── lib.rs
------------------mydylib/Cargo.toml:
[package]
name = "mydylib"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
foo = { path = "foo" }
[lib]
crate-type = ["cdylib"]
------------------mydylib/foo/Cargo.toml:
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[lib]
crate-type = ["rlib"]
------------------mydylib/src/lib.rs:
pub use foo;
#[no_mangle]
pub extern "C" fn hello() {
println!("Hello World!");
}
------------------mydylib/foo/src/lib.rs:
#[no_mangle]
pub extern "C" fn wrapped_hello() {
println!("Hello Wrapped World!");
}
Results:
$ cd mydylib
$ RUSTC_LOG=rustc_codegen_ssa::back::link=info cargo build
Compiling foo v0.1.0 (/home/user/tmp/mydylib/foo)
INFO rustc_codegen_ssa::back::link preparing rlib to "/home/user/tmp/mydylib/target/debug/deps/libfoo-f3e99f1b7ea9e90d.rlib"
Compiling mydylib v0.1.0 (/home/user/tmp/mydylib)
INFO rustc_codegen_ssa::back::link preparing Cdylib to "/home/user/tmp/mydylib/target/debug/deps/libmydylib.so"
INFO rustc_codegen_ssa::back::link "cc" "-Wl,--version-script=/tmp/rustcO88MJl/list" "-m64" "/home/user/tmp/mydylib/target/debug/deps/mydylib.2hfarbmypcuef87x.rcgu.o" "/home/user/tmp/mydylib/target/debug/deps/mydylib.jvr9udtwgdjffuy.rcgu.o" "/home/user/tmp/mydylib/target/debug/deps/mydylib.2po762jn48xj89vh.rcgu.o" "-Wl,--as-needed" "-L" "/home/user/tmp/mydylib/target/debug/deps" "-L" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/user/tmp/mydylib/target/debug/deps/libfoo-f3e99f1b7ea9e90d.rlib" "-Wl,--start-group" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-05b39ac0cb4c5688.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-ccaa149b737d6503.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-a94a6388c153126b.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-1ecfa264246b85c6.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-ee710154a50440b8.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-f09986d873ea8592.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-f3521e20c99619ab.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-df6036c77d75ce21.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-24f91c1a1dfc7e13.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-bffcc61991adb202.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-cf22313353d8663e.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-c45fb100f99430e9.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-0cdc47a8a81950ea.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-f1e158606c4c82f6.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-0b608b5ef4df0ec4.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-b8438dc0bcbbcc08.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-70e2ae036775ff2f.rlib" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-815d281f7068a893.rlib" "-Wl,--end-group" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-377835cfab8dae0d.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/user/tmp/mydylib/target/debug/deps/libmydylib.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
INFO rustc_codegen_ssa::back::link linker stderr:
INFO rustc_codegen_ssa::back::link linker stdout:
Finished dev [unoptimized + debuginfo] target(s) in 2.73s
$ nm target/debug/libmydylib.so | grep wrapped # NO OUTPUT, BUT WE WANT TO SEE "... T wrapped_hello"
Metadata
Metadata
Assignees
Labels
No labels