I was excited to see the recent work [1] regarding link-time optimization 
between C or C++ and Rust code.  In Servo we access JavaScript objects through 
small C++ functions [2] declared as extern "C".  It would be great if the code 
for these accessors (which depends on the C++ ABI and the contents of the 
SpiderMonkey header files) could be inlined into Rust functions.

The main problem I see with the approach described in [1] is that it requires a 
special build process for the whole Rust program.  One compiles Rust to LLVM 
bytecode and then links using clang.  So my question is: how can we make a 
mixed C++/Rust library which exposes LTO for the C++ components, and yet can be 
used like any other Rust library crate?  I suppose we would have to compile the 
C++ with clang and then store the resulting LLVM bytecode as metadata in the 
library crate's shared object.  Does rustc already do inlining from LLVM 
bytecode stored as metadata, or does it store Rust ASTs only?

I would be interested to hear any thoughts regarding this project, in 
particular estimates of how difficult or time-consuming it would be.

Thanks,
keegan

[1] https://github.com/mozilla/rust/wiki/Mixed-language-link-time-optimization
[2] https://github.com/mozilla-servo/rust-mozjs/blob/master/jsglue.cpp#L269
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to