Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync toolchains with main #10532

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
- run: nix build ${{ installable }}
- run: nix build ${{ matrix.installable }}
- uses: actions/upload-artifact@v4
with:
path: result/bin/dune
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ install-ocamlformat:
dev-depext:
opam depext -y $(TEST_DEPS)

# v4-414-dev
# branch v4-414-for-dune
.PHONY: melange
melange:
opam pin add -n melange.dev https://github.com/melange-re/melange.git#24e21cc42
opam pin add -n melange.dev https://github.com/melange-re/melange.git#ab48cfcfe5f2c0ca4a4a4fcafceb73b95c2acb1d

.PHONY: dev-deps
dev-deps: melange
Expand Down
2 changes: 1 addition & 1 deletion bin/install_uninstall.ml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ module File_ops_real (W : sig
open W

let print_line = print_line ~verbosity
let get_vcs p = Dune_rules.Vcs_db.nearest_vcs p
let get_vcs p = Source_tree.nearest_vcs p

type copy_special_file_status =
| Done
Expand Down
11 changes: 5 additions & 6 deletions boot/bootstrap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ open Printf

let min_supported_natively = 4, 08, 0

let _verbose, keep_generated_files, _debug =
let keep_generated_files =
let anon s = raise (Arg.Bad (sprintf "don't know what to do with %s\n" s)) in
let verbose = ref false in
let keep_generated_files = ref false in
let debug = ref false in
Arg.parse
[ "-j", Arg.Int ignore, "JOBS Concurrency"
; "--verbose", Arg.Set verbose, " Set the display mode"
; "--verbose", Arg.Unit ignore, " Set the display mode"
; "--keep-generated-files", Arg.Set keep_generated_files, " Keep generated files"
; "--debug", Arg.Set debug, " Enable various debugging options"
; "--debug", Arg.Unit ignore, " Enable various debugging options"
; ( "--force-byte-compilation"
, Arg.Unit ignore
, " Force bytecode compilation even if ocamlopt is available" )
; "--static", Arg.Unit ignore, " Build a static binary"
]
anon
"Usage: ocaml bootstrap.ml <options>\nOptions are:";
!verbose, !keep_generated_files, !debug
!keep_generated_files
;;

let modules = [ "boot/libs"; "boot/duneboot" ]
Expand Down
16 changes: 7 additions & 9 deletions boot/duneboot.ml
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
(** {2 Command line} *)

let concurrency, verbose, _keep_generated_files, debug, secondary, force_byte_compilation =
let concurrency, verbose, debug, secondary, force_byte_compilation, static =
let anon s = raise (Arg.Bad (Printf.sprintf "don't know what to do with %s\n" s)) in
let concurrency = ref None in
let verbose = ref false in
let keep_generated_files = ref false in
let prog = Filename.basename Sys.argv.(0) in
let debug = ref false in
let secondary = ref false in
let force_byte_compilation = ref false in
let static = ref false in
Arg.parse
[ "-j", Int (fun n -> concurrency := Some n), "JOBS Concurrency"
; "--verbose", Set verbose, " Set the display mode"
; "--keep-generated-files", Set keep_generated_files, " Keep generated files"
; "--keep-generated-files", Unit ignore, " Keep generated files"
; "--debug", Set debug, " Enable various debugging options"
; "--secondary", Set secondary, " Use the secondary compiler installation"
; ( "--force-byte-compilation"
, Set force_byte_compilation
, " Force bytecode compilation even if ocamlopt is available" )
; "--static", Set static, " Build a static binary"
]
anon
(Printf.sprintf "Usage: %s <options>\nOptions are:" prog);
( !concurrency
, !verbose
, !keep_generated_files
, !debug
, !secondary
, !force_byte_compilation )
!concurrency, !verbose, !debug, !secondary, !force_byte_compilation, !static
;;

(** {2 General configuration} *)
Expand Down Expand Up @@ -1129,6 +1125,7 @@ let build
| ".ml" -> Some (Filename.remove_extension fn ^ compiled_ml_ext)
| _ -> None)
in
let static_flags = if static then [ "-ccopt"; "-static" ] else [] in
write_args "compiled_ml_files" compiled_ml_files;
Process.run
~cwd:build_dir
Expand All @@ -1138,6 +1135,7 @@ let build
; obj_files
; [ "-args"; "compiled_ml_files" ]
; link_flags
; static_flags
; allow_unstable_sources
])
;;
Expand Down
3 changes: 3 additions & 0 deletions doc/changes/10525.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fix incorrect warning for libraries defined inside non-existant directories
using `(subdir ..)` and used by executables using `dune-build-info` (#10525,
@rgrinberg)
12 changes: 12 additions & 0 deletions doc/reference/dune-project/dialect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ dialect

.. versionchanged:: 3.9 This field is made optional.

.. describe:: (merlin_reader <program> <args>...)

Configure Merlin to use `<program> <args>...` as READER. Merlin's READER
is a mechanism to extend Merlin to support OCaml dialects by providing
a program that transforms a dialect AST into an OCaml AST.

.. seealso:: `merlin/src/extend/extend_protocol.ml <https://github.com/ocaml/merlin/blob/4.14-502_preview2/src/extend/extend_protocol.ml>`_ for the protocol specification.

This field is optional.

.. versionadded:: 3.16


