Skip to content

sysv_abi attribute for constructors and destructors on Windows, and/or in a pragma? #166925

@solbjorn

Description

@solbjorn

Hey,

I have to work on a Windows project unfortunately (I'm a Linux guy myself).

I hate MS x64 calling convention and would like to use sysv_abi throughout the project (except external dlls of course) to be able to pass stuff like std::span directly etc.
Calling an MS ABI function from a SysV ABI function is fine, however, calling a SysV ABI function from an MS ABI function introduces function coloring / additional overhead due to XMM clobbering which negates benefits of using SysV ABI on Windows, unless the whole project is in SysV ABI.
Unfortunately, for now Clang doesn't support setting the sysv_abi attribute for constructors and destructors, as well as using pragmas. The latter can be worked around by marking every function separately (annoying but acceptable), while the former complicates things a lot.
It's also interesting that Clang on Linux supports marking constructors and destructors with ms_abi, but not vice versa.

Are there any plans to remove those limitations? That would really help; otherwise, I start doubting it's worth it at all.

Or maybe there are some other flags/WAs in Clang that would avoid passing 16-byte structs via implicit references instead of registers on Windows for the whole project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ABIApplication Binary Interfaceclang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"platform:windows

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions