jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

Export global constants

Open sarranz opened this issue 1 year ago • 7 comments

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.

sarranz avatar Nov 29 '24 18:11 sarranz

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

bgregoir avatar Nov 29 '24 19:11 bgregoir

What’s the motivation?

vbgl avatar Nov 29 '24 20:11 vbgl

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).

xvzcf avatar Dec 03 '24 16:12 xvzcf

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

vbgl avatar Dec 03 '24 19:12 vbgl

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.

xvzcf avatar Dec 05 '24 17:12 xvzcf

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 avatar Dec 10 '24 16:12 vbgl

Related PR turning off the export of global data: https://github.com/jasmin-lang/jasmin/pull/41

vbgl avatar Dec 11 '24 07:12 vbgl