tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
958 stars 83 forks source link

Ormolu doesn't build on MacOS Catalina #596

Closed voidus closed 4 years ago

voidus commented 4 years ago

Describe the bug There is an error about path case (which I don't think breaks the build) and a CPP-related one (which I think is the problem). This might as well be a ghc+macos issue, but I don't know how to diagnose this.

The error messages are:

Building executable 'ormolu' for ormolu-0.0.5.0..

<built-in>:16:10: error:
     error: non-portable path to file '"dist/build/Ormolu/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
#include "dist/build/ormolu/autogen/cabal_macros.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         "dist/build/Ormolu/autogen/cabal_macros.h"
1 error generated.

<built-in>:16:10: error:
     error: non-portable path to file '"dist/build/Ormolu/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
#include "dist/build/ormolu/autogen/cabal_macros.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         "dist/build/Ormolu/autogen/cabal_macros.h"
1 error generated.

app/Main.hs:1:1: error:
    `cc' failed in phase `C pre-processor'. (Exit code: 1)
  |
1 | {-# LANGUAGE CPP #-}
  | ^

dist/build/ormolu/autogen/Paths_ormolu.hs:1:1: error:
    `cc' failed in phase `C pre-processor'. (Exit code: 1)
  |
1 | {-# LANGUAGE CPP #-}
  | ^

builder for '/nix/store/dgj7lm0gmqpc139yrhljq92mx5lw6pjv-ormolu-0.0.5.0.drv' failed with exit code 1

Full log attached: buildlog.txt

To Reproduce

git clone https://github.com/tweag/ormolu
cd ormolu
nix-build -A ormolu

Expected behavior Successful build

Environment

Additional context I strongly suspect this is related to the system cc, since I cannot even build old versions (sampled a few back up to september). Any guidance on how to debug would be appreciated.

voidus commented 4 years ago

If anybody is more knowledgeable about ghc and stuff, I would be willing to pair on debugging this.

lrworth commented 4 years ago

This looks the same as https://github.com/tweag/ormolu/issues/470, but the workaround there assumes you're building ormolu with cabal. I'm building it with nix directly (described in the README) which makes the workaround hard to implement.

lrworth commented 4 years ago

I guess it wasn't that hard to implement:

  ormolu = nixpkgs.haskell.packages."${ormoluCompiler}".ormolu.overrideAttrs (
    oldAttrs: rec {
      configureFlags = oldAttrs.configureFlags ++ [ "--ghc-option=-optP-Wno-nonportable-include-path" ];
    }
  );

but perhaps that ghc-option should be in the default.nix if it allows building on more OSes.

mrkkrp commented 4 years ago

@lrworth Do you want to open a PR?

lrworth commented 4 years ago

Absolutely I do.