Skip to content
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

Support Rust v0 mangling #1626

Open
ChoKyuWon opened this issue Feb 1, 2023 · 2 comments
Open

Support Rust v0 mangling #1626

ChoKyuWon opened this issue Feb 1, 2023 · 2 comments

Comments

@ChoKyuWon
Copy link
Contributor

For now, utils/demangle.c only care about the Itanium C++ ABI mangling rules.
However, Rust introduces a new mangling rule, v0 mangling. (See the RFC and PR)

For example, std::mem::align_of::<f64> mangles to _RINvNtC3std3mem8align_ofdE.
Note that this new mangling scheme starts with a new identifier, _R.

We need support for this new mangling scheme.

@namhyung
Copy link
Owner

namhyung commented Feb 1, 2023

What's the command line to enable the v0 mangling? It'd be nice if you share a result of uftrace + hello world in v0.

@ChoKyuWon
Copy link
Contributor Author

ChoKyuWon commented Feb 1, 2023

$ cargo new --bin v0_mangling && cd v0_mangling
$ RUSTFLAGS="-Zsymbol-mangling-version=v0" cargo build

$ uftrace -P. -F _RNvCskxQuv2bvxbZ_11v0_mangling4main ./target/debug/v0_mangling
# DURATION     TID     FUNCTION
            [3613655] | _RNvCskxQuv2bvxbZ_11v0_mangling4main() {
   0.120 us [3613655] |   _RNvMs2_NtCscoN4IID3Vv4_4core3fmtNtB5_9Arguments6new_v1CskxQuv2bvxbZ_11v0_mangling();
            [3613655] |   std::io::stdio::_print() {
            [3613655] |     std::sync::once::Once::call_inner() {
            [3613655] |       std::sync::once::Once::call_once_force::_{{closure}}() {
   0.090 us [3613655] |         __rdl_alloc();
   0.351 us [3613655] |       } /* std::sync::once::Once::call_once_force::_{{closure}} */
   0.090 us [3613655] |       _<std..sync..once..WaiterQueue as core..ops..drop..Drop>::drop();
   0.741 us [3613655] |     } /* std::sync::once::Once::call_inner */
            [3613655] |     _<&std..io..stdio..Stdout as std..io..Write>::write_fmt() {
   0.090 us [3613655] |       std::sys_common::remutex::current_thread_unique_ptr::X::__getit();
            [3613655] |       core::fmt::write() {
            [3613655] |         _<std..io..Write..write_fmt..Adapter<T> as core..fmt..Write>::write_str() {
            [3613655] |           _<std..io..buffered..linewritershim..LineWriterShim<W> as std..io..Write>::write_all() {
            [3613655] |             _<std..io..stdio..StdoutRaw as std..io..Write>::write_all() {
   6.954 us [3613655] |               std::io::Write::write_all();
   7.184 us [3613655] |             } /* _<std..io..stdio..StdoutRaw as std..io..Write>::write_all */
   7.464 us [3613655] |           } /* _<std..io..buffered..linewritershim..LineWriterShim<W> as std..io..Write>::write_all */
   7.675 us [3613655] |         } /* _<std..io..Write..write_fmt..Adapter<T> as core..fmt..Write>::write_str */
   7.855 us [3613655] |       } /* core::fmt::write */
   8.235 us [3613655] |     } /* _<&std..io..stdio..Stdout as std..io..Write>::write_fmt */
   9.268 us [3613655] |   } /* std::io::stdio::_print */
  10.591 us [3613655] | } /* _RNvCskxQuv2bvxbZ_11v0_mangling4main */

$ uftrace -P. -F v0_mangling::main ./target/debug/v0_mangling
# DURATION     TID     FUNCTION
            [3613773] | main() {
            [3613773] |   _RINvNtCsjaRYnC5jcmR_3std2rt10lang_startuECskxQuv2bvxbZ_11v0_mangling() {
            [3613773] |     std::rt::lang_start_internal() {
            [3613773] |       std::rt::init() {
            [3613773] |         std::sys::unix::init() {
            [3613773] |           std::sys::unix::stack_overflow::imp::init() {
   2.365 us [3613773] |             std::sys::unix::stack_overflow::imp::make_handler();
   3.447 us [3613773] |           } /* std::sys::unix::stack_overflow::imp::init */
   8.336 us [3613773] |         } /* std::sys::unix::init */
  54.595 us [3613773] |         std::sys::unix::thread::guard::init();
            [3613773] |         _<&str as alloc..ffi..c_str..CString..new..SpecNewImpl>::spec_new_impl() {
   0.220 us [3613773] |           __rdl_alloc();
   0.130 us [3613773] |           alloc::vec::Vec<T,A>::into_boxed_slice();
   0.871 us [3613773] |         } /* _<&str as alloc..ffi..c_str..CString..new..SpecNewImpl>::spec_new_impl */
            [3613773] |         alloc::sync::Arc<T>::new_uninit() {
   0.110 us [3613773] |           __rdl_alloc();
   0.331 us [3613773] |         } /* alloc::sync::Arc<T>::new_uninit */
            [3613773] |         std::thread::local::LocalKey<T>::with() {
   0.471 us [3613773] |           std::sys_common::thread_info::THREAD_INFO::__getit();
   0.651 us [3613773] |         } /* std::thread::local::LocalKey<T>::with */
  65.405 us [3613773] |       } /* std::rt::init */
            [3613773] |       _RNCINvNtCsjaRYnC5jcmR_3std2rt10lang_startuE0CskxQuv2bvxbZ_11v0_mangling() {
            [3613773] |         _RINvNtNtCsjaRYnC5jcmR_3std10sys_common9backtrace28___rust_begin_short_backtraceFEuuECskxQuv2bvxbZ_11v0_mangling() {
            [3613773] |           _RNvYFEuINtNtNtCscoN4IID3Vv4_4core3ops8function6FnOnceuE9call_onceCskxQuv2bvxbZ_11v0_mangling() {
            [3613773] |             _RNvCskxQuv2bvxbZ_11v0_mangling4main() {
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants