Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions test/blackbox-tests/test-cases/ctypes/lib-no-modules-field.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Checking the validation of ctypes with no (modules) field works.

$ cat > dune-project <<EOF
> (lang dune 3.20)
> (using ctypes 0.3)
> EOF

$ mkdir bindings
$ cat > bindings/dune <<EOF
> (library (name mybindings))
> EOF

$ cat > bindings/ffi_bindings.ml <<EOF
> module Types (F : Ctypes.TYPE) = struct end
> module Functions (F : Ctypes.FOREIGN) = struct end
> EOF

$ cat > dune <<EOF
> (library
> (name mylib)
> (libraries mybindings)
> (ctypes
> (external_library_name foo)
> (type_description (instance Types) (functor Ffi_bindings))
> (function_description (instance Functions) (functor Ffi_bindings))
> (generated_entry_point C)))
> EOF

$ dune build
Copy link
Copy Markdown
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV Dec 23, 2025

Choose a reason for hiding this comment

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

Could you add a plain-text explanation what is expected here and what is failing? That would make it easier to understand the failure case and expected behavior without knowing the entire context.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The (ctypes (type_description (functor ...))) fields use a module that tells ctypes about the kind of interface to expect for the ffi. Some validation was added to make sure that the module came from the modules of the stanza in #12124. However this assumption is incorrect as there are people using this with this particular interface module coming from a separate location. More information can be found in #13001.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, but I mean in the cram file. So people reading it can understand what is going on without having to go through the git blame and the github issues.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will update the test with explanation, sorry for being unclear.

File "dune", lines 1-8, characters 0-245:
1 | (library
2 | (name mylib)
3 | (libraries mybindings)
4 | (ctypes
5 | (external_library_name foo)
6 | (type_description (instance Types) (functor Ffi_bindings))
7 | (function_description (instance Functions) (functor Ffi_bindings))
8 | (generated_entry_point C)))
Error: Module Ffi_bindings is required by ctypes at dune:6 but is missing in
the modules field of the stanza.
File "dune", lines 1-8, characters 0-245:
1 | (library
2 | (name mylib)
3 | (libraries mybindings)
4 | (ctypes
5 | (external_library_name foo)
6 | (type_description (instance Types) (functor Ffi_bindings))
7 | (function_description (instance Functions) (functor Ffi_bindings))
8 | (generated_entry_point C)))
Error: Module Ffi_bindings is required by ctypes at dune:7 but is missing in
the modules field of the stanza.
[1]
Loading