Skip to content

Commit

Permalink
Merge pull request #8877 from gretay-js/link_anyway
Browse files Browse the repository at this point in the history
Call linker even when Clflags.objfiles is empty
  • Loading branch information
lpw25 committed Feb 22, 2021
2 parents 25a0653 + a83ae20 commit d674d20
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -140,6 +140,9 @@ Working version
(Gabriel Scherer, review by David Allsopp and Florian Angeletti
and Daniel Bünzli, report by Robin Björklin)

- #8877: Call the linker when ocamlopt is invoked with .o and .a files only.
(Greta Yorsh, review by Leo White)

### Internal/compiler-libs changes:

- #9243, simplify parser rules for array indexing operations
Expand Down
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 d674d20

Please sign in to comment.