haskell-github-trust / thyme

A faster date and time library based on time
BSD 3-Clause "New" or "Revised" License
46 stars 33 forks source link

Please declare dependency on 'cpphs' in the build tools stanza of your cabal file ... #28

Closed peti closed 8 years ago

peti commented 10 years ago

... because builds fail if that tool isn't available.

liyang commented 10 years ago

@peti I haven't been able to reproduce this. cpphs is only required on recent OS X due to Clang's CPP breaking the -traditional way of doing token-pasting (see #23). I have confirmed that everything builds fine without cpphs on Ubuntu at least…

Could you show me the build error on NixOS? Thanks.

peti commented 10 years ago

We've had the error compiling on Darwin. (Note that Nix is cross-platform; we build on Linux, Darwin, BSD, and even Cygwin.) In https://github.com/NixOS/nixpkgs/commit/0e588f35fc4ab1a94437653f1ad0ad5dc3b961dd @jwiegley added cpphs to fix the issue. Unfortunately, I cannot provide a build log because I don't have access to Darwin, but maybe @jwiegley can help out?

jwiegley commented 10 years ago

I don't quite remember what the issue was. If someone can point me to a log, I'd be happy to track it down.

liyang commented 10 years ago

Ah, I hadn't realised NixOS was being built on anything other than the GNU toolchain. I think this is a Clang issue (see #23), and Cabal can't really tell the native CPP is coming from so I guess it'll be easier just to switch to cpphs for all platforms.

liyang commented 10 years ago

Thinking about it a little more, I already have the following in thyme.cabal:

    if os(darwin)
        build-tools: cpphs
        ghc-options: -pgmP cpphs -optP--cpp

Could you confirm that Cabal isn't detecting os(darwin) correctly in your case? What's $OSTYPE for NixOS/Darwin? (I think this is the same as System.Info.os.)

peti commented 10 years ago

Oh, that is an interesting problem. Nix controls the exact set of packages that the build can see, i.e. only those paths that have been declared as a dependency will be visible in the chroot environment. The build instructions, https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/haskell/thyme/default.nix, don't mention cpphs, however, because we generate those expressions by running Cabal's finalizePackageDescription assuming our target platform is Linux/i686: https://github.com/NixOS/cabal2nix/blob/master/src/Cabal2Nix/Generate.hs#L58. In theory, we should probably parse the Cabal description separately for every target architecture/platform supported by Nix and then merge the result into one Nix expression that combines all that know-how, but this would be very hard to implement.

What we've do instead to remedy the situation is to hard-code that know-how about cpphs into our cabal2nix tool: https://github.com/NixOS/cabal2nix/blob/master/src/Cabal2Nix/PostProcess.hs#L106.

So, arguably, this bug report is invalid. Thyme does the right thing, it's just our particular build environment that fails to take advantage of the information properly.

liyang commented 10 years ago

Ah, I see! I guess most packages would be checking if os(windows) or something which doesn't affect Nix. I made an attempt to look for other affected packages that's already in Nix, and came across fsnotify: NixOS/cabal2nix#99 —I guess that's basically the same underlying issue…

peti commented 10 years ago

Yeah, exactly. We had to duplicate the selection logic in Nix to get that package to build on something other than Linux.

LeviSchuck commented 9 years ago

I just ran into this today, please fix it already.

I use http://ghcformacosx.github.io GHC For Mac OS X, which is a very minimal installation.