Closed briantkelley closed 1 year ago
I don't think this is generally solvable in Rust (see attempts and commit messages in fb05e276682ee78a882c619895bb3388843062fc and 06b9ca90808e805ef27b46b433af2a428312a7e5).
The selector symbol must be emitted into each object file in which it's used and cannot be exported. But Rust defines the symbol once and assumes it's visible to the other translation units.
I think the only way the downstream linking problem can be fixed is to derive trait implementations for each object type. A general purpose derive procedural macro would likely leverage some bindgen
support (#4). Although I suspect this won't fix the parallel compilation problem.
Topic posted on the Rust Users forum: Per Object File Symbols (Objective-C FFI).
When multiple
codegen-units
are enabled, the linker can't find symbols generated via theselector!
macro, even if the symbols are.globl
. The crate should support parallel compilation and not rely on generating a single object file.Example Output: