-
Notifications
You must be signed in to change notification settings - Fork 15
Translating rust array type [T;C] into struct arr { T[C] data; } #252
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
Conversation
…nes for evaluation order
…nd wip in changing the sigs of builtin functions
…ay in C, trying to handle this in AstOfLlbc.ml
…turn array in C, trying to handle this in AstOfLlbc.ml" This reverts commit 35af6fe.
… the double definition
|
@msprotz Shall we merge this? What else should we do / wait for? |
|
We are still blocked on #252 (comment) -- @ssyram do you think that this issue is fixed by AeneasVerif/charon#790? |
|
If you have time, do you think you could look into this bug? It seems to be an x64-only behavior (and, specifically, on OSX): in those conditions, the function keccakf1600 is not extracted. which might be related. |
|
This is tracked as AeneasVerif/charon#804 and is triggered on a much smaller example. |
|
OK, so the main problem now is the sorting issue AeneasVerif/charon#790 ? This I think has been fixed by my PR in AeneasVerif/hax#2 . Yes, I think you're right that this is the discrepancy between the architecture... This is caused by that the order hash of Rustc used to implement Is this the key factor that produces the issues in comment? I would suggest you simply add the sorting mechanism in the fix on your local computer so to confirm if this fixes everything or there is any other issue we need to overcome. We may work together more efficiently in this way! |
|
Thanks for bringing this to my attention, I was not aware of this PR. I've asked @W95Psp to take a look if he can while we wait for @Nadrieril to come back online. It would be good to merge this to unblock. |
|
OK, thanks! |
|
Thanks for merging AeneasVerif/hax#2, so is the problem fixed? Btw, the merge may not take effect immediately as Charon seems to fix a specific commit hash code in |
|
Do you see hax in Cargo.lock for Charon? this is the error I got |
|
I think simply |
|
but it looks like CI is down so maybe that'll have to wait until Monday |
|
Happy to confirm that AeneasVerif/hax#2 fixes the intel libcrux extraction issue. Now I need to make sure the tests still pass and we should be good. |
|
This needs to be fixed here: @@ -163,8 +163,8 @@ typedef struct {
KRML_CLITERAL(Eurydice_slice) { ptr_, len_ }
#define core_array__core__clone__Clone_for__Array_T__N___clone( \
- len, src, dst, elem_type, _ret_t) \
- (memcpy(dst, src, len * sizeof(elem_type)))
+ len, src, elem_type, _ret_t) \
+ (*(src))
#define TryFromSliceError uint8_t
#define core_array_TryFromSliceError uint8_t |
|
Ok there is a bunch of stuff to fix on the test side for libcrux but at least the code compiles without errors. Everything is on branch protz/ci-arr. @keks @franziskuskiefer should we work together to fix those tests for this upcoming PR? That way this doesn't come as a surprise for libcrux. |
Do you have a branch somewhere with the extraction? Then we could take a first look to see what it takes to fix it up. |
|
Here: https://github.com/cryspen/libcrux/tree/protz/ci-arr With this branch, |
|
The Trying to extract ( |
|
Ok I need to debug the build on ARM too. Let me take a look. |
|
I was able to confirm that this does not break libcrux (see my latest commit on protz/ci-arr branch of libcrux). I'm going to try to figure out the CI issues and then merge this. |
|
OK, I tried to merge the latest into the PR. But kyber seems to report the same error as before. |
|
Congratulations! This has now been merged as part of #283. I will review the metadata PR tomorrow. Thanks for all the good work and sorry it took so long to merge -- I wanted to be absolutely sure that nothing was broken. |
Remove phase that is now un-necessary after #252
Another simplification the new array compilation scheme from #252
According to our discussion in #37, I've done with this prototype which can pass
make test. The cases are mainly unchanged except adding someassert!to avoid unused variable warning.I'll introduce the main changes with my thoughts on them. This version surely needs more cleanup but maybe you can take a look first and give some feedback :)
Translation
In
AstOfLlbc.ml, three basic changes:decl_of_Arris included in the translated program.[x;N]or[x,y,z]and functions related to arrays are similarly translated.Cleanup phases
In
Cleanup2.ml:remove_implicit_array_copies, a recursive call for multi-demensional array is added.from_fnandmapfunctions are changed from the pass-by-ref style to directly returning the struct of array as value.remove_array_repeatsis changed by 1) find and translate thearr{T data[N];}pattern in expressions; 2) forcevisit_DGlobalto return a initializer list as macro definitions in C.A new phase
remove_builtin_declsinCleanup3.mlis added to remove several specific monomorphized array types which are already defined ineurydice_glue.hfor builtin functions (e.g.[u8;4]forcore_num__u32__to_be_bytes).External definitions
As we discussed in #37, I changed the function types in
Builtin.mlto use the new struct types.box_new_arrayandslice_of_boxed_arrayare no longer needed.Notably, most of the C macro definitions of functions for slices and arrays in
eurydice_glue.hare unchanged. Because it seems that the pointer to the struct is nearly "the same" as the pointer to the arraydata. It works for now and I'm not sure should we keep this or add more type-polymorphic macros as @msprotz mentioned.Others
As mentioned in FStarLang/karamel#627, I've added a new builtin function 'empty_array' to replace the empty buffer list for 0-length array. it's later implemented as follows:
I still need a dummy arg to pass the checker, maybe you have better idea?