Skip to content

Commit ba63be3

Browse files
authored
flambda-backend: Fix make depend for jane street stdlib modules (#2493)
1 parent 4194036 commit ba63be3

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

.depend

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,6 @@ typing/typecore.cmo : \
17681768
typing/typedtree.cmi \
17691769
typing/typedecl.cmi \
17701770
typing/subst.cmi \
1771-
typing/solver.cmi \
17721771
typing/shape.cmi \
17731772
typing/rec_check.cmi \
17741773
typing/printtyp.cmi \
@@ -1811,7 +1810,6 @@ typing/typecore.cmx : \
18111810
typing/typedtree.cmx \
18121811
typing/typedecl.cmx \
18131812
typing/subst.cmx \
1814-
typing/solver.cmx \
18151813
typing/shape.cmx \
18161814
typing/rec_check.cmx \
18171815
typing/printtyp.cmx \

boot/ocamlc

1.56 KB
Binary file not shown.

driver/makedepend.ml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,38 @@ let add_to_synonym_list synonyms suffix =
100100
(* Find file 'name' (capitalized) in search path *)
101101
let find_module_in_load_path name =
102102
let names = List.map (fun ext -> name ^ ext) (!mli_synonyms @ !ml_synonyms) in
103+
let uname = String.uncapitalize_ascii name in
103104
let unames =
104-
let uname = String.uncapitalize_ascii name in
105105
List.map (fun ext -> uname ^ ext) (!mli_synonyms @ !ml_synonyms)
106106
in
107+
let stdlib_unames =
108+
(* Jane Street: This is a hack to deal with the fact that we refer to our
109+
custom stdlib modules with names like [Stdlib__Int32_u] from within the
110+
stdlib.
111+
112+
Dependencies are calculated by looking at all modules mentioned by the
113+
code in question and checking to see if there is a corresponding ml file.
114+
But in our case there is no corresponding ml file, because the references
115+
look like `Stdlib__Int32_u.foo` and the ml file's name is just
116+
`int32_u.ml`. This is unlike normal stdlib modules, which are exposed
117+
with names that match their ml files. So, the code here just teaches
118+
make depend to optionally ignore a `Stdlib__` prefix for the purposes of
119+
checking for a matching ml file. *)
120+
let stdlib_prefix = "stdlib__" in
121+
if String.starts_with ~prefix:stdlib_prefix uname then
122+
let plen = String.length stdlib_prefix in
123+
let uname =
124+
String.sub name plen (String.length name - plen)
125+
in
126+
let uname = String.uncapitalize_ascii uname in
127+
List.map (fun ext -> uname ^ ext) (!mli_synonyms @ !ml_synonyms)
128+
else
129+
[]
130+
in
107131
let rec find_in_array a pos =
108132
if pos >= Array.length a then None else begin
109133
let s = a.(pos) in
110-
if List.mem s names || List.mem s unames then
134+
if List.mem s names || List.mem s unames || List.mem s stdlib_unames then
111135
Some s
112136
else
113137
find_in_array a (pos + 1)

ocamldoc/.depend

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,7 @@ odoc_info.cmi : \
480480
odoc_extension.cmi \
481481
odoc_exception.cmi \
482482
odoc_class.cmi \
483-
../parsing/location.cmi \
484-
../parsing/asttypes.cmi
483+
../parsing/location.cmi
485484
odoc_latex.cmo : \
486485
odoc_to_text.cmi \
487486
odoc_messages.cmi \
@@ -594,8 +593,7 @@ odoc_misc.cmx : \
594593
odoc_misc.cmi : \
595594
../typing/types.cmi \
596595
odoc_types.cmi \
597-
../parsing/longident.cmi \
598-
../parsing/asttypes.cmi
596+
../parsing/longident.cmi
599597
odoc_module.cmo : \
600598
../typing/types.cmi \
601599
odoc_value.cmi \
@@ -743,6 +741,7 @@ odoc_see_lexer.cmx : \
743741
odoc_see_lexer.cmi : \
744742
odoc_parser.cmi
745743
odoc_sig.cmo : \
744+
../typing/typetexp.cmi \
746745
../typing/types.cmi \
747746
../typing/typedtree.cmi \
748747
../parsing/parsetree.cmi \
@@ -769,6 +768,7 @@ odoc_sig.cmo : \
769768
../parsing/asttypes.cmi \
770769
odoc_sig.cmi
771770
odoc_sig.cmx : \
771+
../typing/typetexp.cmx \
772772
../typing/types.cmx \
773773
../typing/typedtree.cmx \
774774
../parsing/parsetree.cmi \
@@ -950,15 +950,13 @@ odoc_value.cmo : \
950950
odoc_parameter.cmi \
951951
odoc_name.cmi \
952952
odoc_misc.cmi \
953-
../parsing/asttypes.cmi \
954953
odoc_value.cmi
955954
odoc_value.cmx : \
956955
../typing/types.cmx \
957956
odoc_types.cmx \
958957
odoc_parameter.cmx \
959958
odoc_name.cmx \
960959
odoc_misc.cmx \
961-
../parsing/asttypes.cmi \
962960
odoc_value.cmi
963961
odoc_value.cmi : \
964962
../typing/types.cmi \

stdlib/.depend

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,14 @@ stdlib__Int64.cmx : int64.ml \
541541
stdlib__Int64.cmi : int64.mli \
542542
stdlib.cmi
543543
stdlib__Int64_u.cmo : int64_u.ml \
544+
stdlib__Nativeint_u.cmi \
545+
stdlib__Int32_u.cmi \
544546
stdlib.cmi \
545547
stdlib__Int64.cmi \
546548
stdlib__Int64_u.cmi
547549
stdlib__Int64_u.cmx : int64_u.ml \
550+
stdlib__Nativeint_u.cmx \
551+
stdlib__Int32_u.cmx \
548552
stdlib.cmx \
549553
stdlib__Int64.cmx \
550554
stdlib__Int64_u.cmi
@@ -666,10 +670,12 @@ stdlib__Nativeint.cmx : nativeint.ml \
666670
stdlib__Nativeint.cmi : nativeint.mli \
667671
stdlib.cmi
668672
stdlib__Nativeint_u.cmo : nativeint_u.ml \
673+
stdlib__Int32_u.cmi \
669674
stdlib.cmi \
670675
stdlib__Nativeint.cmi \
671676
stdlib__Nativeint_u.cmi
672677
stdlib__Nativeint_u.cmx : nativeint_u.ml \
678+
stdlib__Int32_u.cmx \
673679
stdlib.cmx \
674680
stdlib__Nativeint.cmx \
675681
stdlib__Nativeint_u.cmi

0 commit comments

Comments
 (0)