Proof of concept for how to do proper branching on target architecture that works for regular and Eurydice compilation runs #260
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This came up while trying to extract to C a version of symcrust with intrinsics in it. The approach is described in the test file (test/intrinsics.rs) which is pretty heavily commented.
However, this work is blocked on AeneasVerif/charon#803.
The reason is that we need the following AST:
where the
TARGET_IS_variables areDExternals marked with IfDef. ASTs of this specific form are recognized and optimized by krml, see e.g. https://github.com/hacl-star/hacl-star/blob/main/dist/gcc-compatible/EverCrypt_Poly1305.c#L69-L92 which is produced by writing https://github.com/hacl-star/hacl-star/blob/main/providers/evercrypt/fst/EverCrypt.Poly1305.fst#L134-L151The approach taken by this PR is to recognize calls to
eurylib::target_arch("xxx")and turn them into the correspondingTARGET_IS_XXXmacro (defined in lib/Builtin.ml), then hope that the AST form above appears.However, because of AeneasVerif/charon#803, control-flow reconstruction fails, which in turn prevents let-binding reconstruction (on the Eurydice side) from kicking in, which then means that instead of seeing
eurylib_target_arch((Eurydice_str){ data = "x86_64"; ... })in the AST, we see:which in turn prevents this pattern from being recognized and turned into a suitable macro.
Of course, because the control-flow reconstruction is also failing, the AST does not have the desired form.
Once this is fixed, I believe we should be in good shape for supporting the compilation of code that features multiplexing over the target architecture.