File tree Expand file tree Collapse file tree 5 files changed +69
-1
lines changed
test/blackbox-tests/test-cases Expand file tree Collapse file tree 5 files changed +69
-1
lines changed Original file line number Diff line number Diff line change 1+ - #11176 : when a library declares ` (no_dynlink) ` , then the ` .cmxs ` file for it
2+ is no longer built. (@nojb )
Original file line number Diff line number Diff line change @@ -378,6 +378,7 @@ let orig_src_dir t = t.orig_src_dir
378378let best_src_dir t = Option. value ~default: t.src_dir t.orig_src_dir
379379let set_version t version = { t with version }
380380let entry_modules t = t.entry_modules
381+ let dynlink_supported t = Mode.Dict. get t.plugins Native <> []
381382
382383let eval_native_archives_exn (type path ) (t : path t ) ~modules =
383384 match t.native_archives, modules with
Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ val enabled : _ t -> Enabled_status.t Memo.t
155155val orig_src_dir : 'path t -> 'path option
156156val version : _ t -> Package_version .t option
157157val dune_version : _ t -> Dune_lang.Syntax.Version .t option
158+ val dynlink_supported : _ t -> bool
158159
159160(* * Directory where the source files for the library are located. Returns the
160161 original src dir when it exists *)
Original file line number Diff line number Diff line change @@ -490,7 +490,9 @@ let setup_build_archives (lib : Library.t) ~top_sorted_modules ~cctx ~expander ~
490490 Super_context. add_rule sctx ~dir ~loc: lib.buildable.loc rule)))
491491 in
492492 Memo. when_
493- (Dynlink_supported.By_the_os. get natdynlink_supported && modes.ocaml.native)
493+ (Lib_info. dynlink_supported lib_info
494+ && Dynlink_supported.By_the_os. get natdynlink_supported
495+ && modes.ocaml.native)
494496 (fun () -> build_shared ~native_archives ~sctx lib ~dir ~flags )
495497;;
496498
Original file line number Diff line number Diff line change 1+ This test checks that if a library is declared with `(no_dynlink)`, then the
2+ corresponding `. cmxs` file is * not * built.
3+
4+ $ cat > dune-project << EOF
5+ > (lang dune 3.17 )
6+ > EOF
7+
8+ First we check the behaviour when `(no_dynlink)` is not present.
9+
10+ $ cat > dune << EOF
11+ > (library
12+ > (name mylib))
13+ > EOF
14+
15+ $ touch a. ml
16+
17+ $ dune build _build/ default / mylib. cmxs
18+
19+ Now with `(no_dynlink)`.
20+
21+ $ cat > dune << EOF
22+ > (library
23+ > (name mylib)
24+ > (no_dynlink))
25+ > EOF
26+
27+ $ dune clean
28+
29+ $ dune build _build/ default / mylib. cmxs
30+ Error: Don't know how to build _build/ default / mylib. cmxs
31+ Hint: did you mean _build/ default / mylib. cma or _build/ default / mylib. cmxa?
32+ [1 ]
33+
34+ Next, we check that the . cmxs is installed without `(no_dynlink)`:
35+
36+ $ cat > dune-project << EOF
37+ > (lang dune 3.17 )
38+ > (package (name mylib))
39+ > EOF
40+
41+ $ cat > dune << EOF
42+ > (library
43+ > (public_name mylib))
44+ > EOF
45+
46+ $ dune build _build/ default / mylib. install
47+
48+ $ grep cmxs _build/ default / mylib. install
49+ " _build/install/default/lib/mylib/mylib.cmxs"
50+
51+ And * not * installed with `(no_dynlink)`:
52+
53+ $ cat > dune << EOF
54+ > (library
55+ > (public_name mylib)
56+ > (no_dynlink))
57+ > EOF
58+
59+ $ dune build _build/ default / mylib. install
60+
61+ $ grep cmxs _build/ default / mylib. install
62+ [1 ]
You can’t perform that action at this time.
0 commit comments