input-output-hk / haskell.nix

Alternative Haskell Infrastructure for Nixpkgs
https://input-output-hk.github.io/haskell.nix
Apache License 2.0
559 stars 238 forks source link

Cannot bootstrap on macOS with CUDA #330

Open kayhide opened 5 years ago

kayhide commented 5 years ago

I got hit by the problem which is reported on https://gitlab.haskell.org/ghc/ghc/issues/16620 and failed to bootstrap.

When cloning this repository and running the following command:

% nix build "(with import <nixpkgs> (import ./.); haskell-nix.nix-tools)" --keep-failed

It failed while building bindist-version and raised the following error:

% nix build "(with import <nixpkgs> (import ./.); haskell-nix.nix-tools)" --keep-failed
warning: dumping very large path (> 256 MiB); this may run out of memory
note: keeping build directory '/private/var/folders/qy/4m5dss6j6vg51dspg41ty2mw0000gn/T/nix-build-bindist-version.drv-9'
builder for '/nix/store/nliwa4kqxdswrzd9923v6z2n7mbvvc3p-bindist-version.drv' failed with exit code 2; last 10 log lines:
  config.status: creating settings
  config.status: creating mk/config.mk
  config.status: creating mk/install.mk
  ****************************************************
  Configuration done, ready to 'make install'
  (see README and INSTALL files for more info.)
  ****************************************************
  configure: WARNING: cache variable fp_cv_gcc_version contains a newline
  building
  mk/config.mk:521: *** missing separator.  Stop.
[0 built (1 failed), 30.0 MiB DL]
error: build of '/nix/store/nliwa4kqxdswrzd9923v6z2n7mbvvc3p-bindist-version.drv' failed
(use '--show-trace' to show detailed location information)

I found that the version detection was not working:

% cd /private/var/folders/qy/4m5dss6j6vg51dspg41ty2mw0000gn/T/nix-build-bindist-version.drv-9
% source env-vars
% $CC -v 2>&1 | sed -n -e '1,/version /s/.*version [^0-9]*\([0-9.]*\).*/\1/p'
7.1.0
9.1

This is because my $CC is reporting the CUDA version along with the compiler version:

% $CC -v
clang version 7.1.0 (tags/RELEASE_710/final)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /nix/store/j1gnbfpi25dw68d6idlxrxibycvirnbw-clang-7.1.0/bin
Found CUDA installation: /usr/local/cuda, version 9.1

This CUDA related problem is also reported https://gitlab.haskell.org/ghc/ghc/issues/14526 .


I am on:

% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G1012
% nix --version
nix (Nix) 2.3.1
kayhide commented 5 years ago

I wrote this patch and solved the gcc version detection.

But I could not find out how to apply this patch properly in the process of nix build. Adding this patch to the ghc-patches on overlays/bootstrap.nix looked to work but did not.

Any suggestion to make it work?

Here is the branch of what I did: https://github.com/kayhide/haskell.nix/tree/patch-macos-gcc-version

kayhide commented 5 years ago

I made a progress.

The problem was actually triggered by a derivation which comes from old-ghc-nix. On that repo, I successfully applied a patch and built bindist-version on macOS. I am going to open a PR there.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.