Opened 18 months ago

Last modified 17 months ago

#14982 patch bug

LLVM default -mcpu setting inhibits customization

Reported by: tommd Owned by:
Priority: normal Milestone: 8.4.2
Component: Compiler (LLVM) Version: 8.4.1
Keywords: Cc: angerman
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): D4548
Wiki Page:


With GHC 8.4.1 we are now passing a default -mcpu selection to llvm. This default is passed regardless of any explicit command line option such as -optlc=-mcpu=native. If/when the user explicitly specifies the architecture we now get a failed build. The error message from LLVM is:

llc: for the -mcpu option: may only occur zero or one times!
`llc' failed in phase `LLVM Compiler'. (Exit code: 1)

This is when compiling with GHC 8.4.1 as such:

ghc-8.4.1 -fforce-recomp -fllvm -optlc=-mcpu=native -O2 tt.hs

I suggest we either check for a user option of `mcpu` before adding the default or revert this behavior and allow llvm to take it's (optimistic and less portable) default.

Change History (4)

comment:1 Changed 18 months ago by bgamari

Cc: angerman added

Any thoughts on what we should do here, Moritz? I'm leaning towards just reverting the -mcpu change.

comment:2 Changed 18 months ago by angerman

The code in question pulls the mcpu (and mattr) from the new llvm-targets file. As such a hack around it right now would be to just modify the llvm-targets file. This however is a rather ugly hack as it would apply the logic globally.

I guess we could just, as suggested, trop the mcpu from llc if a custom one is given. I'm not sure how to handle mattr though.

comment:3 Changed 18 months ago by angerman

Differential Rev(s): D4548
Status: newpatch

comment:4 Changed 17 months ago by Ben Gamari <ben@…>

In cb1ee7e1/ghc:

Do not supply `-mcpu` if `-optlc` provides `-mcpu` already.

Reviewers: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #14982

Differential Revision:
Note: See TracTickets for help on using tickets.