Skip to content

M1 clang/llvm issue

Hi! Any pointers on getting GHCUp installed GHC/Cabal with LLVM working on an M1 laptop?

I'm failing to build this project on aarch64-osx with ghcup+llvm. However, -O0 builds fine as does Rosetta's x86_64-osx.

Prerequisitives:

  1. Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. GHCUp
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
    BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
    BOOTSTRAP_HASKELL_GHC_VERSION=8.10.7 \
    BOOTSTRAP_HASKELL_CABAL_VERSION=3.6.2.0 \
    sh

Steps to reproduce:

git clone --recursive https://github.com/futurice/haskell-mega-repo.git
brew install fftw pkg-config python3 xz postgresql
cabal new-update
cp -r data.sample data
cabal new-build avatar-app

WITHOUT llvm:

<no location info>: error:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM between [9 and 13)

WITH llvm:

  • for some reason OPT and LLC need to be defined, even if they're on PATH
brew install llvm@11
OPT=/opt/homebrew/opt/llvm@11/bin/opt LLC=/opt/homebrew/opt/llvm@11/bin/llc ghcup install ghc 8.10.7 --force
ghcup set ghc 8.10.7
0  0x100a5c224  __assert_rtn + 128
1  0x100a624e8  ld::tool::OutputFile::addDyldInfo(ld::Internal&, ld::Internal::FinalSection*, ld::Atom const*, ld::Fixup*, ld::Fixup*, ld::Fixup*, ld::Atom const*, ld::Atom const*, unsigned long long, unsigned long long) (.cold.1) + 0
2  0x1009a4b98  ld::tool::OutputFile::addDyldInfo(ld::Internal&, ld::Internal::FinalSection*, ld::Atom const*, ld::Fixup*, ld::Fixup*, ld::Fixup*, ld::Atom const*, ld::Atom const*, unsigned long long, unsigned long long) + 0
3  0x100997544  ld::tool::OutputFile::generateLinkEditInfo(ld::Internal&) + 1188
4  0x100991a90  ld::tool::OutputFile::write(ld::Internal&) + 140
5  0x10091f1d8  main + 584
A linker snapshot was created at:
	/tmp/libHSfuturice-integrations-0-inplace-ghc8.10.7.dylib-2022-00-08-123320.ld-snapshot
ld: Assertion failed: (target->definition() != ld::Atom::definitionProxy), function addChainedFixupLocation, file OutputFile.cpp, line 5903.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
cabal: Failed to build futurice-integrations-0 (which is required by
exe:avatar-server from avatar-app-0).

Runtime information

$ uname -a

Darwin jussi-max.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64

$ clang --version

Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ gcc --version

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ cabal --version

cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library

$ ghc --info

ghc --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts","")
 ,("C compiler command","gcc")
 ,("C compiler flags","")
 ,("C++ compiler flags","")
 ,("C compiler link flags","")
 ,("C compiler supports -no-pie","NO")
 ,("Haskell CPP command","gcc")
 ,("Haskell CPP flags","-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs")
 ,("ld command","ld")
 ,("ld flags","")
 ,("ld supports compact unwind","YES")
 ,("ld supports build-id","NO")
 ,("ld supports filelist","YES")
 ,("ld is GNU ld","NO")
 ,("Merge objects command","ld")
 ,("Merge objects flags","-r")
 ,("ar command","ar")
 ,("ar flags","qcls")
 ,("ar supports at file","NO")
 ,("ranlib command","ranlib")
 ,("otool command","otool")
 ,("install_name_tool command","install_name_tool")
 ,("touch command","touch")
 ,("dllwrap command","/bin/false")
 ,("windres command","/bin/false")
 ,("libtool command","libtool")
 ,("unlit command","/Users/jussi.vaihia@futurice.com/.ghcup/ghc/8.10.7/lib/ghc-8.10.7/bin/unlit")
 ,("cross compiling","NO")
 ,("target platform string","aarch64-apple-darwin")
 ,("target os","OSDarwin")
 ,("target arch","ArchAArch64")
 ,("target word size","8")
 ,("target has GNU nonexec stack","NO")
 ,("target has .ident directive","YES")
 ,("target has subsections via symbols","NO")
 ,("target has RTS linker","YES")
 ,("Unregisterised","NO")
 ,("LLVM target","arm64-apple-darwin")
 ,("LLVM llc command","/opt/homebrew/opt/llvm@11/bin/llc")
 ,("LLVM opt command","/opt/homebrew/opt/llvm@11/bin/opt")
 ,("LLVM clang command","clang")
 ,("integer library","integer-gmp")
 ,("Use interpreter","YES")
 ,("Use native code generator","NO")
 ,("Support SMP","YES")
 ,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn thr_debug_p debug_p")
 ,("Tables next to code","YES")
 ,("Leading underscore","YES")
 ,("Use LibFFI","YES")
 ,("Use Threads","YES")
 ,("Use Debugging","NO")
 ,("RTS expects libdw","NO")
 ,("Project version","8.10.7")
 ,("Project Git commit id","1f02b7430b2fbab403d7ffdde9cfd006e884678e")
 ,("Booter version","8.10.3")
 ,("Stage","2")
 ,("Build platform","aarch64-apple-darwin")
 ,("Host platform","aarch64-apple-darwin")
 ,("Target platform","aarch64-apple-darwin")
 ,("Have interpreter","YES")
 ,("Object splitting supported","NO")
 ,("Have native code generator","NO")
 ,("Support dynamic-too","YES")
 ,("Support parallel --make","YES")
 ,("Support reexported-modules","YES")
 ,("Support thinning and renaming package flags","YES")
 ,("Support Backpack","YES")
 ,("Requires unified installed package IDs","YES")
 ,("Uses package keys","YES")
 ,("Uses unit IDs","YES")
 ,("Dynamic by default","NO")
 ,("GHC Dynamic","YES")
 ,("GHC Profiled","NO")
 ,("Debug on","NO")
 ,("LibDir","/Users/jussi.vaihia@futurice.com/.ghcup/ghc/8.10.7/lib/ghc-8.10.7")
 ,("Global Package DB","/Users/jussi.vaihia@futurice.com/.ghcup/ghc/8.10.7/lib/ghc-8.10.7/package.conf.d")
 ]

I'm stumped. Tips?

Edited by Jussi Vaihia
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information