New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building GHC with nix-shell errors on macOS 10.12 #28997

Open
mjhoy opened this Issue Sep 4, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@mjhoy
Copy link
Contributor

mjhoy commented Sep 4, 2017

Issue description

When I run a nix-shell

nix-shell '<nixpkgs>' -A haskell.compiler.ghcHEAD

inside the ghc repository, then run patchPhase, configurePhase, and buildPhase, it fails building with the following:

"inplace/bin/ghc-stage1" -optc-fno-stack-protector -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-DDTRACE -optc-Irts/dist/build/./autogen -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static  -O0 -H64m -Wall   -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -this-unit-id rts -dcmm-lint  -DDTRACE     -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen            -O2 -Wcpp-undef    -Wnoncanonical-monad-instances  -c rts/posix/GetTime.c -o rts/dist/build/posix/GetTime.o

rts/posix/GetTime.c:88:11: error:
     warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
        res = clock_gettime(CLOCK_ID, &ts);
              ^
   |
88 |     res = clock_gettime(CLOCK_ID, &ts);
   |           ^

rts/posix/GetTime.c:88:11: error:
     warning: this function declaration is not a prototype [-Wstrict-prototypes]
   |
88 |     res = clock_gettime(CLOCK_ID, &ts);
   |           ^

rts/posix/GetTime.c:88:25: error:
     error: use of undeclared identifier 'CLOCK_MONOTONIC'
        res = clock_gettime(CLOCK_ID, &ts);
                            ^
   |
88 |     res = clock_gettime(CLOCK_ID, &ts);
   |                         ^

rts/posix/Clock.h:25:20: error:
     note: expanded from macro 'CLOCK_ID'
   |
25 | #  define CLOCK_ID CLOCK_MONOTONIC
   |                    ^
#  define CLOCK_ID CLOCK_MONOTONIC
                   ^
2 warnings and 1 error generated.

I thought this might be related to some problems outlined in #18506 but apparently that's been fixed for a while. Am I missing a step in building in a nix shell?

Steps to reproduce

git clone git@github.com:ghc/ghc.git
cd ghc
git submodule update --init # see https://ghc.haskell.org/trac/ghc/wiki/Building/GettingTheSources#CloningfromGitHub
nix-shell '<nixpkgs>' -A haskell.compiler.ghcHEAD
patchPhase
configurePhase
buildPhase

Technical details

  • System: macOS Sierra 10.12.6
  • Nix version: nix-env (Nix) 1.11.11
  • Nixpkgs version: "18.03pre-git"
  • Sandboxing enabled: (Not sure; how do I check for this on darwin?)
@vcunat

This comment has been minimized.

Copy link
Member

vcunat commented Sep 4, 2017

Note: nix-shell -A often doesn't reproduce the build exactly. Quite some things may be different, e.g. there's no sandboxing and especially without --pure the package can "see too much".

@mjhoy

This comment has been minimized.

Copy link
Contributor Author

mjhoy commented Sep 4, 2017

@vcunat Hmm, I might just not understand the purpose of nix-shell.

@vcunat

This comment has been minimized.

Copy link
Member

vcunat commented Sep 4, 2017

It's a tool suitable for various purposes – with -A or with -p or with custom shell.nix, for example.

Most of the differences from the real build are just conscious choices, as you don't want to be in an isolated temporary directory, you don't want to unpack the source or other phases ran automatically, you may want your $PATH or not (--pure), etc. Occasionally I think I saw an unintentional difference, i.e. probably a bug.

@mjhoy

This comment has been minimized.

Copy link
Contributor Author

mjhoy commented Sep 5, 2017

So is this behavior considered a bug? (e.g. nix-shell should be able to build any given package?) By the way, --pure fails the configure step due to missing git -- I assume that's due to differences building in a git repository vs getting the .tar.gz sources. I assume that's not a bug because nix doesn't guarantee building works in the source control repository checkout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment