Skip to content

Tracking Issue for extern_system_varargs #136946

Open

Description

@workingjubilee

This is a tracking issue for enabling using an extern "system" function with varargs.
The feature gate for the issue is #![feature(extern_system_varargs)].

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps

Unresolved Questions

Implementation history

Activity

  1. added
    A-ABIArea: Concerning the application binary interface (ABI)
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Feb 12, 2025
  2. added 2 commits that reference this issue on Feb 13, 2025
  3. added a commit that references this issue on Feb 13, 2025
  4. RalfJung commented on Feb 14, 2025

    @RalfJung
    Member

    we have previously rejected implementing MSVC's oddities:

    You keep saying this and I keep correcting you.^^
    We have implemented their oddities on Windows targets: stdcall works on x86_64-pc-windows-msvc and even aarch64-pc-windows-msvc. There was some discussion about this here and here.

  5. workingjubilee commented on Feb 14, 2025

    @workingjubilee
    MemberAuthor

    Yes yes, I copied some text around, so you get to copy some text around too.

    If extern "stdcall" is downgraded to extern "C" anyways when variable arguments are involved on MSVC targets, why doesn't that apply to extern "stdcall" for all cases where the ABI is supported?

  6. workingjubilee commented on Feb 14, 2025

    @workingjubilee
    MemberAuthor

    At least if we did that, it would be... well, absurd, I think, but equally absurd in all cases?

  7. RalfJung commented on Feb 14, 2025

    @RalfJung
    Member

    I don't understand the question / proposal. This does apply in all cases, no?

  8. ChrisDenton commented on Feb 14, 2025

    @ChrisDenton
    Member

    stdcall works on x86_64-pc-windows-msvc and even aarch64-pc-windows-msvc.

    That is not true for the raw-dylib feature, which is stricter.

  9. workingjubilee commented on Feb 14, 2025

    @workingjubilee
    MemberAuthor

    I don't understand the question / proposal. This does apply in all cases, no?

    Currently rustc_hir_analysis will reject an attempt to use a variable argument function with extern "stdcall", such as extern "stdcall" fn(i32, ...), without further consideration.

  10. RalfJung commented on Feb 14, 2025

    @RalfJung
    Member

    Currently rustc_hir_analysis will reject an attempt to use a variable argument function with extern "stdcall", such as extern "stdcall" fn(i32, ...), without further consideration.

    I guess the argument is that MSVC accepts varagrs for system but not for stdcall? Or is that not correct?

    That is not true for the raw-dylib feature, which is stricter.

    Oh, that is an odd inconsistency... I filed a separate issue for that: #137018.

  11. workingjubilee commented on Feb 14, 2025

    @workingjubilee
    MemberAuthor

    I guess the argument is that MSVC accepts varagrs for system but not for stdcall? Or is that not correct?

    extern "system" is a Rust invention, as far as I am aware.

  12. added
    T-langRelevant to the language team
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 14, 2025
  13. RalfJung commented on Feb 20, 2025

    @RalfJung
    Member

    extern "system" is a Rust invention, as far as I am aware.

    Ah, right.

    In my understanding, extern "system" is a "do the right thing" ABI, mainly for calling system functions on Windows -- and there are variadic system functions on Windows. So IMO we should support variadics for that ABI and ensure it works the way the Windows ABI does (for win32 targets, which is the only target where there's even a question about what this should do). That seems like the most convenient thing to do.

  14. RalfJung commented on Feb 20, 2025

    @RalfJung
    Member

    @workingjubilee the main argument against supporting varargs here seems to be that the implementation is ugly, or did I misunderstand that? Given everything going on during ABI adjustments, it's a bit surprising to me that taking into account whether a function is variadic would cause so much trouble.

  15. Soveu commented on May 17, 2025

    @Soveu
    Contributor

    Hi, do I understand correctly that this feature got separated from extended_varargs_abi_support and we could attempt stabilization of it again?

  16. RalfJung commented on Jun 12, 2025

    @RalfJung
    Member

    @Soveu we could attempt stabilization of #100189 -- I think that feature is entirely uncontroversial, it just needs someone to write a stabilization report.

    For this one, @workingjubilee had reservations about making "system" fall back to "C" when there are variadics. Meanwhile however, we have landed #141569 and made it compatible with that behavior. Jubilee, are you still opposed to stabilizing "system" variadics as-is or can you live with it now?

  17. workingjubilee commented on Jun 12, 2025

    @workingjubilee
    MemberAuthor

    I think there are desirable simplifications still from not having this behavior however I am increasingly reconsidering my reservations, yes, if we are also moving to being "maximally strict" on all other fronts re: usage of ABI strings. I don't think that makes much sense without extern "system" adopting a fully "do what I mean" semantic.

  18. RalfJung commented on Jun 12, 2025

    @RalfJung
    Member

    In that case it may make sense for someone to prepare a stabilization report and check test coverage for this.

  19. RalfJung commented on Jul 17, 2025

    @RalfJung
    Member

    I am proposing this for stabilization in #144066.

  20. added a commit that references this issue on Sep 1, 2025
  21. added a commit that references this issue on Sep 2, 2025
  22. added a commit that references this issue on Sep 2, 2025
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

    A-ABIArea: Concerning the application binary interface (ABI)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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