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

Use -output-complete-exe if available #2692

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 13 additions & 3 deletions src/dune/exe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module Program = struct
}
end

let custom_or_output_complete_exe ctx =
if Ocaml_version.supports_output_complete_exe ctx.Context.version then
"-output-complete-exe"
else
"-custom"

module Linkage = struct
type t =
{ mode : Mode.t
Expand All @@ -23,11 +29,15 @@ module Linkage = struct

let native = { mode = Native; ext = ".exe"; flags = [] }

let custom = { mode = Byte; ext = ".exe"; flags = [ "-custom" ] }
let custom context =
{ mode = Byte
; ext = ".exe"
; flags = [ custom_or_output_complete_exe context ]
}

let native_or_custom (context : Context.t) =
match context.ocamlopt with
| None -> custom
| None -> custom context
| Some _ -> native

let js = { mode = Byte; ext = ".bc.js"; flags = [] }
Expand Down Expand Up @@ -83,7 +93,7 @@ module Linkage = struct
| Js -> []
| Exe -> (
match (wanted_mode, real_mode) with
| Native, Byte -> [ "-custom" ]
| Native, Byte -> [ custom_or_output_complete_exe ctx ]
| _ -> [] )
| Object -> o_flags
| Shared_object -> (
Expand Down
5 changes: 3 additions & 2 deletions src/dune/exe.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ module Linkage : sig
(** Native compilation, extension [.exe] *)
val native : t

(** Byte compilation, link with [-custom], extension [.exe] *)
val custom : t
(** Byte compilation, link with [-custom] or [-output-complete-exe],
extension [.exe] *)
val custom : Context.t -> t

(** [native] if supported, [custom] if not *)
val native_or_custom : Context.t -> t
Expand Down
2 changes: 1 addition & 1 deletion src/dune/exe_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ let executables_rules ~sctx ~dir ~expander ~dir_contents ~scope ~compile_info
&& (not (L.Set.mem exes.modes L.native))
&& not (L.Set.mem exes.modes L.exe)
then
Exe.Linkage.custom :: l
Exe.Linkage.custom ctx :: l
else
l
in
Expand Down
2 changes: 2 additions & 0 deletions src/dune/ocaml_version.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ let ooi_supports_no_approx version = version >= (4, 05, 0)
let ooi_supports_no_code version = version >= (4, 05, 0)

let supports_let_syntax version = version >= (4, 08, 0)

let supports_output_complete_exe version = version >= (4, 10, 0)
3 changes: 3 additions & 0 deletions src/dune/ocaml_version.mli
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ val ooi_supports_no_code : t -> bool

(** Whether the language supports custom let operators *)
val supports_let_syntax : t -> bool

(** Does this support [-output-complete-exe]? *)
val supports_output_complete_exe : t -> bool
2 changes: 1 addition & 1 deletion src/dune/toplevel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let setup_module_rules t =
Super_context.add_rule sctx ~dir main_ml

let setup_rules t =
let linkage = Exe.Linkage.custom in
let linkage = Exe.Linkage.custom (Compilation_context.context t.cctx) in
let program = Source.program t.source in
let sctx = Compilation_context.super_context t.cctx in
Exe.build_and_link t.cctx ~program ~linkages:[ linkage ]
Expand Down