Skip to content

Commit 07fc48a

Browse files
jberdinergrinberg
authored andcommitted
fix(duild-info): reapply flambda fix from #3599 removed in #5049
With flambda, Sys.opaque_identity is needed around the placeholder string or else flambda is able to compile it away. This prevents the rewriting done by e.g. `dune install` from working. Signed-off-by: Josh Berdine <josh@berdine.net>
1 parent 5226892 commit 07fc48a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
- Inline tests are now sandboxed by default (#6079, @rgrinberg)
2929

30+
- Fix build-info version when used with flambda (#6089, fixes #6075, @jberdine)
31+
3032
3.4.1 (26-07-2022)
3133
------------------
3234

otherlibs/build-info/test/run.t

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ Check what the generated build info module looks like:
100100
None
101101
[@@inline never]
102102

103-
let p1 = eval "%%DUNE_PLACEHOLDER:64:vcs-describe:1:a%%%%%%%%%%%%%%%%%%%%%%%%%%"
104-
let p2 = eval "%%DUNE_PLACEHOLDER:64:vcs-describe:1:b%%%%%%%%%%%%%%%%%%%%%%%%%%"
105-
let p0 = eval "%%DUNE_PLACEHOLDER:64:vcs-describe:1:c%%%%%%%%%%%%%%%%%%%%%%%%%%"
103+
let p1 = eval (Sys.opaque_identity "%%DUNE_PLACEHOLDER:64:vcs-describe:1:a%%%%%%%%%%%%%%%%%%%%%%%%%%")
104+
let p2 = eval (Sys.opaque_identity "%%DUNE_PLACEHOLDER:64:vcs-describe:1:b%%%%%%%%%%%%%%%%%%%%%%%%%%")
105+
let p0 = eval (Sys.opaque_identity "%%DUNE_PLACEHOLDER:64:vcs-describe:1:c%%%%%%%%%%%%%%%%%%%%%%%%%%")
106106

107107
let version = p0
108108

src/dune_rules/link_time_code_gen.ml

+7-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ let build_info_code cctx ~libs ~api_version =
150150
((Lib.name lib, v) :: libs, placeholders))
151151
in
152152
let libs = List.rev libs in
153+
let context = CC.context cctx in
154+
let ocaml_version = Ocaml.Version.of_ocaml_config context.ocaml_config in
153155
let buf = Buffer.create 1024 in
154156
(* Parse the replacement format described in [artifact_substitution.ml]. *)
155157
pr buf
@@ -167,7 +169,11 @@ let build_info_code cctx ~libs ~api_version =
167169
None
168170
[@@inline never]
169171
|ocaml};
170-
let fmt_eval : _ format6 = "let %s = eval %S" in
172+
let fmt_eval : _ format6 =
173+
if Ocaml.Version.has_sys_opaque_identity ocaml_version then
174+
"let %s = eval (Sys.opaque_identity %S)"
175+
else "let %s = eval %S"
176+
in
171177
Path.Source.Map.iteri placeholders ~f:(fun path var ->
172178
pr buf fmt_eval var
173179
(Artifact_substitution.encode ~min_len:64 (Vcs_describe path)));

0 commit comments

Comments
 (0)