Skip to content

Commit a0ad5ff

Browse files
committed
x86 assembly: fix the comment delimiter for macos and make it per-OS
As reported in #399, it seems better to use `##` instead of `#` as comment delimiter under macOS. For the time being we keep using `#` for Linux and Cygwin. Closes: #399
1 parent 9eccbd3 commit a0ad5ff

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

x86/TargetPrinter.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ let z oc n = output_string oc (Z.to_string n)
9595

9696
let data_pointer = if Archi.ptr64 then ".quad" else ".long"
9797

98-
(* The comment deliminiter *)
99-
let comment = "#"
100-
10198
(* Base-2 log of a Caml integer *)
10299
let rec log2 n =
103100
assert (n > 0);
@@ -106,6 +103,7 @@ let rec log2 n =
106103
(* System dependent printer functions *)
107104
module type SYSTEM =
108105
sig
106+
val comment: string
109107
val raw_symbol: out_channel -> string -> unit
110108
val symbol: out_channel -> P.t -> unit
111109
val label: out_channel -> int -> unit
@@ -124,6 +122,9 @@ module type SYSTEM =
124122
module ELF_System : SYSTEM =
125123
struct
126124

125+
(* The comment delimiter *)
126+
let comment = "#"
127+
127128
let raw_symbol oc s =
128129
fprintf oc "%s" s
129130

@@ -180,6 +181,10 @@ module ELF_System : SYSTEM =
180181
module MacOS_System : SYSTEM =
181182
struct
182183

184+
(* The comment delimiter.
185+
`##` instead of `#` to please the Clang assembler. *)
186+
let comment = "##"
187+
183188
let raw_symbol oc s =
184189
fprintf oc "_%s" s
185190

@@ -239,6 +244,9 @@ module MacOS_System : SYSTEM =
239244
module Cygwin_System : SYSTEM =
240245
struct
241246

247+
(* The comment delimiter *)
248+
let comment = "#"
249+
242250
let symbol_prefix =
243251
if Archi.ptr64 then "" else "_"
244252

0 commit comments

Comments
 (0)