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

Missing stdcall annotations on Vale extern declarations #744

Open
msprotz opened this issue Dec 15, 2022 · 3 comments
Open

Missing stdcall annotations on Vale extern declarations #744

msprotz opened this issue Dec 15, 2022 · 3 comments

Comments

@msprotz
Copy link
Contributor

msprotz commented Dec 15, 2022

Describe the bug

The source contains numerous precise C calling-convention annotations:

jonathan@absinthe:~/Code/everest/hacl-star (protz_sha2) $ git grep CCConv
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Aes.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Aes.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.AesHash.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.AesHash.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Cpuid.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fmul.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsub.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fswap.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMencryptOpt.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMencryptOpt.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti:[@ (CCConv "stdcall") ]
vale/code/arch/x64/interop/Vale.Stdcalls.X64.Sha.fsti:[@ (CCConv "stdcall") ]

but it seems like krml does nothing with them: there are no keywords stdcall in internal/Vale.h

Expected behavior

krml should probably emit stdcall

@franziskuskiefer do you know if this is a problem on Windows? I'm not sure how it worked so far... is stdcall the default convention?

@msprotz
Copy link
Contributor Author

msprotz commented Dec 15, 2022

Note: I found this bug while spending an afternoon going down the rabbit hole of header inclusion in krml. Following my most recent changes, callconv.h should only be used from within Vale.h, possibly by passing -add-include 'Vale.h:"krml/internal/callconv.h"' to krml

@franziskuskiefer
Copy link
Member

I haven't seen any issue with calling conventions on Windows. The .asm work fine with msvc and the .S with clang-cl. I didn't check the assembly though.

@msprotz
Copy link
Contributor Author

msprotz commented Dec 15, 2022

ok, because the Vale assembly code definitely expects stdcall, so I'm just curious how this is even working out -- the default is cdecl I think on Windows... isn't there some issue related to stack cleanup?

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

No branches or pull requests

2 participants