-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiling to Shared Library doesn't always expose reexported symbols #50007
Comments
Maybe a duplicate of #36342? |
It's not a duplicate of #36342, which is about reexporting functions defined in C AFAICT. We've been struggling with this in https://github.com/mozilla/application-services. This doesn't seem to happen with all targets. In particular, I have a simple reproducable case at https://github.com/thomcc/megazord/tree/simple-bug-repro (e.g. the simple-bug-repro branch of that repository). An explanation for how to use it to reproduce the issue is in the README.md. It's worth noting that if you turn on LTO, the issue does not manifest (all symbols are present), presumably due to it being a single compilation unit at that point (thanks to the reporter for pointing this out to me, I did not realize it initially). |
For more context: the Android toolchains are all specifying a stand-alone Android NDK toolchain, in particular a clang-based toolchain. I believe our Desktop targets (like |
The right fix here might be that the relevant extern blocks should get |
@Mark-Simulacrum This issue is about no_mangle symbols from another crate that get brought in by |
Heads up - this hits us in https://github.com/gfx-rs/wgpu as well. Very annoying and inconvenient, would very much appreciate any progress here! |
Hitting this issue as well. My use-case is exporting some functions from my executable, then loading a dynamic library that needs to link to those symbols. |
After `record.rs` was split into multiple modules, the C API disappeared from the compiled .so library. This is likely due to this compiler bug: rust-lang/rust#50007 As a workaround until the bug is fixed, we move the API from `record/c_api.rs` to `record/mod.rs`.
After `record.rs` was split into multiple modules, the C API disappeared from the compiled .so library. This is likely due to this compiler bug: rust-lang/rust#50007 As a workaround until the bug is fixed, we move the API from `record/c_api.rs` to `record/mod.rs`.
Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi` Due to how linking works and hides symbols the symbols from `glean_ffi` might not be re-exported and thus not usable. By forcing use of _at least one_ symbol in an exported function the functions will also be rexported. This is only required for debug builds (and `debug_assertions` is the closest thing we have to check that). In release builds we rely on LTO builds to take care of it. As the tests will use libglean_ffi functionality running the tests should ensure this actually happens. See rust-lang/rust#50007
Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi` Due to how linking works and hides symbols the symbols from `glean_ffi` might not be re-exported and thus not usable. By forcing use of _at least one_ symbol in an exported function the functions will also be rexported. This is only required for debug builds (and `debug_assertions` is the closest thing we have to check that). In release builds we rely on LTO builds to take care of it. As the tests will use libglean_ffi functionality running the tests should ensure this actually happens. See rust-lang/rust#50007
Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi` Due to how linking works and hides symbols the symbols from `glean_ffi` might not be re-exported and thus not usable. By forcing use of _at least one_ symbol in an exported function the functions will also be rexported. This is only required for debug builds (and `debug_assertions` is the closest thing we have to check that). In release builds we rely on LTO builds to take care of it. As the tests will use libglean_ffi functionality running the tests should ensure this actually happens. See rust-lang/rust#50007
Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi` Due to how linking works and hides symbols the symbols from `glean_ffi` might not be re-exported and thus not usable. By forcing use of _at least one_ symbol in an exported function the functions will also be rexported. This is only required for debug builds (and `debug_assertions` is the closest thing we have to check that). In release builds we rely on LTO builds to take care of it. As the tests will use libglean_ffi functionality running the tests should ensure this actually happens. See rust-lang/rust#50007
Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi` Due to how linking works and hides symbols the symbols from `glean_ffi` might not be re-exported and thus not usable. By forcing use of _at least one_ symbol in an exported function the functions will also be rexported. This is only required for debug builds (and `debug_assertions` is the closest thing we have to check that). In release builds we rely on LTO builds to take care of it. As the tests will use libglean_ffi functionality running the tests should ensure this actually happens. See rust-lang/rust#50007
This can be used to work around [rust-lang#50007](rust-lang/rust#50007), which is getting to be more and more of an issue on the desktop JS project.
This can be used to work around [rust-lang#50007](rust-lang/rust#50007), which is getting to be more and more of an issue on the desktop JS project.
This can be used to work around [rust-lang#50007](rust-lang/rust#50007), which is getting to be more and more of an issue on the desktop JS project. Updated `uniffi::interface` and some of the fixtures so that we can test this.
This can be used to work around [rust-lang#50007](rust-lang/rust#50007), which is getting to be more and more of an issue on the desktop JS project. Updated `uniffi::interface` and some of the fixtures so that we can test this.
This can be used to work around [rust-lang#50007](rust-lang/rust#50007), which is getting to be more and more of an issue on the desktop JS project. Updated `uniffi::interface` and some of the fixtures so that we can test this.
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? ``@petrochenkov`` cc ``@carbotaniuman``
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? ```@petrochenkov``` cc ```@carbotaniuman```
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
When changing something trivial in the hello world project created by `cargo pgx new`, it would take ~20 seconds to compile a dev build of the generated crate on my machine. This seemed way slower than it should be. It turns out that the thin LTO setting greatly inrceases compilation times. By disabling it, compilation time of the crate is only 1 second. As far as I can tell this setting was enabled initially as a workaround for this bug in Rust: rust-lang/rust#50007 Since this bug has been fixed since Rust 1.62, and current stable Rust is version 1.67, this PR removes the workaround.
When changing something trivial in the hello world project created by `cargo pgx new`, it would take ~20 seconds to compile a dev build of the generated crate on my machine. This seemed way slower than it should be. It turns out that the thin LTO setting greatly inrceases compilation times. By disabling it, compilation time of the crate is only 1 second. As far as I can tell this setting was enabled initially as a workaround for this bug in Rust: rust-lang/rust#50007 Since this bug has been fixed since Rust 1.62, and current stable Rust is version 1.67, this PR removes the workaround.
When changing something trivial in the hello world project created by `cargo pgx new`, it would take ~20 seconds to compile a dev build of the generated crate on my machine. This seemed way slower than it should be. It turns out that the thin LTO setting greatly inrceases compilation times. By disabling it, compilation time of the crate is only 1 second. As far as I can tell this setting was enabled initially as a workaround for this bug in Rust: rust-lang/rust#50007 Since this bug has been fixed since Rust 1.62, and current stable Rust is version 1.67, this PR removes the workaround.
When changing something trivial in the hello world project created by `cargo pgx new`, it would take ~20 seconds to compile a dev build of the generated crate on my machine. This seemed way slower than it should be. It turns out that the thin LTO setting greatly inrceases compilation times. By disabling it, compilation time of the crate is only 1 second. As far as I can tell this setting was enabled initially as a workaround for this bug in Rust: rust-lang/rust#50007 Since this bug has been fixed since Rust 1.62, and current stable Rust is version 1.67, this PR removes the workaround.
Consider the following:
We have 2 crates, rlib
helper
and the shared libraryfoo
that depends on thehelper
crate. The helper crate's lib.rs looks like this:The shared library's lib.rs looks like this:
The code is then compiled to a shared library. The bla symbol is not exported. That does not seem intentional.
The text was updated successfully, but these errors were encountered: