Skip to content

Commit

Permalink
Protect LTCG placeholders with Sys.opaque_identity
Browse files Browse the repository at this point in the history
This ensures that they are not inlined when using flambda.
See discussion in ocaml#1930.

Signed-off-by: Etienne Millon <[email protected]>
  • Loading branch information
emillon committed Jul 1, 2020
1 parent 6b213b1 commit df10ba5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ next
- Allow the use of the `context_name` variable in the `enabled_if` fields of
executable(s) and install stanzas. (#3568, fixes #3566, @voodoos)

- Fix dune-build-info not working correctly when flambda is active (#3599,
@emillon, @jeremiedimino).

2.6.0 (05/06/2020)
------------------

Expand Down
6 changes: 3 additions & 3 deletions otherlibs/build-info/test/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ Check what the generated build info module looks like:
None
[@@inline never]

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

let version = p0

Expand Down
2 changes: 1 addition & 1 deletion src/dune/link_time_code_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ let build_info_code cctx ~libs ~api_version =
pr buf "[@@inline never]";
pr buf "";
Path.Source.Map.iteri !placeholders ~f:(fun path var ->
pr buf "let %s = eval %S" var
pr buf "let %s = eval (Sys.opaque_identity %S)" var
(Artifact_substitution.encode ~min_len:64 (Vcs_describe path)));
if not (Path.Source.Map.is_empty !placeholders) then pr buf "";
pr buf "let version = %s" version;
Expand Down

0 comments on commit df10ba5

Please sign in to comment.