Skip to content

comments in assembly code cause assembler errors in some versions of MacOS on x86-64 #399

@monniaux

Description

@monniaux

Some versions of MacOS install a gcc command that is actually aliased to clang. Some versions of that command run the C preprocessor on .s files, whereas gcc runs it only on .S files. This causes some mysterious errors when assembling these files when CompCert prints comment lines, which start with #, when these lines are identified as C preprocessor directives, which happens for instance if the comment line is of the form # if (blabla).

Fix: use ## as comment prefix.

diff --git a/x86/TargetPrinter.ml b/x86/TargetPrinter.ml
index 2000f96a..50c871e4 100644
--- a/x86/TargetPrinter.ml
+++ b/x86/TargetPrinter.ml
@@ -96,7 +96,7 @@ let z oc n = output_string oc (Z.to_string n)
 let data_pointer = if Archi.ptr64 then ".quad" else ".long"
 
 (* The comment deliminiter *)
-let comment = "#"
+let comment = "##"
 
 (* Base-2 log of a Caml integer *)
 let rec log2 n =

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions