diff --git a/CHANGES.md b/CHANGES.md index 30636a74f34..d3a8c0d80ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,8 @@ next - `$ dune utop` no longer tries to load optional libraries that are unavailable (#3612, fixes #3188, @anuragsoni) +- Fix dune-build-info on 4.10.0+flambda (#3599, @emillon, @jeremiedimino). + 2.6.1 (02/07/2020) ------------------ diff --git a/otherlibs/build-info/test/run.t b/otherlibs/build-info/test/run.t index 2cdc7f276b5..ec3b401e34e 100644 --- a/otherlibs/build-info/test/run.t +++ b/otherlibs/build-info/test/run.t @@ -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 diff --git a/src/dune/link_time_code_gen.ml b/src/dune/link_time_code_gen.ml index ac860e3fd5f..73bff849719 100644 --- a/src/dune/link_time_code_gen.ml +++ b/src/dune/link_time_code_gen.ml @@ -144,6 +144,8 @@ let build_info_code cctx ~libs ~api_version = in placeholder p ) )) in + let context = CC.context cctx in + let ocaml_version = Ocaml_version.of_ocaml_config context.ocaml_config in let buf = Buffer.create 1024 in (* Parse the replacement format described in [artifact_substitution.ml]. *) pr buf "let eval s ="; @@ -159,8 +161,14 @@ let build_info_code cctx ~libs ~api_version = pr buf " None"; pr buf "[@@inline never]"; pr buf ""; + let fmt_eval : _ format6 = + if Ocaml_version.has_sys_opaque_identity ocaml_version then + "let %s = eval (Sys.opaque_identity %S)" + else + "let %s = eval %S" + in Path.Source.Map.iteri !placeholders ~f:(fun path var -> - pr buf "let %s = eval %S" var + pr buf fmt_eval 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; diff --git a/src/dune/ocaml_version.ml b/src/dune/ocaml_version.ml index bb71e69511c..690c3a54192 100644 --- a/src/dune/ocaml_version.ml +++ b/src/dune/ocaml_version.ml @@ -45,3 +45,5 @@ let custom_or_output_complete_exe version = "-custom" let ocamlopt_always_calls_library_linker version = version < (4, 12, 0) + +let has_sys_opaque_identity version = version >= (4, 3, 0) diff --git a/src/dune/ocaml_version.mli b/src/dune/ocaml_version.mli index 7a6df09721f..e1c9e98ffd6 100644 --- a/src/dune/ocaml_version.mli +++ b/src/dune/ocaml_version.mli @@ -63,3 +63,6 @@ val custom_or_output_complete_exe : t -> string (** ocamlopt -a always calls the native C linker, even for empty archives *) val ocamlopt_always_calls_library_linker : t -> bool + +(** Whether [Sys.opaque_identity] is in the standard library *) +val has_sys_opaque_identity : t -> bool