From 096fc97ea5a8734186a9fb7ae080326526fd7bf7 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 29 Mar 2023 22:38:51 -0700 Subject: [PATCH] test(x-compilation): demonstrate overlap check failure with ppx_runtime_libraries Signed-off-by: Antonio Nuno Monteiro --- .../custom-cross-compilation/ppx-cross.t | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 test/blackbox-tests/test-cases/custom-cross-compilation/ppx-cross.t diff --git a/test/blackbox-tests/test-cases/custom-cross-compilation/ppx-cross.t b/test/blackbox-tests/test-cases/custom-cross-compilation/ppx-cross.t new file mode 100644 index 00000000000..3de9a567c9e --- /dev/null +++ b/test/blackbox-tests/test-cases/custom-cross-compilation/ppx-cross.t @@ -0,0 +1,68 @@ +Demonstrate a bad interaction between cross-compilation and +ppx_runtime_libraries + + $ mkdir -p etc/findlib.conf.d + $ export OCAMLFIND_CONF=$PWD/etc/findlib.conf + $ touch etc/findlib.conf etc/findlib.conf.d/foo.conf + +Create lib1, ppx and lib2: +- lib1 is a regular library +- ppx has a runtime dep on lib1 (via `ppx_runtime_libraries`) +- lib2 is a regular library pre-processed by `ppx` + + $ mkdir lib1 ppx lib2 + $ cat > dune-project < (lang dune 3.7) + > (package (name ppx-cross)) + > EOF + + $ cat > lib1/dune < (library + > (name lib1) + > (public_name ppx-cross.lib1)) + > EOF + +In the ppx, removing `ppx_runtime_libraries` makes the test pass + + $ cat > ppx/dune < (library + > (name ppx) + > (public_name ppx-cross.ppx) + > (kind ppx_rewriter) + > (ppx.driver (main Ppx.main)) + > (ppx_runtime_libraries lib1)) + > EOF + $ cat > ppx/ppx.ml < let main () = + > let out = ref "" in + > let args = + > [ ("-o", Arg.Set_string out, "") + > ; ("--impl", Arg.Set_string (ref ""), "") + > ; ("--as-ppx", Arg.Set (ref false), "") + > ; ("--cookie", Arg.Set (ref false), "") + > ] + > in + > let anon _ = () in + > Arg.parse (Arg.align args) anon ""; + > let out = open_out !out in + > close_out out; + > EOF + + $ cat > lib2/dune < (library + > (name lib2) + > (public_name ppx-cross.lib2) + > (preprocess (pps ppx))) + > EOF + $ touch lib2/lib2.ml + + $ dune build @install -x foo + Error: Conflict between the following libraries: + - "ppx-cross.lib1" in _build/default.foo/lib1 + - "ppx-cross.lib1" in _build/default/lib1 + -> required by _build/default.foo/lib2/.lib2.objs/byte/lib2.cmt + -> required by _build/install/default.foo/lib/ppx-cross/lib2/lib2.cmt + -> required by _build/default.foo/ppx-cross-foo.install + -> required by alias install (context default.foo) + [1] +