Skip to content

Commit 0444eac

Browse files
committed
Print warnings on the warnings formatter in the couple of places that don't
Except the OCAMLPARAM stuff, as that runs before the command line warning settings are even parsed, so while they are reported using the normal warnings code, they don't look like normal warnings.
1 parent 47eeff4 commit 0444eac

11 files changed

+48
-50
lines changed

Diff for: bytecomp/bytelibrarian.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let add_ccobjs l =
5555
lib_dllibs := !lib_dllibs @ l.lib_dllibs
5656
end
5757

58-
let copy_object_file ppf oc name =
58+
let copy_object_file oc name =
5959
let file_name =
6060
try
6161
find_in_path !load_path name
@@ -68,7 +68,7 @@ let copy_object_file ppf oc name =
6868
let compunit_pos = input_binary_int ic in
6969
seek_in ic compunit_pos;
7070
let compunit = (input_value ic : compilation_unit) in
71-
Bytelink.check_consistency ppf file_name compunit;
71+
Bytelink.check_consistency file_name compunit;
7272
copy_compunit ic oc compunit;
7373
close_in ic;
7474
[compunit]
@@ -77,7 +77,7 @@ let copy_object_file ppf oc name =
7777
let toc_pos = input_binary_int ic in
7878
seek_in ic toc_pos;
7979
let toc = (input_value ic : library) in
80-
List.iter (Bytelink.check_consistency ppf file_name) toc.lib_units;
80+
List.iter (Bytelink.check_consistency file_name) toc.lib_units;
8181
add_ccobjs toc;
8282
List.iter (copy_compunit ic oc) toc.lib_units;
8383
close_in ic;
@@ -88,14 +88,14 @@ let copy_object_file ppf oc name =
8888
End_of_file -> close_in ic; raise(Error(Not_an_object_file file_name))
8989
| x -> close_in ic; raise x
9090

91-
let create_archive ppf file_list lib_name =
91+
let create_archive file_list lib_name =
9292
let outchan = open_out_bin lib_name in
9393
try
9494
output_string outchan cma_magic_number;
9595
let ofs_pos_toc = pos_out outchan in
9696
output_binary_int outchan 0;
9797
let units =
98-
List.flatten(List.map (copy_object_file ppf outchan) file_list) in
98+
List.flatten(List.map (copy_object_file outchan) file_list) in
9999
let toc =
100100
{ lib_units = units;
101101
lib_custom = !Clflags.custom_runtime;

Diff for: bytecomp/bytelibrarian.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
content table = list of compilation units
2323
*)
2424

25-
val create_archive: Format.formatter -> string list -> string -> unit
25+
val create_archive: string list -> string -> unit
2626

2727
type error =
2828
File_not_found of string

Diff for: bytecomp/bytelink.ml

+19-19
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ let crc_interfaces = Consistbl.create ()
169169
let interfaces = ref ([] : string list)
170170
let implementations_defined = ref ([] : (string * string) list)
171171

