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

Does not build with clang CPP (-traditional) #23

Closed pikajude closed 10 years ago

pikajude commented 10 years ago

I'm sure you're probably aware of this already, but as of right now it doesn't look like GCC will be usable at all on OS X Yosemite. I'd like to be able to build this package using clang as my compiler.

To clarify, the output from cabal install thyme -j1:

Resolving dependencies...
Configuring thyme-0.3.5.1...
Building thyme-0.3.5.1...
Preprocessing library thyme-0.3.5.1...
[ 1 of 20] Compiling Data.Thyme.Format.Internal ( src/Data/Thyme/Format/Internal.hs, dist/build/Data/Thyme/Format/Internal.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package primitive-0.5.3.0 ... linking ... done.
Loading package vector-0.10.11.0 ... linking ... done.
Loading package vector-th-unbox-0.2.1.0 ... linking ... done.
Loading package Boolean-0.2.1 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package text-1.1.1.3 ... linking ... done.
Loading package hashable-1.2.2.0 ... linking ... done.
Loading package nats-0.2 ... linking ... done.
Loading package unordered-containers-0.2.4.0 ... linking ... done.
Loading package semigroups-0.15.1 ... linking ... done.
Loading package void-0.6.1 ... linking ... done.
Loading package MemoTrie-0.6.2 ... linking ... done.
Loading package NumInstances-1.3 ... linking ... done.
Loading package vector-space-0.8.7 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package transformers-compat-0.3.3.4 ... linking ... done.
Loading package contravariant-0.6 ... linking ... done.
Loading package tagged-0.7.2 ... linking ... done.
Loading package distributive-0.4.4 ... linking ... done.
Loading package comonad-4.2 ... linking ... done.
Loading package semigroupoids-4.0.2.1 ... linking ... done.
Loading package profunctors-4.0.4 ... linking ... done.
Loading package scientific-0.3.2.1 ... linking ... done.
Loading package attoparsec-0.11.3.4 ... linking ... done.
Loading package dlist-0.7.0.1 ... linking ... done.
Loading package mtl-2.1.3.1 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package syb-0.4.2 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package aeson-0.7.0.6 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package tf-random-0.5 ... linking ... done.
Loading package QuickCheck-2.7.5 ... linking ... done.
[ 2 of 20] Compiling Data.Thyme.Internal.Micro ( src/Data/Thyme/Internal/Micro.hs, dist/build/Data/Thyme/Internal/Micro.o )
[ 3 of 20] Compiling Control.Lens     ( lens/Control/Lens.hs, dist/build/Control/Lens.o )
[ 4 of 20] Compiling Data.Thyme.Calendar.Internal ( src/Data/Thyme/Calendar/Internal.hs, dist/build/Data/Thyme/Calendar/Internal.o )
[ 5 of 20] Compiling Data.Thyme.Clock.Internal ( src/Data/Thyme/Clock/Internal.hs, dist/build/Data/Thyme/Clock/Internal.o )
[ 6 of 20] Compiling Data.Thyme.Calendar.MonthDay ( src/Data/Thyme/Calendar/MonthDay.hs, dist/build/Data/Thyme/Calendar/MonthDay.o )

src/Data/Thyme/Calendar/MonthDay.hs:17:12: parse error on input ‘_’
Failed to install thyme-0.3.5.1
cabal: Error: some packages failed to install:
thyme-0.3.5.1 failed during the building phase. The exception was:
ExitFailure 1

because the LENS macro in thyme.h uses token pasting. clang's preprocessor in traditional mode is not capable of token pasting at all—the empty comment /**/ becomes a space.

liyang commented 10 years ago

I wasn't aware of this... but I am now. Is it possible to invoke Clang's cpp in non-traditional mode and use ## I wonder? I'll take a look when I get some free time, unless you get there before me. ;)

maoe commented 10 years ago

I got the same error. I've fixed it by installing a real gcc (I have gcc-4.9) and editing /path/to/ghc-$version/lib/ghc-$version/settings as follows:

--- /usr/local/ghc/ghc-7.8.2/lib/ghc-7.8.2/settings.orig        2014-07-09 22:40:50.000000000 +0900
+++ /usr/local/ghc/ghc-7.8.2/lib/ghc-7.8.2/settings     2014-07-09 22:41:42.000000000 +0900
@@ -1,5 +1,5 @@
 [("GCC extra via C opts", " -fwrapv"),
- ("C compiler command", "/usr/bin/gcc"),
+ ("C compiler command", "/usr/local/bin/gcc-4.9"),
  ("C compiler flags", " -m64 -fno-stack-protector"),
  ("C compiler link flags", " -m64"),
  ("ld command", "/usr/bin/ld"),
pikajude commented 10 years ago

@maoe: GCC is unusable on 10.10 because it can't parse one of the system header files, which is included by everything in the stdlib.

pikajude commented 10 years ago

It looks like thyme will build successfully with cpphs. I guess we need to push harder on the GHC people to make the compiler use cpphs by default.

liyang commented 10 years ago

Does the above commit fix things on Mavericks? It creates a dependency on cpphs for all Darwin users, but that's probably acceptable.

maoe commented 10 years ago

@liyang I just confirmed that your fix builds fine with vanilla GHC 7.8.2 on Mavericks, but when I ran the tests I got the same error as in the travis build..

pikajude commented 10 years ago

@liyang: as @maoe says, commit fixes the build on Darwin, but causes the Travis failure.

liyang commented 10 years ago

The current Travis failure is due to tests/rewrite.hs being built against an older version of Cabal than what cabal-install uses. I'm not sure how to get it to use the same version…

liyang commented 10 years ago

Released as 0.3.5.2.