Skip to content

Commit

Permalink
Call linker even when Clflags.objfiles is empty to link .o .a files
Browse files Browse the repository at this point in the history
Record when linker inputs are specified on command line.
  • Loading branch information
gretay-js committed Feb 11, 2021
1 parent 95a4963 commit 3f2025f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion driver/compenv.ml
Expand Up @@ -600,6 +600,7 @@ let get_objfiles ~with_ocamlparam =
else
List.rev !objfiles

let has_linker_inputs = ref false



Expand Down Expand Up @@ -653,8 +654,10 @@ let process_action
else if Filename.check_suffix name ".cmi" && !make_package then
objfiles := name :: !objfiles
else if Filename.check_suffix name Config.ext_obj
|| Filename.check_suffix name Config.ext_lib then
|| Filename.check_suffix name Config.ext_lib then begin
has_linker_inputs := true;
ccobjs := name :: !ccobjs
end
else if not !native_code && Filename.check_suffix name Config.ext_dll then
dllibs := name :: !dllibs
else
Expand Down
1 change: 1 addition & 0 deletions driver/compenv.mli
Expand Up @@ -37,6 +37,7 @@ val last_objfiles : string list ref
val first_objfiles : string list ref

val stop_early : bool ref
val has_linker_inputs : bool ref

type filename = string

Expand Down
3 changes: 2 additions & 1 deletion driver/optmaindriver.ml
Expand Up @@ -106,7 +106,8 @@ let main argv ppf =
(Compenv.get_objfiles ~with_ocamlparam:false) target);
Warnings.check_fatal ();
end
else if not !Compenv.stop_early && !objfiles <> [] then begin
else if not !Compenv.stop_early &&
(!objfiles <> [] || !Compenv.has_linker_inputs) then begin
let target =
if !output_c_object then
let s = Compenv.extract_output !output_name in
Expand Down

0 comments on commit 3f2025f

Please sign in to comment.