172-
let check_consistency ppf file_name cu =
172+
let check_consistency file_name cu =
173173
begin try
174174
List.iter
175175
(fun (name, crco) ->
@@ -186,7 +186,7 @@ let check_consistency ppf file_name cu =
186186
end;
187187
begin try
188188
let source = List.assoc cu.cu_name !implementations_defined in
189-
Location.print_warning (Location.in_file file_name) ppf
189+
Location.prerr_warning (Location.in_file file_name)
190190
(Warnings.Multiple_definition(cu.cu_name,
191191
Location.show_filename file_name,
192192
Location.show_filename source))
@@ -208,8 +208,8 @@ let debug_info = ref ([] : (int * Instruct.debug_event list * string list) list)
208208

209209
(* Link in a compilation unit *)
210210

211-
let link_compunit ppf output_fun currpos_fun inchan file_name compunit =
212-
check_consistency ppf file_name compunit;
211+
let link_compunit output_fun currpos_fun inchan file_name compunit =
212+
check_consistency file_name compunit;
213213
seek_in inchan compunit.cu_pos;
214214
let code_block = LongString.input_bytes inchan compunit.cu_codesize in
215215
Symtable.patch_object code_block compunit.cu_reloc;
@@ -230,10 +230,10 @@ let link_compunit ppf output_fun currpos_fun inchan file_name compunit =
230230

231231
(* Link in a .cmo file *)
232232

233-
let link_object ppf output_fun currpos_fun file_name compunit =
233+
let link_object output_fun currpos_fun file_name compunit =
234234
let inchan = open_in_bin file_name in
235235
try
236-
link_compunit ppf output_fun currpos_fun inchan file_name compunit;
236+
link_compunit output_fun currpos_fun inchan file_name compunit;
237237
close_in inchan
238238
with
239239
Symtable.Error msg ->
@@ -243,14 +243,14 @@ let link_object ppf output_fun currpos_fun file_name compunit =
243243

244244
(* Link in a .cma file *)
245245

246-
let link_archive ppf output_fun currpos_fun file_name units_required =
246+
let link_archive output_fun currpos_fun file_name units_required =
247247
let inchan = open_in_bin file_name in
248248
try
249249
List.iter
250250
(fun cu ->
251251
let name = file_name ^ "(" ^ cu.cu_name ^ ")" in
252252
try
253-
link_compunit ppf output_fun currpos_fun inchan name cu
253+
link_compunit output_fun currpos_fun inchan name cu
254254
with Symtable.Error msg ->
255255
raise(Error(Symbol_error(name, msg))))
256256
units_required;
@@ -259,11 +259,11 @@ let link_archive ppf output_fun currpos_fun file_name units_required =
259259

260260
(* Link in a .cmo or .cma file *)
261261

262-
let link_file ppf output_fun currpos_fun = function
262+
let link_file output_fun currpos_fun = function
263263
Link_object(file_name, unit) ->
264-
link_object ppf output_fun currpos_fun file_name unit
264+
link_object output_fun currpos_fun file_name unit
265265
| Link_archive(file_name, units) ->
266-
link_archive ppf output_fun currpos_fun file_name units
266+
link_archive output_fun currpos_fun file_name units
267267

268268
(* Output the debugging information *)
269269
(* Format is:
@@ -298,7 +298,7 @@ let make_absolute file =
298298

299299
(* Create a bytecode executable file *)
300300

301-
let link_bytecode ppf tolink exec_name standalone =
301+
let link_bytecode tolink exec_name standalone =
302302
(* Avoid the case where the specified exec output file is the same as
303303
one of the objects to be linked *)
304304
List.iter (function
@@ -343,7 +343,7 @@ let link_bytecode ppf tolink exec_name standalone =
343343
end;
344344
let output_fun = output_bytes outchan
345345
and currpos_fun () = pos_out outchan - start_code in
346-
List.iter (link_file ppf output_fun currpos_fun) tolink;
346+
List.iter (link_file output_fun currpos_fun) tolink;
347347
if check_dlls then Dll.close_all_dlls();
348348
(* The final STOP instruction *)
349349
output_byte outchan Opcodes.opSTOP;
@@ -444,7 +444,7 @@ let output_cds_file outfile =
444444

445445
(* Output a bytecode executable as a C file *)
446446

447-
let link_bytecode_as_c ppf tolink outfile =
447+
let link_bytecode_as_c tolink outfile =
448448
let outchan = open_out outfile in
449449
begin try
450450
(* The bytecode *)
@@ -464,7 +464,7 @@ let link_bytecode_as_c ppf tolink outfile =
464464
output_code_string outchan code;
465465
currpos := !currpos + Bytes.length code
466466
and currpos_fun () = !currpos in
467-
List.iter (link_file ppf output_fun currpos_fun) tolink;
467+
List.iter (link_file output_fun currpos_fun) tolink;
468468
(* The final STOP instruction *)
469469
Printf.fprintf outchan "\n0x%x};\n\n" Opcodes.opSTOP;
470470
(* The table of global data *)
@@ -565,7 +565,7 @@ let fix_exec_name name =
565565

566566
(* Main entry point (build a custom runtime if needed) *)
567567

568-
let link ppf objfiles output_name =
568+
let link objfiles output_name =
569569
let objfiles =
570570
if !Clflags.nopervasives then objfiles
571571
else if !Clflags.output_c_object then "stdlib.cma" :: objfiles
@@ -584,7 +584,7 @@ let link ppf objfiles output_name =
584584
(* put user's opts first *)
585585
Clflags.dllibs := !lib_dllibs @ !Clflags.dllibs; (* put user's DLLs first *)
586586
if not !Clflags.custom_runtime then
587-
link_bytecode ppf tolink output_name true
587+
link_bytecode tolink output_name true
588588
else if not !Clflags.output_c_object then begin
589589
let bytecode_name = Filename.temp_file "camlcode" "" in
590590
let prim_name =
@@ -593,7 +593,7 @@ let link ppf objfiles output_name =
593593
else
594594
Filename.temp_file "camlprim" ".c" in
595595
try
596-
link_bytecode ppf tolink bytecode_name false;
596+
link_bytecode tolink bytecode_name false;
597597
let poc = open_out prim_name in
598598
(* note: builds will not be reproducible if the C code contains macros
599599
such as __FILE__. *)
@@ -646,7 +646,7 @@ let link ppf objfiles output_name =
646646
else basename ^ Config.ext_obj
647647
in
648648
try
649-
link_bytecode_as_c ppf tolink c_file;
649+
link_bytecode_as_c tolink c_file;
650650
if not (Filename.check_suffix output_name ".c") then begin
651651
temps := c_file :: !temps;
652652
if Ccomp.compile_file ~output:obj_file ?stable_name c_file <> 0 then

Diff for: bytecomp/bytelink.mli

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515

1616
(* Link .cmo files and produce a bytecode executable. *)
1717

18-
val link : Format.formatter -> string list -> string -> unit
18+
val link : string list -> string -> unit
1919
val reset : unit -> unit
2020

21-
val check_consistency:
22-
Format.formatter -> string -> Cmo_format.compilation_unit -> unit
21+
val check_consistency: string -> Cmo_format.compilation_unit -> unit
2322

2423
val extract_crc_interfaces: unit -> (string * Digest.t option) list
2524

Diff for: bytecomp/bytepackager.ml

+10-10
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ let read_member_info file = (
132132
Accumulate relocs, debug info, etc.
133133
Return size of bytecode. *)
134134

135-
let rename_append_bytecode ppf packagename oc mapping defined ofs prefix subst
135+
let rename_append_bytecode packagename oc mapping defined ofs prefix subst
136136
objfile compunit =
137137
let ic = open_in_bin objfile in
138138
try
139-
Bytelink.check_consistency ppf objfile compunit;
139+
Bytelink.check_consistency objfile compunit;
140140
List.iter
141141
(rename_relocation packagename objfile mapping defined ofs)
142142
compunit.cu_reloc;
@@ -161,23 +161,23 @@ let rename_append_bytecode ppf packagename oc mapping defined ofs prefix subst
161161
(* Same, for a list of .cmo and .cmi files.
162162
Return total size of bytecode. *)
163163

164-
let rec rename_append_bytecode_list ppf packagename oc mapping defined ofs
164+
let rec rename_append_bytecode_list packagename oc mapping defined ofs
165165
prefix subst =
166166
function
167167
[] ->
168168
ofs
169169
| m :: rem ->
170170
match m.pm_kind with
171171
| PM_intf ->
172-
rename_append_bytecode_list ppf packagename oc mapping defined ofs
172+
rename_append_bytecode_list packagename oc mapping defined ofs
173173
prefix subst rem
174174
| PM_impl compunit ->
175175
let size =
176-
rename_append_bytecode ppf packagename oc mapping defined ofs
176+
rename_append_bytecode packagename oc mapping defined ofs
177177
prefix subst m.pm_file compunit in
178178
let id = Ident.create_persistent m.pm_name in
179179
let root = Path.Pident (Ident.create_persistent prefix) in
180-
rename_append_bytecode_list ppf packagename oc mapping (id :: defined)
180+
rename_append_bytecode_list packagename oc mapping (id :: defined)
181181
(ofs + size) prefix
182182
(Subst.add_module id (Path.Pdot (root, Ident.name id, Path.nopos))
183183
subst)
@@ -206,7 +206,7 @@ let build_global_target oc target_name members mapping pos coercion =
206206

207207
(* Build the .cmo file obtained by packaging the given .cmo files. *)
208208

209-
let package_object_files ppf files targetfile targetname coercion =
209+
let package_object_files files targetfile targetname coercion =
210210
let members =
211211
map_left_right read_member_info files in
212212
let required_globals =
@@ -241,7 +241,7 @@ let package_object_files ppf files targetfile targetname coercion =
241241
let pos_depl = pos_out oc in
242242
output_binary_int oc 0;
243243
let pos_code = pos_out oc in
244-
let ofs = rename_append_bytecode_list ppf targetname oc mapping [] 0
244+
let ofs = rename_append_bytecode_list targetname oc mapping [] 0
245245
targetname Subst.identity members in
246246
build_global_target oc targetname members mapping ofs coercion;
247247
let pos_debug = pos_out oc in
@@ -278,7 +278,7 @@ let package_object_files ppf files targetfile targetname coercion =
278278

279279
(* The entry point *)
280280

281-
let package_files ppf initial_env files targetfile =
281+
let package_files initial_env files targetfile =
282282
let files =
283283
List.map
284284
(fun f ->
@@ -291,7 +291,7 @@ let package_files ppf initial_env files targetfile =
291291
try
292292
let coercion =
293293
Typemod.package_units initial_env files targetcmi targetname in
294-
package_object_files ppf files targetfile targetname coercion
294+
package_object_files files targetfile targetname coercion
295295
with x ->
296296
remove_file targetfile; raise x
297297

Diff for: bytecomp/bytepackager.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(* "Package" a set of .cmo files into one .cmo file having the
1717
original compilation units as sub-modules. *)
1818

19-
val package_files: Format.formatter -> Env.t -> string list -> string -> unit
19+
val package_files: Env.t -> string list -> string -> unit
2020

2121
type error =
2222
Forward_reference of string * Ident.t

Diff for: driver/compmisc.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ let initial_env () =
5757
~initially_opened_module
5858
~open_implicit_modules:(List.rev !Clflags.open_modules)
5959

60-
let read_color_env ppf =
60+
let read_color_env () =
6161
try
6262
match Clflags.parse_color_setting (Sys.getenv "OCAML_COLOR") with
6363
| None ->
64-
Location.print_warning Location.none ppf
64+
Location.prerr_warning Location.none
6565
(Warnings.Bad_env_variable
6666
("OCAML_COLOR",
6767
"expected \"auto\", \"always\" or \"never\""));

Diff for: driver/compmisc.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
val init_path : ?dir:string -> bool -> unit
1717
val initial_env : unit -> Env.t
1818

19-
val read_color_env : Format.formatter -> unit
19+
val read_color_env : unit -> unit

Diff for: driver/main.ml

+4-5
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ let main () =
134134
try
135135
readenv ppf Before_args;
136136
Clflags.parse_arguments anonymous usage;
137-
Compmisc.read_color_env ppf;
137+
Compmisc.read_color_env ();
138138
begin try
139139
Compenv.process_deferred_actions
140140
(ppf,
@@ -162,16 +162,15 @@ let main () =
162162
if !make_archive then begin
163163
Compmisc.init_path false;
164164

165-
Bytelibrarian.create_archive ppf
166-
(Compenv.get_objfiles ~with_ocamlparam:false)
165+
Bytelibrarian.create_archive (Compenv.get_objfiles ~with_ocamlparam:false)
167166
(extract_output !output_name);
168167
Warnings.check_fatal ();
169168
end
170169
else if !make_package then begin
171170
Compmisc.init_path false;
172171
let extracted_output = extract_output !output_name in
173172
let revd = get_objfiles ~with_ocamlparam:false in
174-
Bytepackager.package_files ppf (Compmisc.initial_env ())
173+
Bytepackager.package_files (Compmisc.initial_env ())
175174
revd (extracted_output);
176175
Warnings.check_fatal ();
177176
end
@@ -193,7 +192,7 @@ let main () =
193192
default_output !output_name
194193
in
195194
Compmisc.init_path false;
196-
Bytelink.link ppf (get_objfiles ~with_ocamlparam:true) target;
195+
Bytelink.link (get_objfiles ~with_ocamlparam:true) target;
197196
Warnings.check_fatal ();
198197
end;
199198
with x ->

Diff for: driver/optmain.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ let main () =
247247
"<options> Compute dependencies \
248248
(use 'ocamlopt -depend -help' for details)"];
249249
Clflags.parse_arguments anonymous usage;
250-
Compmisc.read_color_env ppf;
250+
Compmisc.read_color_env ();
251251
if !gprofile && not Config.profiling then
252252
fatal "Profiling with \"gprof\" is not supported on this platform.";
253253
begin try

Diff for: middle_end/middle_end.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ let middle_end ppf ~prefixname ~backend
4545
end)
4646
in
4747
let warning_set = ref WarningSet.empty in
48-
let flambda_warning_printer loc _fmt w =
48+
let flambda_warning_printer loc ppf w =
4949
let elt = loc, w in
5050
if not (WarningSet.mem elt !warning_set) then begin
5151
warning_set := WarningSet.add elt !warning_set;
52-
previous_warning_printer loc !Location.formatter_for_warnings w
52+
previous_warning_printer loc ppf w
5353
end;
5454
in
5555
Misc.protect_refs

0 commit comments

Comments
 (0)