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

Don't statically link the "common" deps? #1

Open
James-E-A opened this issue Dec 18, 2023 · 2 comments
Open

Don't statically link the "common" deps? #1

James-E-A opened this issue Dec 18, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@James-E-A
Copy link
Owner

James-E-A commented Dec 18, 2023

As it stands, the "hard-coded" def_extern() calls at import-time are messy and awkward.

It looks like maybe "out-of-line ABI mode" could be used for a cleaner, more modularized solution.

Something like this might work:

# at build-time
...
ffibuilder.set_source('pqc._lib.foo1', ...)
ffibuilder.cdef("""\
void shake256(
	uint8_t *output,
	size_t outlen,
	const uint8_t *input,
	size_t inlen
);
""")
...
# at import-time
from .._lib import foo1

lib_f = ctypes.util.find_library("pqc_fips202")
lib = foo1.ffi.dlopen(lib_f)  # ??? WILL THIS WORK?? https://stackoverflow.com/a/30824152/1874170
...
@James-E-A
Copy link
Owner Author

As of version 0.0.0.9, we've ditched the cdef_extern and switched over just to compiling the sources inline.

@James-E-A
Copy link
Owner Author

James-E-A commented Jan 9, 2024

I looked into SWIG as an alternative (it would allow actually dynamically linking the common deps, and would also allow us to avoid the extra unnecessary copy when converting a mutable FFI allocation into a bytes for return by constructing the object in-place, which would be AWESOME), but *golly* their tooling is just awful; I couldn't figure it out

@James-E-A James-E-A changed the title Cleaner dependency injection Don't statically link the "common" deps? Jan 11, 2024
@James-E-A James-E-A added the help wanted Extra attention is needed label Jan 11, 2024
@James-E-A James-E-A mentioned this issue Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant