Skip to content

Tracking issue for the thiscall calling convention #42202

Closed

Description

@froydnj

Added in #42058, which fixes #42044 and related requests from other bugs.

This calling convention is the default calling convention for C++ instance methods in the (MSVC) Windows ABI. At the very least, bindgen (and its dependency syntex) need this to exist so they have a reasonable chance of representing C++ instance methods in an AST. thiscall is therefore important for the interop story between Rust and C++ on Windows.

I don't think you could actually write callable C++ instance methods in Rust for MSVC, since mangled names in MSVC contain characters that, AFAICT, are not legal in Rust identifiers ('?', for instance). But maybe there is cleverness around assigning assembly names to things that I am not aware of.

Activity

  1. ids1024 commented on May 25, 2017

    @ids1024
    Contributor

    But maybe there is cleverness around assigning assembly names to things that I am not aware of.

    If this doesn't exist, perhaps it warrants an RFC? In particular some kind of attribute to specify the symbol name as an alternative to no_mangle.

  2. froydnj commented on May 25, 2017

    @froydnj
    ContributorAuthor

    If this doesn't exist, perhaps it warrants an RFC? In particular some kind of attribute to specify the symbol name as an alternative to no_mangle.

    I think this sounds like an excellent idea!

  3. ids1024 commented on May 25, 2017

    @ids1024
    Contributor

    It looks like there's already an export_name attribute that does this. That probably would work.

  4. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 23, 2017
  5. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jul 22, 2017
  6. steveklabnik commented on Mar 12, 2019

    @steveklabnik
    Contributor

    Triage: not aware of any movement on stabilizing this.

  7. whatisaphone commented on Apr 25, 2019

    @whatisaphone
    Contributor

    not aware of any movement on stabilizing this

    I see what you did there, and I like it.

    More seriously, I'm just swinging by to say I use this feature independently of bindgen, and I hope it's stabilized one day (or at least sticks around in some form)

  8. MSxDOS commented on Sep 28, 2020

    @MSxDOS

    What's blocking stabilization of this?

  9. pravic commented on Dec 24, 2020

    @pravic
    Contributor

    The same question.

    cc @dtolnay to route this to an appropriate person.

  10. super-continent commented on Apr 19, 2021

    @super-continent

    Wondering the same myself, any updates on stabilizing this? Would be very nice to have access to in stable.

  11. zorftw commented on Jul 26, 2021

    @zorftw

    It's been rather long, why is still unstable?

  12. chorman0773 commented on Aug 22, 2021

    @chorman0773
    Contributor

    Indeed. I have a use for this in my compiler project https://github.com/LightningCreations/lccc, which would allow me to write bindings to the C++ api in rust on MSVC (which I am able to do on other major compilers, but need thiscall for i386 windows).

  13. beepster4096 commented on Sep 20, 2021

    @beepster4096
    Contributor

    I think this feature should be stabilized.

    Stabilization Report

    Summary

    The abi_thiscall feature allows code to export and link to functions with the thiscall abi. This is the abi used by default for C++ member functions on x86 MSVC, and is very important for C++ FFI.

    Tests

    This feature is tested in ui/extern/extern-thiscall.rs

    Documentation PRs

  14. ChrisDenton commented on Oct 22, 2021

    @ChrisDenton
    Member

    If/when this is fcp'd, would anyone be ready with the stabilization PR? @drmeepster maybe?

    Not that I want to rush anyone. I understand people have other priorities and commitments, etc. But I am quite keen to see this stabilized as soon as realistically possible. 😀

  15. 58 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-design-concernsStatus: There are blocking design concerns.S-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions