<div dir="ltr"><div>> I've had no
      issues with the configure step by running the configure_ghc shell
      function that the flake provides.</div><div><br></div><div>For reference, this is the relevant ghc.nix issue: <a href="https://github.com/alpmestan/ghc.nix/issues/111" target="_blank">https://github.com/alpmestan/ghc.nix/issues/111</a></div><div>It seems that the `configure_ghc` used to be a shell function in <a href="https://github.com/alpmestan/ghc.nix/blob/b200a76a4f28d6434e4678827a0373002e641b12/default.nix#L156">https://github.com/alpmestan/ghc.nix/blob/b200a76a4f28d6434e4678827a0373002e641b12/default.nix#L156</a>.</div><div>Nowadays, it became a standalone bash script (great work, Magnus!), which explains why it works for you: <a href="https://github.com/alpmestan/ghc.nix/blob/f34c21877257fc37bbcf8962dc006024bfd0f946/ghc.nix#L138">https://github.com/alpmestan/ghc.nix/blob/f34c21877257fc37bbcf8962dc006024bfd0f946/ghc.nix#L138</a></div><div><br></div><div>You can't do `./configure $CONFIGURE_ARGS` in zsh directly, though.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mi., 31. Mai 2023 um 09:49 Uhr schrieb Georgi Lyubenov <<a href="mailto:godzbanebane@gmail.com" target="_blank">godzbanebane@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>Just chiming in to mention that I'm on zsh, and I've had no
      issues with the configure step by running the configure_ghc shell
      function that the flake provides.<br>
    </p>
    <div>On 5/31/23 10:13, Sebastian Graf wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>Hi Lyle,</div>
        <div><br>
        </div>
        <div>I'm sorry that you have so much trouble in getting your
          first build done.</div>
        <div>The Classes.hi issue sounds like something I had
          experienced in the past, but I'm not having it at the moment.</div>
        <div>Are you also using symlinks by any chance? Then it is very
          likely that you have been bitten by <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/22451" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/issues/22451</a>,
          the workaround to which would be to do something like `cd
          "$(readlink -f .)"` before you start your build.</div>
        <div><br>
        </div>
        <div>Regarding your second issue using ghc.nix, a quick google
          turned up <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/20429#note_379762" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/issues/20429#note_379762</a>.</div>
        <div>Is it possible that you didn't start from a clean build?<br>
        </div>
        <div>E.g., at the least you should `rm -rf _build` (note that
          `hadrian/cabal clean` sadly is insufficient IIRC for reasons I
          don't recall).</div>
        <div>I often simply do `git clean -fxd` to be extra sure.</div>
        <div>After that, you'll have to boot, configure (including
          passing $CONFIGURE_ARGS) and build again.</div>
        <div>By the way, are you using ZSH? I'm using it and I have to<a href="https://github.com/alpmestan/ghc.nix#building-ghc" target="_blank"> pass the CONFIGURE_ARGS in a
            slightly different way</a>: `./configure
          ${=CONFIGURE_ARGS}`.</div>
        <div><br>
        </div>
        <div>I also updated <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/linux#nixnixos" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/linux#nixnixos</a>
          to account for new-style flakified builds+direnv, if that's a
          workflow that you are familiar with.</div>
        <div><br>
        </div>
        <div>Hope that helps,</div>
        <div>Sebastian<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Am Mi., 31. Mai 2023 um
          05:14 Uhr schrieb Lyle Kopnicky <<a href="mailto:lists@qseep.net" target="_blank">lists@qseep.net</a>>:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <div dir="ltr">Hi folks, I’m new here. I’ll be attending the
              GHC Contributors’ Workshop next week, and in preparation,
              I’m trying to build GHC, both the native code backend and
              the JS backend. So far, I’ve only tried to build it with
              the native code backend, but I haven’t been able to get it
              to work. I’ve gotten help from some friendly folks on the
              #ghc channel on Matrix, and made some progress, but I’m
              still stuck.
              <div><br>
              </div>
              <div dir="ltr">Is there anyone here who could be a point
                person for helping me get it to build? BTW I’m located
                on the west coast of the US (until next week when I’ll
                be in Switzerland), so time lag may be a factor.</div>
              <div dir="ltr"><br>
              </div>
              <div dir="ltr">I’m using a Mac with aarch64 and macOS
                13.3. Here are some of the things I’ve tried, and issues
                I’ve run into:</div>
              <div dir="ltr"><br>
              </div>
              <div dir="ltr">
                <ul style="margin:0px" dir="ltr">
                  <li>Started with the advice from this wiki: <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/building" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/wikis/building</a><br>
                  </li>
                  <li>Checked out the ghc source, on HEAD.<br>
                  </li>
                  <li>The rest of the steps were at <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/mac-osx" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/mac-osx</a><br>
                  </li>
                  <li>Already had Apple’s command line tools, but when I
                    tried to do operations using them, I got an error
                    saying I needed the full Xcode, so I installed that.<br>
                  </li>
                  <li><span style="font-family:ui-monospace">brew
                      install autoconf automake python sphinx-doc</span></li>
                  <ul dir="ltr">
                    <li>Worked fine, also added sphinx-build to the path</li>
                  </ul>
                  <li>Initially tried using ghc 9.2.7 to build - later
                    tried switching to 9.4.4 and eventually 9.4.5</li>
                  <li><font face="menlo, monospace">cabal update; cabal
                      install alex happy haddock</font><br>
                  </li>
                  <ul dir="ltr">
                    <li>This is where I ran into trouble - couldn’t
                      build haddock. Cabal said it couldn’t resolve the
                      dependencies.</li>
                    <li>I tried switching to ghc 9.4.4 and cabal
                      3.10.1.0 - same problem</li>
                    <li>User romes (Rodrigo) on #ghc helped with this -
                      was able to reproduce it and filed a ticket: <a href="https://github.com/haskell/haddock/issues/1596" target="_blank">https://github.com/haskell/haddock/issues/1596</a></li>
                    <li>However he pointed out that haddock was already
                      supplied through ghcup so I don’t need to build
                      it.</li>
                  </ul>
                  <li>Already had MacTex installed and I installed the
                    DejaVu font family.</li>
                  <li><font face="menlo, monospace">./boot &&
                      ./configure</font></li>
                  <ul dir="ltr">
                    <li>Worked fine, although <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">./boot</code> gave me
                      lots of autoconf warnings like:<br>
                      <font face="menlo, monospace"><a href="http://configure.ac:9" target="_blank">configure.ac:9</a>:
                        warning: The macro `AC_HELP_STRING' is obsolete.<br>
                        <a href="http://configure.ac:9" target="_blank">configure.ac:9</a>: You
                        should run autoupdate.</font></li>
                    <li>Apparently autoconf has renamed these macros to
                      pluralize them, and also encloses the arguments in
                      square brackets.</li>
                  </ul>
                  <li><font face="menlo, monospace">hadrian/build</font></li>
                  <ul dir="ltr">
                    <li>Ran into another problem: The build failed with:<br>
                      <font face="menlo, monospace">Error, file does not
                        exist and no rule available:<br>
/Users/lyle/devel/haskell/ghc/_build/stage1/libraries/ghc-prim/build/GHC/Classes.hi</font></li>
                    <li>Rodrigo helped me out with this. Introduced me
                      to other build flags like <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">-j —flavour-quick</code>.</li>
                    <li>The issue proved quite persistent, but it might
                      fail on different <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">.hi</code> files.</li>
                    <li>It turns out if you ask Hadrian to build that
                      specific file, it works. So somehow it can find a
                      rule! Then you can proceed to rebuild and it will
                      fail on a different <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">.hi</code> file.
                      Obviously it would be tedious to do this for all
                      the possible files it can fail on.</li>
                    <li>I also tried not building profiled libraries.</li>
                    <li>I tried, instead of using the Apple toolchain,
                      using llvm 12, then llvm 16. But I got different
                      errors from that.</li>
                    <li>Rodrigo was unable to reproduce the issue.</li>
                  </ul>
                  <li>So, I thought I’d try the Nix approach.</li>
                  <li>First I had to repair my nix installation, because
                    apparently updating macOS overwrites /etc/zshrc,
                    overwriting the bit that sources
                    '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh’</li>
                  <li>Nix reminded me when I ran commands that I needed
                    to add the flag '--extra-experimental-features
                    nix-command’ and
                    sometimes '--extra-experimental-features flakes’</li>
                  <li>The instructions from the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/mac-osx" target="_blank">wiki</a>
                    didn’t work, got an error:</li>
                  <ul>
                    <li><br>
                    </li>
                    <li><font face="menlo, monospace">nix build -f
                        .gitlab/darwin/toolchain.nix -o toolchain.sh
                        --extra-experimental-features nix-command</font></li>
                    <li><font face="menlo, monospace">error: cannot
                        evaluate a function that has an argument without
                        a value ('system’)</font></li>
                  </ul>
                  <li><font face="ui-sans-serif, sans-serif">But folks
                      on #ghc recommended I use </font><code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">ghc.nix</code> instead</li>
                  <ul dir="ltr">
                    <li>Pointed me to <a href="https://ghc.dev/" target="_blank">https://ghc.dev/</a></li>
                    <li>That linked to these instructions: <a href="https://github.com/alpmestan/ghc.nix#building-ghc" target="_blank">https://github.com/alpmestan/ghc.nix#building-ghc</a></li>
                    <li>But those instructions failed with:</li>
                    <ul>
                      <li>error: nix-shell requires a single derivation<br>
                      </li>
                    </ul>
                    <li>User Artem said my command was wrong, instead
                      recommended:</li>
                    <ul dir="ltr">
                      <li><font face="menlo, monospace">nix develop <a href="https://github.com/alpmestan/ghc.nix/archive/master.tar.gz" target="_blank">https://github.com/alpmestan/ghc.nix/archive/master.tar.gz</a></font></li>
                    </ul>
                    <li>Once I added the magic experimental flags…<br>
                    </li>
                    <li>It failed, with:</li>
                    <ul>
                      <li><font face="menlo, monospace">error: NAR hash
                          mismatch in input
'github:commercialhaskell/all-cabal-hashes/02bb1361217e690d83af9cc132b1d2bf2096763c'
(/nix/store/zbav3qqbyz7mn7rh4iwybs0ni01ppdbj-source), expected
                          'sha256-HdAnlSc4U8ftnZrBZr2CewsPQs03V9K2gkTVHKG8IfA=',
                          got
                          'sha256-86BgvJ+ebMxTp+nPxo659hsNJbhE6CYJWiIbQXX+sBM=</font><br>
                      </li>
                    </ul>
                    <li>User MangoIV helped me out with this.</li>
                    <li>First I tried regenerating the lock file, with <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">nix flake update</code>.</li>
                    <ul dir="ltr">
                      <li>Didn’t fix the problem.</li>
                    </ul>
                    <li>Then, I checked out the branch <span style="font-family:ui-monospace;background-color:rgb(248,248,248)">update_flake_lock_action</span></li>
                    <ul dir="ltr">
                      <li>This is apparently a branch designed to fix
                        the problem</li>
                      <li>Didn’t fix the problem</li>
                    </ul>
                    <li>Then I regenerated the lock file again, with <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">nix flake update</code></li>
                    <ul dir="ltr">
                      <li>That worked! Well, at least that got me to a <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">ghc.nix</code> prompt</li>
                    </ul>
                    <li>So, I did:</li>
                    <ul dir="ltr">
                      <li><font face="menlo, monospace">./boot</font></li>
                      <li><font face="menlo, monospace">./configure</font></li>
                      <li><font face="menlo, monospace">cabal v2-update</font></li>
                      <li><font face="menlo, monospace">hadrian/build -j
                          --flavour=quick</font><br>
                      </li>
                    </ul>
                    <li>It chugged along for quite a while. Sadly, it
                      ended with this error:</li>
                    <ul>
                      <li><br>
                      </li>
                      <li><font face="menlo, monospace">Linking
/Users/lyle/Sync/devel/haskell/ghc/hadrian/dist-newstyle/build/aarch64-osx/ghc-9.2.4/hadrian-0.1.0.0/x/hadrian/build/hadrian/hadrian
                          ...</font><span style="font-family:menlo,monospace"><br>
                          Data.Binary.Get.runGet at position 1181:
                          Unknown encoding for constructor</span></li>
                    </ul>
                    <li>What also worries me is that I thought I read
                      somewhere that <code style="border:1px solid rgb(206,206,206);background-color:rgb(248,248,248);padding:0px 3px;border-radius:4px">ghc.nix</code> doesn’t
                      work for cross-compilers, so even if it works for
                      the native backend, it may not work for the JS
                      backend.</li>
                  </ul>
                </ul>
                <div><br>
                </div>
                <div dir="ltr">Any help would be much appreciated!</div>
                <div dir="ltr">— Lyle</div>
              </div>
            </div>
          </div>
          _______________________________________________<br>
          ghc-devs mailing list<br>
          <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
          <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
ghc-devs mailing list
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a>
</pre>
    </blockquote>
  </div>

_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>