Giter Site home page Giter Site logo

Comments (4)

tibbe avatar tibbe commented on July 30, 2024

Could we instead use ghc-options as GHC is used to compiled C files? Alternatively I think __SSE2__ is set by the C compiler itself, it is enabled, but someone needs to double-check with both gcc and llvm.

from hashable.

cartazio avatar cartazio commented on July 30, 2024

Ohhh, i have a way to make this work!

https://gist.github.com/cartazio/5842786

I had the same problem, this should fix it! (you need shim in the right flags via setup.hs)

replicating my above gist below

{-# Language NamedFieldPuns #-}
{-#Language BangPatterns #-}
{-# LANGUAGE CPP #-}
import Distribution.Simple
import Distribution.Simple.Program.Builtin
import Distribution.Simple.Program.Types
import Distribution.Simple.Program

import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
--main = defaultMain



main :: IO ()
#if x86_64_HOST_ARCH
main = do putStrLn "we recommend using -fllvm for your numerical code. Numerics requires Clang on Mac"
        defaultMainWithHooks myhook 
#else   
main = error "only x86_64 architectures are currently supported" 
#endif 

{-
this is to work around mac having a really old GCC version and AS (assembler)
darwin is OSX
-}
#if darwin_HOST_OS 
myhook =  set lensBuildHook2UserHooks myBuildHook simpleUserHooks 
    where 
        oldbuildhook = get lensBuildHook2UserHooks simpleUserHooks
        myBuildHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
        myBuildHook packDesc  locBuildInfo  = 
            oldbuildhook packDesc   (set lensProgramConfig2LocBuildInfo newProgramConfig locBuildInfo)
                where   !(Just !oldGhcConf) =lookupProgram ghcProgram oldProgramConfig

                        oldProgramConfig = get lensProgramConfig2LocBuildInfo locBuildInfo
                        oldOverrideArgs = get lensProgramOverrideArgs2ConfiguredProgram oldGhcConf
                        newOverrideArgs = oldOverrideArgs++["-pgma clang", "-pgmc clang"] 
                        newGhcConf = set lensProgramOverrideArgs2ConfiguredProgram newOverrideArgs oldGhcConf
                        newProgramConfig = updateProgram newGhcConf oldProgramConfig
#else
myhook = simpleUserHooks
#endif 
{-
    On mac we need to use Clang as the assembler and C compiler to enable
-}


            {-basically mangle adding -pgma and pgmc to the flags for the ghc withprograms in local build info
            local build info -> with program -}



    --simpleUserHooks { hookedPrograms = [ghcProgram { programPostConf = \ a b -> return ["-pgma clang", "-pgmc clang"] }] }
lensProgramOverrideArgs2ConfiguredProgram :: Lens [String] ConfiguredProgram
lensProgramOverrideArgs2ConfiguredProgram = 
        Lens (\ConfiguredProgram{programOverrideArgs}-> programOverrideArgs)
             (\newargs confprog -> confprog{programOverrideArgs = newargs})

lensBuildHook2UserHooks :: Lens (PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()) UserHooks
lensBuildHook2UserHooks = Lens (\UserHooks{buildHook}->buildHook) (\ bh  uhook -> uhook{buildHook=bh}) 

lensProgramConfig2LocBuildInfo :: Lens (ProgramConfiguration) (LocalBuildInfo)
lensProgramConfig2LocBuildInfo = Lens (\LocalBuildInfo{withPrograms}-> withPrograms) 
                                    (\wprog lbi -> lbi{withPrograms= wprog})

-- my mini lens!
data Lens a b = Lens (b->a) (a ->b  -> b)
infixr 9 #

(#) :: Lens a b -> Lens b c -> Lens a c 
(#) lenA@(Lens getA setA) lenB@(Lens getB setB)=  Lens (getA . getB) (\a c -> setB (setA a $ getB c) c)

get :: Lens a b -> b -> a
get (Lens lensGet _) b = lensGet b

set :: Lens a b -> a -> b -> b 
set (Lens _ lensSet) a b = lensSet a b  

from hashable.

cartazio avatar cartazio commented on July 30, 2024

the key point is I pass along some override flags to the ghc ALWAYS, not possible via the .cabal file, modify the above example to pass the options you want

from hashable.

tibbe avatar tibbe commented on July 30, 2024

SipHash is now only used in benchmarks so I'm closing this for now.

from hashable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.