Default dialects
----------------
Expand Down
34 changes: 17 additions & 17 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
inputs.flake-utils.follows = "flake-utils";
};
melange = {
# When moving the compiler tests to OCaml 5.1, change to v4-51-dev
url = "github:melange-re/melange?rev=24e21cc4284ffb18b3a856c1d730f06f34d32737";
# branch v4-414-for-dune
url = "github:melange-re/melange?rev=ab48cfcfe5f2c0ca4a4a4fcafceb73b95c2acb1d";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
Expand Down Expand Up @@ -47,13 +47,7 @@
ocamlPackages = super.ocaml-ng.ocamlPackages_4_14.overrideScope (oself: osuper: {
dune_3 = osuper.dune_3.overrideAttrs (a: {
src = ./.;
postPatch = ''
substituteInPlace \
boot/duneboot.ml \
--replace-fail \
'; link_flags' \
'; link_flags; ["-ccopt"; "-static"]'
'';
preBuild = "ocaml boot/bootstrap.ml --static";
});
});
};
Expand Down
21 changes: 14 additions & 7 deletions src/dune_pkg/opam_solver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,17 @@ let available_depopts solver_env version_by_package_name (opam_package : OpamFil
else None))
;;

(* Heuristic to determine whether a package is an ocaml compiler *)
let opam_file_is_compiler (opam_package : OpamFile.OPAM.t) =
(* Identify compiler packages by using the fact that all compiler
Packages declare conflicts with other compiler packages. note
that relying on the "compiler" flag to identify compiler packages
will not work, as compiler options packages (such as
ocaml-option-flambda) also have this flag. *)
let ocaml_core_compiler = OpamPackage.Name.of_string "ocaml-core-compiler" in
List.mem opam_package.conflict_class ocaml_core_compiler ~equal:OpamPackage.Name.equal
;;

let opam_package_to_lock_file_pkg
solver_env
stats_updater
Expand Down Expand Up @@ -569,7 +580,7 @@ let opam_package_to_lock_file_pkg
(* opam discards the later checksums, so we only take the first one *)
| checksum :: _ -> Some (Loc.none, Checksum.of_opam_hash checksum)
in
Source.Fetch { Source.url; checksum } ))
{ Source.url; checksum } ))
in
let info =
let url = OpamFile.OPAM.url opam_file in
Expand All @@ -581,7 +592,7 @@ let opam_package_to_lock_file_pkg
|> Option.map ~f:(fun hash -> Loc.none, Checksum.of_opam_hash hash)
in
let url = Loc.none, OpamFile.URL.url url in
Source.Fetch { url; checksum })
{ Source.url; checksum })
in
let dev =
Package_name.Set.mem pinned_package_names name
Expand Down Expand Up @@ -676,11 +687,7 @@ let opam_package_to_lock_file_pkg
let exported_env =
OpamFile.OPAM.env opam_file |> List.map ~f:opam_env_update_to_env_update
in
let kind =
if List.mem (OpamFile.OPAM.flags opam_file) ~equal:Poly.equal Pkgflag_Compiler
then `Compiler
else `Non_compiler
in
let kind = if opam_file_is_compiler opam_file then `Compiler else `Non_compiler in
kind, { Lock_dir.Pkg.build_command; install_command; depends; info; exported_env }
;;

Expand Down
18 changes: 8 additions & 10 deletions src/dune_pkg/package_universe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,6 @@ let create local_packages lock_dir =
t
;;

let concrete_dependencies_of_local_package_with_test t local_package_name =
match concrete_dependencies_of_local_package_with_test t local_package_name with
| Ok x -> x
| Error e ->
Code_error.raise
"Invalid package universe which should have already been validated"
[ "error", Dyn.string (User_message.to_string e) ]
;;

let concrete_dependencies_of_local_package_without_test t local_package_name =
let local_package = Package_name.Map.find_exn t.local_packages local_package_name in
Local_package.(for_solver local_package |> For_solver.opam_filtered_dependency_formula)
Expand Down Expand Up @@ -303,7 +294,14 @@ let check_contains_package t package_name =

let all_dependencies t package ~traverse =
check_contains_package t package;
let immediate_deps = concrete_dependencies_of_local_package_with_test t package in
let immediate_deps =
match concrete_dependencies_of_local_package_with_test t package with
| Ok x -> x
| Error e ->
Code_error.raise
"Invalid package universe which should have already been validated"
[ "error", Dyn.string (User_message.to_string e) ]
in
match traverse with
| `Immediate -> immediate_deps
| `Transitive ->
Expand Down
21 changes: 7 additions & 14 deletions src/dune_pkg/rev_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,11 @@ let output_limit = Sys.max_string_length
let make_stdout () = Process.Io.make_stdout ~output_on_success:Swallow ~output_limit
let make_stderr () = Process.Io.make_stderr ~output_on_success:Swallow ~output_limit

(* to avoid Git translating its CLI *)
let env = Env.add Env.initial ~var:"LC_ALL" ~value:"C"

let git_code_error ~dir ~args ~exit_code ~output =
let git = Lazy.force Vcs.git in
Code_error.raise
"git returned non-zero exit code"
[ "exit code", Dyn.int exit_code
; "dir", Path.to_dyn dir
; "git", Path.to_dyn git
; "args", Dyn.list Dyn.string args
; "output", Dyn.list Dyn.string output
]
let env =
(* to avoid Git translating its CLI *)
Env.add Env.initial ~var:"LC_ALL" ~value:"C"
(* to avoid prmompting for passwords *)
|> Env.add ~var:"GIT_TERMINAL_PROMPT" ~value:"0"
;;

module Git_error = struct
Expand Down Expand Up @@ -723,7 +715,8 @@ module At_rev = struct
let+ (), exit_code =
Process.run ~dir ~display:Quiet ~stdout_to ~stderr_to ~env failure_mode git args
in
if exit_code <> 0 then git_code_error ~dir ~args ~exit_code ~output:[]
if exit_code <> 0
then Git_error.raise_code_error { dir; args; exit_code; output = [] }
in
(* We untar things into a temp dir to make sure we don't create garbage
in the build dir until we know can produce the files *)
Expand Down
Loading
Loading