Skip to content

Commit b555916

Browse files
vouillonhhugo
authored andcommitted
Wasm source maps: do not rewrite paths twice
This is already done when writing the source map.
1 parent f7df5c1 commit b555916

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

compiler/lib-wasm/link.ml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,15 +589,7 @@ let extract_source_map ~dir ~name z =
589589
then (
590590
let sm = Source_map.of_string (Zip.read_entry z ~name:"source_map.map") in
591591
let sm =
592-
let rewrite_path path =
593-
if Filename.is_relative path
594-
then path
595-
else
596-
match Build_path_prefix_map.get_build_path_prefix_map () with
597-
| Some map -> Build_path_prefix_map.rewrite map path
598-
| None -> path
599-
in
600-
Wasm_source_map.insert_source_contents ~rewrite_path sm (fun i j file ->
592+
Wasm_source_map.insert_source_contents sm (fun i j file ->
601593
let name = source_name i j file in
602594
if Zip.has_entry z ~name then Some (Zip.read_entry z ~name) else None)
603595
in

compiler/lib-wasm/wasm_source_map.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ let blackbox_filename = "/builtin/blackbox.ml"
137137

138138
let blackbox_contents = "(* generated code *)"
139139

140-
let insert_source_contents' ~rewrite_path (sm : Source_map.Standard.t) i f =
140+
let insert_source_contents' (sm : Source_map.Standard.t) i f =
141141
let l = sm.sources in
142142
let single = List.length l = 1 in
143143
let contents =
@@ -157,13 +157,11 @@ let insert_source_contents' ~rewrite_path (sm : Source_map.Standard.t) i f =
157157
then { sm with ignore_list = [ blackbox_filename ] }
158158
else sm
159159
in
160-
let sm = { sm with sources = List.map ~f:rewrite_path sm.sources } in
161160
sm
162161

163-
let insert_source_contents ~rewrite_path sm f =
162+
let insert_source_contents sm f =
164163
match sm with
165-
| Source_map.Standard sm ->
166-
Source_map.Standard (insert_source_contents' ~rewrite_path sm None f)
164+
| Source_map.Standard sm -> Source_map.Standard (insert_source_contents' sm None f)
167165
| Index ({ sections; _ } as sm) ->
168166
let single_map = List.length sections = 1 in
169167
let sections =
@@ -172,7 +170,6 @@ let insert_source_contents ~rewrite_path sm f =
172170
{ entry with
173171
Source_map.Index.map =
174172
insert_source_contents'
175-
~rewrite_path
176173
entry.Source_map.Index.map
177174
(if single_map then None else Some i)
178175
f

compiler/lib-wasm/wasm_source_map.mli

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ val concatenate : (int * Source_map.Standard.t) list -> Source_map.t
3333
val iter_sources : Source_map.t -> (int option -> int option -> string -> unit) -> unit
3434

3535
val insert_source_contents :
36-
rewrite_path:(string -> string)
37-
-> Source_map.t
38-
-> (int option -> int option -> string -> string option)
39-
-> Source_map.t
36+
Source_map.t -> (int option -> int option -> string -> string option) -> Source_map.t
4037

4138
val blackbox_filename : string
4239

0 commit comments

Comments
 (0)