Opened 2 years ago

Closed 20 months ago

#10667 closed bug (fixed)

'-g' option generates invalid assembly when '*/*' operator is used

Reported by: slyfox Owned by:
Priority: normal Milestone: 7.10.3
Component: Compiler (CodeGen) Version: 7.10.2-rc2
Keywords: Cc: scpmw, akio
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1386
Wiki Page:

Description

Bug is observed when building cpphs-1.19

module A where

x */* y = 42
$ ghc -fforce-recomp A -g
[1 of 1] Compiling A                ( A.hs, A.o )
/tmp/ghc23923_0/ghc_2.s: Assembler messages:

/tmp/ghc23923_0/ghc_2.s:17:0:  Error: bad expression

/tmp/ghc23923_0/ghc_2.s:17:0:
     Warning: missing operand; zero assumed
...

The problem here is the following assembly snippet:

.text
        .align 8
        .loc 1 3 1 /* */* */
        .quad   12884901911
        .quad   0
        .quad   15

Would it be worthwile using ';' as a comment instead? Don't know if it's universally portable.

Change History (7)

comment:1 Changed 2 years ago by scpmw

Well spotted - should have seen that one coming. Here's what the GNU assembler documentation says:

The line comment character is target specific, and some targets multiple comment characters. Some targets also have line comment characters that only work if they are the first character on a line. Some targets use a sequence of two characters to introduce a line comment. Some targets can also change their line comment characters depending upon command line options that have been used.

According to the same documentation, the line comment character for x86 is apparently #, while it's @ for ARM. So possible, but a bit messy.

I think the better course of action here would be to just "escape" the name - or maybe just drop the comment in the first place if the name looks problematic. It's not really that useful anyway.

comment:2 Changed 23 months ago by akio

Cc: akio added

comment:3 Changed 20 months ago by mjmrotek

Similar thing happens when compiling hmatrix-0.16.1.5 with -g:

    [16 of 33] Compiling Numeric.LinearAlgebra.Algorithms ( src/Numeric/LinearAlgebra/Algorithms.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Numeric/LinearAlgebra/Algorithms.o )
    /tmp/ghc31909_0/ghc_110.s: Assembler messages:
    
    /tmp/ghc31909_0/ghc_110.s:60657:0:  Error: bad expression
    
    /tmp/ghc31909_0/ghc_110.s:60664:0:  Error: bad expression

... etc

and in the offending .s file:

60657: .loc 3 805 33 /* expGolub.*/ */

60664: .loc 3 805 33 /* expGolub.*/ */

... etc
Last edited 20 months ago by mjmrotek (previous) (diff)

comment:4 Changed 20 months ago by slyfox

Architecture: Unknown/Multiplex86_64 (amd64)
Differential Rev(s): Phab:D1386
Milestone: 7.10.3
Status: newpatch

comment:5 Changed 20 months ago by Sergei Trofimovich <siarheit@…>

In e272ab9/ghc:

x86 codegen: don't generate location comments

The following source snippet 'module A where x */* y = 42'
when being compiled with '-g' option emits syntactically
invalid comment for GNU as:

    .text
        .align 8
        .loc 1 3 1 /* */* */

Fixed by not emitting comments at all. We already suppress
all asm comments in 'X86/Ppr.hs'.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>

Test Plan: added test and check it works

Reviewers: scpmw, simonmar, austin, bgamari

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1386

GHC Trac Issues: #10667

comment:6 Changed 20 months ago by slyfox

Status: patchmerge

comment:7 Changed 20 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.