From 2a55d7420a6530b19a3e4eab5809734adb53aea3 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sun, 24 Aug 2025 22:27:52 -0700 Subject: [PATCH 1/3] test(include_subdirs): show missing dependency when building in sandbox Signed-off-by: Antonio Nuno Monteiro --- .../include-qualified/build-with-sandbox.t | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t diff --git a/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t b/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t new file mode 100644 index 00000000000..8bbb32d3f08 --- /dev/null +++ b/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t @@ -0,0 +1,34 @@ +Test `(include_subdirs qualified)` with sandboxing + + $ mkdir lib + $ cat > dune-project < (lang dune 3.20) + > EOF + + $ mkdir lib/sub + $ cat > lib/dune < (include_subdirs qualified) + > (library (name foo)) + > EOF + $ cat > lib/bar.ml < let hello = Sub.Hello.hello + > EOF + $ cat > lib/sub/hello.ml < let hello = "hello from sub" + > EOF + +Errors in sandbox + + $ DUNE_SANDBOX=symlink dune build + File "lib/bar.ml", line 1, characters 12-27: + 1 | let hello = Sub.Hello.hello + ^^^^^^^^^^^^^^^ + Error: The module Sub is an alias for module Foo__Sub, which is missing + [1] + +Transitive deps file doesn't include the alias module + + $ cat _build/default/lib/.foo.objs/foo__Bar.impl.d + lib/bar.ml: Sub + $ cat _build/default/lib/.foo.objs/foo__Bar.impl.all-deps + foo__Sub__Hello From 0261b8131f2711c2867db8e668a9692545317a26 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sun, 24 Aug 2025 22:46:29 -0700 Subject: [PATCH 2/3] fix(include_subdirs): include the alias module in closure group Signed-off-by: Antonio Nuno Monteiro --- src/dune_rules/modules.ml | 5 ++++- .../test-cases/include-qualified/build-with-sandbox.t | 10 ++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dune_rules/modules.ml b/src/dune_rules/modules.ml index 526b54110ab..c952c7abbf9 100644 --- a/src/dune_rules/modules.ml +++ b/src/dune_rules/modules.ml @@ -453,7 +453,10 @@ module Group = struct (* XXX ocamldep can't currently give us precise dependencies for modules under [(include_subdirs qualified)] directories. For that reason we currently depend on everything under the sub-directory. *) - Module_name.Map.values g.modules |> List.concat_map ~f:closure_node + let closure = + Module_name.Map.values g.modules |> List.concat_map ~f:closure_node + in + lib_interface :: closure | _ -> [ lib_interface ] and closure_node = function diff --git a/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t b/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t index 8bbb32d3f08..f305b144cac 100644 --- a/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t +++ b/test/blackbox-tests/test-cases/include-qualified/build-with-sandbox.t @@ -17,18 +17,12 @@ Test `(include_subdirs qualified)` with sandboxing > let hello = "hello from sub" > EOF -Errors in sandbox - $ DUNE_SANDBOX=symlink dune build - File "lib/bar.ml", line 1, characters 12-27: - 1 | let hello = Sub.Hello.hello - ^^^^^^^^^^^^^^^ - Error: The module Sub is an alias for module Foo__Sub, which is missing - [1] -Transitive deps file doesn't include the alias module +Transitive deps file includes the alias module $ cat _build/default/lib/.foo.objs/foo__Bar.impl.d lib/bar.ml: Sub $ cat _build/default/lib/.foo.objs/foo__Bar.impl.all-deps + foo__Sub foo__Sub__Hello From d669bbdb9ad504499d0c3e50ff1087e5fb753ec1 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 27 Aug 2025 00:02:48 -0700 Subject: [PATCH 3/3] add changelog for #12299 Signed-off-by: Antonio Nuno Monteiro --- doc/changes/12299.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc/changes/12299.md diff --git a/doc/changes/12299.md b/doc/changes/12299.md new file mode 100644 index 00000000000..f0371ef86cd --- /dev/null +++ b/doc/changes/12299.md @@ -0,0 +1,2 @@ +- Fix: include the module alias in the transitive dependency closure with + `(include_subdirs qualified). (#12299, @anmonteiro)