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

Export global constants #968

Open
sarranz opened this issue Nov 29, 2024 · 7 comments
Open

Export global constants #968

sarranz opened this issue Nov 29, 2024 · 7 comments

Comments

@sarranz
Copy link
Collaborator

sarranz commented Nov 29, 2024

Could we add assembler directives to export global variables? For instance, for

u64 g = 42;

it would be good to be able to access g from C.

@bgregoir
Copy link
Contributor

Can we ensure that g will not be modified external code ?

@vbgl
Copy link
Member

vbgl commented Nov 29, 2024

What’s the motivation?

@xvzcf
Copy link

xvzcf commented Dec 3, 2024

What’s the motivation?

I asked about this; I wanted to have a file for "API constants" as follows:

require "parameters.jinc"

u64 c_VERIFICATION_KEY_SIZE = VERIFICATION_KEY_SIZE;
u64 c_SIGNING_KEY_SIZE = SIGNING_KEY_SIZE;
...

Jasmin could print the values of the constants above when invoked as jasminc file.jazz -pcstexp, and this output could be parsed, but if it could compile the file to a set of exportable global variables, benchmarking and testing programs could generically refer to these constants (which would be supplied at their compile time).

@vbgl
Copy link
Member

vbgl commented Dec 3, 2024

Easy workaround: you can define functions that simply return the values of these constants.

@xvzcf
Copy link

xvzcf commented Dec 5, 2024

Easy workaround: you can define functions that simply return the values of these constants.

I was hoping for a way to get the constants at compile-time, but yes I can do it this way, it's no big deal.

@vbgl
Copy link
Member

vbgl commented Dec 10, 2024

The thing is that it is difficult to have both 1) the ability to refer to constants from the outside and 2) the possibility of building shared libraries.

@vbgl
Copy link
Member

vbgl commented Dec 11, 2024

Related PR turning off the export of global data: #41

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

No branches or pull requests

4 participants