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

Avoid C namespace pollution by keeping implementations static #36

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

xavierleroy
Copy link
Owner

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.

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 Author

While I was at it: I also removed the remaining $Id comments.

This PR is easier to read if whitespace changes (coming from re-indenting) are ignored.

-DBLAKE3_NO_SSE2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_AVX512
-DBLAKE3_USE_NEON=0
(:include flags.sexp))
(names aesni
arcfour
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing these names from the dune file makes them unavailable in dune's _build directory, leading to the failures you're seeing in ocaml/opam-repository#26209

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works just fine locally when I do dune build, so I don't understand what OPAM does that causes the build to fail. Any idea?

At any rate, these .c files are used as include files, so I don't want Dune to build them and include them in the library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it also work locally if you run dune clean && dune build -p cryptokit?

I have 2 hypotheses:

  1. you had a stale build so those files were already in the build directory
  2. dune only filters those files out in the release archive

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with dune build but not with dune build -p cryptokit. I miss the old Makefile...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, what do you mean by "the release archive"? These .c files are sources used at build-time but are not part of what's installed. I'm totally confused :-(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we invalidated hypothesis 2, and I'm not sure it would hold either

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xavierleroy I'm working on a fix, will send a PR shortly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check #37

anmonteiro added a commit to anmonteiro/cryptokit that referenced this pull request Jul 7, 2024
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