-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Describe the bug
When a Haskell program that links against -libc++ is compiled using LLVM & GHC from nixpkgs on macOS (darwin), compilation fails with the following error:
ghc: loadArchive: Neither an archive, nor a fat archive: `/nix/store/?-clang-wrapper-5.0.2/bin/clang++'
<no location info>: error:
loadArchive "/nix/store/?-clang-wrapper-5.0.2/bin/clang++": failed
This occurs on x86_64-darwin as well as aarch64-darwin.
I have verified that it can be alleviated by applying this patch, recompiling GHC, and attempting to rebuild a project that failed previously.
Steps To Reproduce
Steps to reproduce the behavior on a macOS system:
- Clone
graphql-engine - Insert the
shell.nixincluded below into the repository root directory - Enter the
nix-shell - Run
cp cabal.project.dev-sh.local cabal.project.local - If you are using an
aarch64-darwinsystem
a. Update thecabal.project.freezeindex-statetohackage.haskell.org 2021-12-09T17:38:20Z - Run
cabal update && cabal build graphql-engine
shell.nix
{ pkgs ? import <nixpkgs> { }
, unstable ? import <unstable> { }
}:
let
inherit (pkgs.lib.strings) makeLibraryPath;
haskellDeps = (with pkgs; [
haskell.compiler.ghc8107
cabal-install
]);
# `freetds` needs to be given a `unixODBC` package explicitly when
# `odbcSupport` is enabled.
freetdsWithODBC = pkgs.freetds.override {
odbcSupport = true;
inherit (pkgs) unixODBC;
};
dynamicLibraries = with pkgs; [
libkrb5
ncurses
openssl
pcre
zlib
# Postgres, ODBC, MSSQL, & MySQL deps.
freetdsWithODBC
libmysqlclient
postgresql
unixODBC
];
in
pkgs.mkShell {
buildInputs =
haskellDeps
++ dynamicLibraries;
DYLD_FALLBACK_LIBRARY_PATH = makeLibraryPath dynamicLibraries;
}
Expected behavior
The project should compile successfully, as it does when the patch linked above is applied.
To verify: replace haskell.compiler.ghc8107 with the following snippet in the shell.nix file provided above and rebuild the nix-shell environment.
(haskell.compiler.ghc8107.overrideAttrs (oldAttrs: {
patches = (oldAttrs.patches or [ ]) ++ [
(pkgs.fetchpatch {
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/613ec38dbd62ab7929178c9c7ffff71df9bb86be/overlays/patches/ghc/ghc-macOS-loadArchive-fix.patch";
name = "ghc-macos-loadArchive-fix.patch";
sha256 = "0IUpuzjZb1G+gP3q6RnwQbW4mFzc/OZ/7QqZy+57kx0=";
})
];
}))
NOTE Doing this will rebuild GHC from source, which is a very time consuming operation!
Notify maintainers
@cdepillabout @expipiplus1 @maralorn @sternenseemann
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
[jkachmar@manhattan-transfer:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"aarch64-darwin"`
- host os: `Darwin 21.1.0, macOS 12.0.1`
- multi-user?: `yes`
- sandbox: `no`
- version: `nix-env (Nix) 2.4`
- channels(jkachmar): `"nixpkgs-21.11pre334206.ff17a0fffea"`
- channels(root): `"nixpkgs-21.11pre334206.ff17a0fffea"`
- nixpkgs: `/nix/store/i00nm8lvxx4kybwym08ydkxpqf3irgwl-source`Maintainer information:
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:Metadata
Metadata
Assignees
Labels
Projects
Status