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

fix some linking errors caused by collisions with openssl #35

Closed
wants to merge 2 commits into from

Conversation

c-cube
Copy link

@c-cube c-cube commented Apr 12, 2024

on alpine, trying to do a static build with cryptokit and openssl (pulled in by another library), I met some symbol collisions that could only be fixed by prefixing C functions. For uniformity I renamed all the public C functions for sha3 and poly1305-donna so they start with cryptokit_.

xavierleroy added a commit that referenced this pull request Apr 16, 2024
As reported in #35, some of the C files in this library (e.g. src/poly1305-donna.c) are also present in other libraries, causing name collisions for the functions they export.

This commit applies a `static` modifier to all C functions exported by these files, and includes directly the C files in the stub-*.c files.

In the end, the only functions exported are now the OCaml/C stub functions, prefixed by `caml_`.

The `static` modifier is hidden behind a `EXPORT` macro, so that the original visibility can be restored by compiling with `-DEXPORT=`, if that's ever needed.
xavierleroy added a commit that referenced this pull request Apr 16, 2024
As reported in #35, some of the C files in this library (e.g. src/poly1305-donna.c) are also present in other libraries, causing name collisions for the functions they export.

This commit applies a `static` modifier to all C functions exported by these files, and includes directly the C files in the stub-*.c files.

In the end, the only functions exported are now the OCaml/C stub functions, prefixed by `caml_`.

The `static` modifier is hidden behind a `EXPORT` macro, so that the original visibility can be restored by compiling with `-DEXPORT=`, if that's ever needed.

While we're at it: removed the remaining `$Id` comments.
@xavierleroy
Copy link
Owner

Thanks for reporting this naming problem. Given that crypto code is often reused as is (with the same function names) between several projects, it could make sense to address the issue more generally. Prefixing all non-static identifiers with cryptokit is one possibility. In #36 I experimented with another approach, based on the use of static modifiers and inclusion of implementation C files in C/OCaml stub files. Let me know what you think.

@c-cube
Copy link
Author

c-cube commented Apr 16, 2024

Oh, great, I think #36 looks more principled. I suppose including .c files is just fine if they're always used in a single place (the corresponding _stubs.c file), and it allows the code to match more closely upstream specifications. I think it's better to move ahead with #36 then :)

xavierleroy added a commit that referenced this pull request Jun 7, 2024
As reported in #35, some of the C files in this library (e.g. src/poly1305-donna.c) are also present in other libraries, causing name collisions for the functions they export.

This commit applies a `static` modifier to all C functions exported by these files, and includes directly the C files in the stub-*.c files.

In the end, the only functions exported are now the OCaml/C stub functions, prefixed by `caml_`.

The `static` modifier is hidden behind a `EXPORT` macro, so that the original visibility can be restored by compiling with `-DEXPORT=`, if that's ever needed.

While we're at it: removed the remaining `$Id` comments.
@xavierleroy
Copy link
Owner

Let's go with #36 ! Thanks for your feedback.

@xavierleroy xavierleroy closed this Jun 7, 2024
@c-cube
Copy link
Author

c-cube commented Jun 7, 2024 via email

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