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

Install ocaml_integers.h #4

Merged
merged 1 commit into from
Mar 3, 2022
Merged

Conversation

jonahbeckford
Copy link

Problem

I encountered the following while trying to cross-compile the luv package (my own setup / not opam-monorepo / but using your Dune-ified ocaml-ctypes package):

jonah@DK-MCHO-Mac-M1-A luv % dune build -x darwin_x86_64 @install
        bash src/c/generate_types_step_2.exe (exit 1)
(cd _build/default/src/c && /bin/bash config/compile_c.sh generate_types_step_2.c /private/tmp/dckbuild/darwin_x86_64/Debug/dksdk/_opam/lib/ctypes generate_types_step_2.exe clang -arch arm64 -O2 -fno-strict-aliasing -fwrapv -arch arm64)
In file included from generate_types_step_2.c:8:
In file included from /private/tmp/dckbuild/darwin_x86_64/Debug/dksdk/_opam/lib/ctypes/ctypes_cstubs_internals.h:13:
/private/tmp/dckbuild/darwin_x86_64/Debug/dksdk/_opam/lib/ctypes/ctypes_primitives.h:16:10: fatal error: 'ocaml_integers.h' file not found

Solution

The Makefile-based version simply copies that ocaml_integers.h file from the integers package. This PR does the equivalent in Dune.

Confer: https://github.com/ocamllabs/ocaml-ctypes/blob/9048ac78b885cc3debeeb020c56ea91f459a4d33/Makefile#L87

Note: If this is the wrong upstream for Dune-ified ocaml-ctypes, please tell me where to submit the PR. I located it from https://github.com/dune-universe/opam-overlays/blob/master/packages/ctypes/ctypes.0.17.1%2Bdune/opam

@avsm
Copy link
Owner

avsm commented Feb 28, 2022

Thanks Jonah! I think this is the right fix, and it was raised in the comments on yallop#588 as well. @TheLortex, does your yaml problem go away if you layer this fix to the dune-universe/opam-overlays ctypes override?

@TheLortex
Copy link

This helps a lot indeed. There remains two small patches to do in ocaml-yaml:

  • in the discover script is given the dune variable %{lib:ctypes:ctypes_cstubs_internals.h}, but it can be a relative path so it has to go through Unix.realpath before being written into the -I ... C flags.
  • the ctypes-cflags rule that uses the discover script has to declare the headers files of the ctypes package as dependencies, otherwise they are not imported in the _build folder where they are included from: so (deps (package ctypes)) has to be added. This works in monorepos, but not in opam before dune 3.0.

@avsm avsm merged commit 3621e05 into avsm:dune-port Mar 3, 2022
@jonahbeckford jonahbeckford deleted the dune-port branch June 4, 2022 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants