Skip to content

Commit aee3538

Browse files
committed
Cabal 3.14 & GHC 9.12 support
1 parent 22b94a0 commit aee3538

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

Setup.hs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE DataKinds #-}
13
{-# LANGUAGE MultiWayIf #-}
24
{-# OPTIONS -Wall #-}
35
module Main where
@@ -11,6 +13,17 @@ import Distribution.Simple.Utils
1113
import Distribution.System
1214
import Distribution.Verbosity
1315

16+
#if MIN_VERSION_Cabal(3,14,0)
17+
-- Note [Cabal 3.14]
18+
--
19+
-- If you change any path stuff, either test that the package still works with
20+
-- Cabal 3.12 or stop declaring support for it in accelerate.cabal. (If you do
21+
-- the latter, also remove all of the other conditionals in this file.)
22+
-- Note that supporting old versions of Cabal is useful for being able to run
23+
-- e.g. Accelerate on old GPU clusters, which is nice.
24+
import Distribution.Utils.Path (SymbolicPath, FileOrDir(Dir), Pkg, CWD, interpretSymbolicPath)
25+
#endif
26+
1427
import Control.Monad
1528
import Data.Maybe
1629
import System.Directory
@@ -44,13 +57,13 @@ preConfHook args config_flags = do
4457
-- Stack and cabal based builds require updating the submodules
4558
git <- doesDirectoryExist ".git"
4659
if git
47-
then rawSystemExit verbosity "git" ["submodule", "update", "--init", "--recursive"]
60+
then rawSystemExit' verbosity "git" ["submodule", "update", "--init", "--recursive"]
4861
else do
4962
-- XXX: This must be kept up to date with the git submodule revision
5063
let archive = "v0.11.1.tar.gz"
5164
createDirectoryIfMissing True "cbits/tracy"
52-
rawSystemExit verbosity "curl" ["-LO", "https://github.com/wolfpld/tracy/archive/refs/tags/" ++ archive]
53-
rawSystemExit verbosity "tar" ["-xzf", archive, "-C", "cbits/tracy", "--strip-components", "1"]
65+
rawSystemExit' verbosity "curl" ["-LO", "https://github.com/wolfpld/tracy/archive/refs/tags/" ++ archive]
66+
rawSystemExit' verbosity "tar" ["-xzf", archive, "-C", "cbits/tracy", "--strip-components", "1"]
5467
removeFile archive
5568

5669
preConf simpleUserHooks args config_flags
@@ -69,8 +82,9 @@ postBuildHook args build_flags pkg_desc lbi = do
6982
Windows -> return () -- XXX TODO: Windows users get the dummy executable that just throws an error
7083
_ ->
7184
forM_ targets $ \(hs_exe, c_dir, c_exe) -> do
72-
let c_projdir = "cbits/tracy" </> c_dir
73-
hs_builddir = buildDir lbi </> hs_exe
85+
let cwd = flagToMaybe (workingDirFlag build_flags)
86+
c_projdir = "cbits/tracy" </> c_dir
87+
hs_builddir = interpretSymbolicPath cwd (buildDir lbi) </> hs_exe
7488
hs_tmpdir = hs_builddir </> hs_exe ++ "-tmp"
7589

7690
-- TODO: This creates a separate build directory for each tracy
@@ -92,12 +106,12 @@ postBuildHook args build_flags pkg_desc lbi = do
92106
setupMessage verbosity (printf "Building executable '%s' from Tracy C++ sources for" hs_exe) (package pkg_desc)
93107

94108
-- We set LEGACY=1 so that tracy builds with X11 instead of Wayland.
95-
rawSystemExit verbosity "cmake" ["-B", hs_tmpdir, "-S", c_projdir, "-DCMAKE_BUILD_TYPE=Release", "-DLEGACY=1"]
109+
rawSystemExit' verbosity "cmake" ["-B", hs_tmpdir, "-S", c_projdir, "-DCMAKE_BUILD_TYPE=Release", "-DLEGACY=1"]
96110

97111
-- Build in parallel with 2 jobs because likely, accelerate is one of
98112
-- the last dependencies in a build, so we aren't stealing CPU time
99113
-- from other packages, and tracy takes way too long to build
100-
rawSystemExit verbosity "cmake" ["--build", hs_tmpdir, "--config", "Release", "-j", "2"]
114+
rawSystemExit' verbosity "cmake" ["--build", hs_tmpdir, "--config", "Release", "-j", "2"]
101115

102116
-- Copy, not rename, to prevent cmake from linking again on the next
103117
-- reconfigure
@@ -109,3 +123,23 @@ tracyMode :: ConfigFlags -> Bool
109123
tracyMode config_flags =
110124
fromMaybe False $
111125
lookupFlagAssignment (mkFlagName "tracy") (configConfigurationsFlags config_flags)
126+
127+
128+
rawSystemExit' :: Verbosity -> FilePath -> [String] -> IO ()
129+
130+
#if MIN_VERSION_Cabal(3,14,0)
131+
rawSystemExit' verb = rawSystemExit verb Nothing
132+
133+
workingDirFlag :: BuildFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
134+
workingDirFlag = setupWorkingDir . buildCommonFlags
135+
136+
-- interpretSymbolicPath is an actual useful function in Cabal-3.14
137+
#else
138+
rawSystemExit' = rawSystemExit
139+
140+
workingDirFlag :: BuildFlags -> Flag ()
141+
workingDirFlag _ = NoFlag
142+
143+
interpretSymbolicPath :: Maybe CWDPath -> FilePath -> FilePath
144+
interpretSymbolicPath _ = id
145+
#endif

src/Data/Array/Accelerate/Data/Semigroup.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,17 @@ instance Semigroup (Exp ()) where
155155

156156
instance (Elt a, Elt b, Semigroup (Exp a), Semigroup (Exp b)) => Semigroup (Exp (a,b)) where
157157
(<>) = lift2 ((<>) :: (Exp a, Exp b) -> (Exp a, Exp b) -> (Exp a, Exp b))
158-
stimes n (unlift -> (a,b) :: (Exp a, Exp b)) = lift (stimes n a, stimes n b)
158+
stimes n (unlift -> ((a,b) :: (Exp a, Exp b))) = lift (stimes n a, stimes n b)
159159

160160
instance (Elt a, Elt b, Elt c, Semigroup (Exp a), Semigroup (Exp b), Semigroup (Exp c)) => Semigroup (Exp (a,b,c)) where
161161
(<>) = lift2 ((<>) :: (Exp a, Exp b, Exp c) -> (Exp a, Exp b, Exp c) -> (Exp a, Exp b, Exp c))
162-
stimes n (unlift -> (a,b,c) :: (Exp a, Exp b, Exp c)) = lift (stimes n a, stimes n b, stimes n c)
162+
stimes n (unlift -> ((a,b,c) :: (Exp a, Exp b, Exp c))) = lift (stimes n a, stimes n b, stimes n c)
163163

164164
instance (Elt a, Elt b, Elt c, Elt d, Semigroup (Exp a), Semigroup (Exp b), Semigroup (Exp c), Semigroup (Exp d)) => Semigroup (Exp (a,b,c,d)) where
165165
(<>) = lift2 ((<>) :: (Exp a, Exp b, Exp c, Exp d) -> (Exp a, Exp b, Exp c, Exp d) -> (Exp a, Exp b, Exp c, Exp d))
166-
stimes n (unlift -> (a,b,c,d) :: (Exp a, Exp b, Exp c, Exp d)) = lift (stimes n a, stimes n b, stimes n c, stimes n d)
166+
stimes n (unlift -> ((a,b,c,d) :: (Exp a, Exp b, Exp c, Exp d))) = lift (stimes n a, stimes n b, stimes n c, stimes n d)
167167

168168
instance (Elt a, Elt b, Elt c, Elt d, Elt e, Semigroup (Exp a), Semigroup (Exp b), Semigroup (Exp c), Semigroup (Exp d), Semigroup (Exp e)) => Semigroup (Exp (a,b,c,d,e)) where
169169
(<>) = lift2 ((<>) :: (Exp a, Exp b, Exp c, Exp d, Exp e) -> (Exp a, Exp b, Exp c, Exp d, Exp e) -> (Exp a, Exp b, Exp c, Exp d, Exp e))
170-
stimes n (unlift -> (a,b,c,d,e) :: (Exp a, Exp b, Exp c, Exp d, Exp e)) = lift (stimes n a, stimes n b, stimes n c, stimes n d, stimes n e)
170+
stimes n (unlift -> ((a,b,c,d,e) :: (Exp a, Exp b, Exp c, Exp d, Exp e))) = lift (stimes n a, stimes n b, stimes n c, stimes n d, stimes n e)
171171

0 commit comments

Comments
 (0)