Skip to content

Commit f416497

Browse files
authored
flambda-backend: Don't pass (unnecessary?) -L flags to gcc -shared from opttoplevel (#1363)
1 parent 416a714 commit f416497

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

utils/ccomp.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ let remove_Wl cclibs =
168168
(String.sub cclib 4 (String.length cclib - 4))
169169
else cclib)
170170

171-
let call_linker mode output_name files extra =
171+
let call_linker ?(native_toplevel = false) mode output_name files extra =
172172
Profile.record_call "c-linker" (fun () ->
173173
let cmd =
174174
if mode = Partial then
@@ -194,7 +194,8 @@ let call_linker mode output_name files extra =
194194
)
195195
(Filename.quote output_name)
196196
"" (*(Clflags.std_include_flag "-I")*)
197-
(quote_prefixed "-L" (Load_path.get_paths ()))
197+
(if native_toplevel then ""
198+
else quote_prefixed "-L" (Load_path.get_paths ()))
198199
(String.concat " " (List.rev !Clflags.all_ccopts))
199200
(quote_files files)
200201
extra

utils/ccomp.mli

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ type link_mode =
3535
| MainDll
3636
| Partial
3737

38-
val call_linker: link_mode -> string -> string list -> string -> int
38+
(* If the ~native_toplevel flag is true, we don't pass any `-L` flags to gcc.
39+
In some cases we observed so many flags being passed that gcc would crash,
40+
but they should all be unnecessary as we're compiling with `-shared` in that
41+
case. *)
42+
(* CR-someday ccasinghino: the argument above equally applies to all cases when
43+
`link_mode` is `Dll`, but that didn't seem to work. Understand why. *)
44+
val call_linker:
45+
?native_toplevel:bool -> link_mode -> string -> string list -> string -> int
3946

4047
val linker_is_flexlink : bool

0 commit comments

Comments
 (0)