[Bug 261798] lang/ghc: fix llvm code generation

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 08 Feb 2022 19:21:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798

            Bug ID: 261798
           Summary: lang/ghc: fix llvm code generation
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: Individual Port(s)
          Assignee: haskell@FreeBSD.org
          Reporter: contact@shiori.com.br
             Flags: maintainer-feedback?(haskell@FreeBSD.org)
          Assignee: haskell@FreeBSD.org

Created attachment 231654
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=231654&action=edit
patch

Salve, salve!

GHC searches for a `amd64-portbld-freebsd` version of LLVM, which does not
match either base or ports version identifiers.

If we try to compile a simple hello world:

```
$ ghc -fllvm main.hs -o main.o
[1 of 1] Compiling Main             ( main.hs, main.o )

<no location info>: error:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM between [9 and 13)
ghc: panic! (the 'impossible' happened)
  (GHC version 8.10.7:
        Failed to lookup LLVM data layout
  Target: x86_64-portbld-freebsd
  Available targets:
      i386-unknown-windows
      i686-unknown-windows
      x86_64-unknown-windows
      arm-unknown-linux-gnueabihf
      arm-unknown-linux-musleabihf
      armv6-unknown-linux-gnueabihf
      armv6-unknown-linux-musleabihf
      armv6l-unknown-linux-gnueabihf
      armv6l-unknown-linux-musleabihf
      armv7-unknown-linux-gnueabihf
      armv7-unknown-linux-musleabihf
      armv7a-unknown-linux-gnueabi
      armv7a-unknown-linux-musleabi
      armv7a-unknown-linux-gnueabihf
      armv7a-unknown-linux-musleabihf
      armv7l-unknown-linux-gnueabi
      armv7l-unknown-linux-musleabi
      armv7l-unknown-linux-gnueabihf
      armv7l-unknown-linux-musleabihf
      aarch64-unknown-linux-gnu
      aarch64-unknown-linux-musl
      aarch64-unknown-linux
      i386-unknown-linux-gnu
      i386-unknown-linux-musl
      i386-unknown-linux
      x86_64-unknown-linux-gnu
      x86_64-unknown-linux-musl
      x86_64-unknown-linux
      x86_64-unknown-linux-android
      armv7-unknown-linux-androideabi
      aarch64-unknown-linux-android
      armv7a-unknown-linux-androideabi
      powerpc64le-unknown-linux-gnu
      powerpc64le-unknown-linux-musl
      powerpc64le-unknown-linux
      s390x-ibm-linux
      i386-apple-darwin
      x86_64-apple-darwin
      arm64-apple-darwin
      aarch64-apple-darwin
      armv7-apple-ios
      aarch64-apple-ios
      i386-apple-ios
      x86_64-apple-ios
      amd64-portbld-freebsd
      x86_64-unknown-freebsd
      aarch64-unknown-freebsd
      armv6-unknown-freebsd-gnueabihf
      armv7-unknown-freebsd-gnueabihf
      arm-unknown-nto-qnx-eabi
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in
ghc:Outputable
        pprPanic, called at compiler/llvmGen/LlvmCodeGen.hs:113:20 in
ghc:LlvmCodeGen

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
```

It seems `amd64-portbld-freebsd` was in fact de identifier used on ports LLVM
(please see https://gitlab.haskell.org/ghc/ghc/-/issues/15718), but that is not
the case anymore. Now all versions (tested 90 (default), 10 (default on
PowerPC) and 13) use `x86_64-portbld-freebsd`, causing GHC to fail.

Although `x86_64-unknown-freebsd` (base LLVM) is correct, the way GHC searches
for LLVM is neither clear nor documented, and it does not seem to use base LLVM
at all.

This patch addresses the problem renaming the identifier to the correct one.
Poudriere testport does not complain. Built on both 13.0-RELEASE and
14.0-CURRENT.

Cheers!

-- 
You are receiving this mail because:
You are the assignee for the bug.