Fix GHC loadArchive clang++ error on macOS#149942
Fix GHC loadArchive clang++ error on macOS#149942jkachmar wants to merge 1 commit intoNixOS:masterfrom jkachmar:ghc-darwin-loadarchive-fix
Conversation
|
Note that I haven't tested this patch on GHC 8.8.4, 9.0.1, or 9.2.1. I've only applied it to those expressions following IOHK's guidance (as they apply this patch in their repository to all versions of GHC following 8.6.4). EDIT: If possible I would really appreciate it if we could back port this to earlier versions of I was bitten by it on |
GHC 8.6.4 introduced an issue where linking to `-libc++` will cause
GHC to resolve the library patch to `c++`, which in turn is a link to
clang++.
This results in 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 commit applies the relevant patch to revert GHC's linking behavior
on darwin for the applicable versions of GHC (i.e. after 8.6.4).
|
@bgamari made the following observation when we discussed this in another channel:
|
@jkachmar Were you able to figure out if this is the case? If so, it sounds pretty bad? My guess is that there are quite a few packages using Also, most of the Haskell maintainers (other than sternenseemann) don't use darwin as far as I know, so we might have to ping @ NixOS/darwin-maintainers in order to get this reviewed. |
|
I looked into this a bit more again tonight and I still don't really know what the best path forwards is here. Some related issues:
@jwiegley I saw that you opened the GHC issue linked above; did you ever find a satisfactory workaround to the issue (or was it resolved for you in an updated GHC release)? |
|
Thanks, this patch solved the problem I was having with |
Improvements to the Nix configuration so that macOS is supported. Microsoft SQL Server is still not supported (yet; I have something in mind there), but the rest works. You can still use Homebrew to install the SQL Server drivers. I had to make the following changes: * I updated nixpkgs, because it's been a while. * I made `ODBCINSTINI` optional so that it's not loaded on macOS, as it depends on `msodbcsql17`, which is broken on macOS. * I upgraded OpenSSL. * I set `DYLD_LIBRARY_PATH` on macOS so GHC finds OpenSSL; otherwise, it uses the wrong version of `libcrypto`, and fails with a fun error: > WARNING: ghc is loading libcrypto in an unsafe way * I patched GHC to fix compilation on macOS (copied from NixOS/nixpkgs#149942). To test this out, you can run `nix develop` (or install [direnv][] and add `use flake` to _.envrc.local_), and then try building HGE in the shell provided. Fair warning: GHC needs to be built, and takes _aaages_ the first time. If this becomes useful to others, we can set up a shared cache. [direnv]: https://direnv.net/ PR-URL: hasura/graphql-engine-mono#5989 GitOrigin-RevId: 7130738d47709c37778b31c134061758ce23e959
|
A bit surprised this is still not fixed. Can't build |
|
As stated above, the workaround is not satisfactory, as it may break legitimate use cases that are already working today. Building cabal-install on darwin is unaffected by this issue: |
|
i agree that this solution is unsatisfactory, however as far as i can tell "something" does need to be done to address this. i'm fine with closing this PR, but i hesitated to do so because it has more activity (and more context) than the discussion at #149937. if anyone has any ideas for how we should fix this, i'd be more than willing to dedicate some time to exploring them and patching things properly. |
There's a transitive dependency somewhere that links against c++ which causes all kinds of havoc. For now, easy way out: use NixOS/nixpkgs#149942
|
iohk repo doesn't have a patch for ghc944. Structure of the files has changed in GHC. I used this patch and can confirm issue disappeared: |
|
@maksar This is equivalent to the patch proposed in this PR and as mentioned above, GHC upstream thinks that the patch breaks legitimate use cases. |
|
Experiencing the same issue with GHC 9.8.1 on nix-darwin, tried with gcc/clang from each of OSX and nixpkgs in the path. I'll see if patching still works following e.g. e9d090f |
|
@harryaskham JFYI we are still using this patch on 9.8.2 and it helps on darwin and doesn't hurt on linux. |
Closes #149937.
Motivation for this change
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes