Opened 8 years ago

Closed 8 years ago

#2872 closed bug (fixed)

sparc -mcpu=v9 is not used in assembly phase

Reported by: duncan Owned by: igloo
Priority: high Milestone: 6.10.2
Component: Compiler Version: 6.8.3
Keywords: Cc:
Operating System: Solaris Architecture: sparc
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The ghc DriverPipeline.hs adds -mcpu=v9 when compiling .hs files on sparc:

#ifdef sparc_TARGET_ARCH
        -- We only support SparcV9 and better because V8 lacks an atomic CAS
        -- instruction. Note that the user can still override this
        -- (e.g., -mcpu=ultrasparc) as GCC picks the "best" -mcpu flag
        -- regardless of the ordering.
        -- This is a temporary hack.
                       ++ ["-mcpu=v9"]

This is great, but it does not add -mcpu=v9 when it calls gcc to assemble the .s file. So it fails because the .s file uses v9 instructions but we're not telling the assembler to use v9:

     Error: Architecture mismatch on "blu,pn %icc,.LL4".
      (Requires v9|v9a|v9b; requested architecture is v8.)

If one re-runs that failing command with -opta-mcpu=v9 then of course it works.

The general rule is that any -mcpu flags passed to gcc at the compile stage also have to be passed to gcc at the assembly phase.

Looking at the code it appears that the -mcpu=v9 flag is passed for the HCc and As but not SplitAs phases. Of course the SplitAs phase is used during ghc bootstrapping which is where I found this failure. This is in ghc-6.8.3 but the code looks to be the same in 6.10 so I don't think it's already been fixed.

The workaround is to use SRC_HC_OPTS=-opta-mcpu=v9 in mk/

Change History (4)

comment:1 Changed 8 years ago by rl

I wasn't aware of SplitAs when I implemented this. Is that used instead of As when SPLIT_OBJS=YES? In any case, could you please add the same chunk of code to SplitAs and test it. Thanks!

comment:2 Changed 8 years ago by igloo

difficulty: Unknown
Milestone: 6.10.2
Priority: normalhigh

comment:3 Changed 8 years ago by igloo

Owner: set to igloo

comment:4 Changed 8 years ago by igloo

Resolution: fixed
Status: newclosed

Fixed in HEAD and 6.10:

Wed Feb 11 06:16:00 PST 2009  Ian Lynagh <>
  * On sparc, pass -mcpu=v9 when assembling with object splitting enabled
  Fixes trac #2872.
Note: See TracTickets for help on using tickets.