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

New option to record renamings in a .h file #357

Merged
merged 4 commits into from
Nov 2, 2023
Merged

Conversation

msprotz
Copy link
Contributor

@msprotz msprotz commented Jun 26, 2023

This simplifies name handling in the situation where a library and a client are both verified projects, extracting separately, and linking together.

Consider Library.A.Base1.fst and Library.A.Base2.fst, extracted with:

-bundle Library.A.Base1+Library.A.Base2=[rename=Library_A,rename-prefix]

The client, in order to use the library, passes -library Library.*, but without any further options, must also replicate the bundle above in order to generate code that references Library_A_foobar instead of Library_A_Base1_foobar; note that the latter would be a linking error.

This is onerous: the library must export its bundle options in a format consumable by the client; furthermore, the client is bound by the bundle choices of the library and has no way of grouping, say, in Library.h all of the extern declarations pertaining to Library while also at the same time respecting the renamings enabled by rename-prefix.

This PR offers an alternate route: the library records in a krmlrenamings.h file all of the name changes that deviate from the default, e.g.

#define Library_A_Base1_foobar Library_A_foobar

This allows the client to replace a litany of bundle/rename options with a mere -add-include '"library/clients/krmlrenamings.h"'

This simplifies name handling in the situation where a library and a
client are both verified projects, extracting separately, and linking
together.

Consider Library.A.Base1.fst and Library.A.Base2.fst, extracted with:

-bundle Library.A.Base1+Library.A.Base2=[rename=Library_A,rename-prefix]

The client, in order to use the library, passes `-library Library.*`,
but without any further options, must also replicate the bundle above in
order to generate code that references Library_A_foobar instead of
Library_A_Base1_foobar; note that the latter would be a linking error.

This is onerous: the library must export its bundle options in a format
consumable by the client; furthermore, the client is bound by the bundle
choices of the library and has no way of grouping, say, in Library.h all
of the `extern` declarations pertaining to Library while also at the
same time respecting the renamings enabled by rename-prefix.

This PR offers an alternate route: the library records in a
krmlrenamings.h file all of the name changes that deviate from the
default, e.g.

```
```

This allows the client to replace a litany of bundle/rename options with
a mere `-add-include '"library/clients/krmlrenamings.h"'`
@msprotz
Copy link
Contributor Author

msprotz commented Jun 26, 2023

CC @pnmadelaine, whose life this should greatly simplify

@msprotz
Copy link
Contributor Author

msprotz commented Jun 26, 2023

Spurious failure for the red. The other green is 👍

@msprotz
Copy link
Contributor Author

msprotz commented Jun 26, 2023

As a side-effect, this breaks HACL* because it was relying on the -drop option which has been deprecated for many years now. The cross-referenced issue fixes it.

@pnmadelaine
Copy link
Contributor

@msprotz thank you very much for this!

@pnmadelaine
Copy link
Contributor

I use this in hacl-star/hacl-star#789, everything seems to work fine! thanks again!

@msprotz msprotz merged commit a7be2a7 into master Nov 2, 2023
2 checks passed
@msprotz msprotz deleted the protz_renamings branch November 2, 2023 23:43
@msprotz
Copy link
Contributor Author

msprotz commented Nov 2, 2023

The test will be whether this allows client projects of HACL* (merkle-tree, everquic, noise*, and so on) to link against HACL* successfully without running into undefined symbols. But I want to merge this to prevent it from bit-rotting, so I'll send followup fixes for this particular feature as we find them.

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

Successfully merging this pull request may close these issues.

2 participants