diff --git a/Setup.hs b/Setup.hs index 42bb1a6..46b921c 100644 --- a/Setup.hs +++ b/Setup.hs @@ -137,7 +137,7 @@ libraryBuildInfo -> IO HookedBuildInfo libraryBuildInfo verbosity profile installPath platform@(Platform arch os) ghcVersion extraLibs extraIncludes = do let - libraryPaths = cudaLibraryPath platform installPath : extraLibs + libraryPaths = cudaLibraryPaths platform installPath <> extraLibs includePaths = cudaIncludePath platform installPath : extraIncludes takeFirstExisting paths = do @@ -214,16 +214,16 @@ cudaIncludePath _ installPath = installPath "include" -- Return the location of the libraries relative to the base CUDA installation. -- -cudaLibraryPath :: Platform -> FilePath -> FilePath -cudaLibraryPath (Platform arch os) installPath = installPath libpath +cudaLibraryPaths :: Platform -> FilePath -> [FilePath] +cudaLibraryPaths (Platform arch os) installPath = () <$> [installPath] <*> libpath where libpath = case (os, arch) of - (Windows, I386) -> "lib/Win32" - (Windows, X86_64) -> "lib/x64" - (OSX, _) -> "lib" -- MacOS does not distinguish 32- vs. 64-bit paths - (_, X86_64) -> "lib64" -- treat all others similarly - _ -> "lib" + (Windows, I386) -> ["lib/Win32"] + (Windows, X86_64) -> ["lib/x64"] + (OSX, _) -> ["lib"] -- MacOS does not distinguish 32- vs. 64-bit paths + (_, X86_64) -> ["lib64", "lib"] -- Prefer lib64, but the nixpkgs distriubtion of cudatools moves files to lib. - AM + _ -> ["lib"] -- On Windows and OSX we use different libraries depending on whether we are @@ -233,6 +233,7 @@ cudaLibraries :: Platform -> [String] cudaLibraries (Platform _ os) = case os of OSX -> ["cudadevrt", "cudart_static"] + Linux -> ["cudadevrt"] _ -> ["cudart", "cuda"] cudaGHCiLibraries @@ -261,7 +262,9 @@ cudaGhciLibrariesWindows -> [FilePath] -> IO [FilePath] cudaGhciLibrariesWindows platform installPath libraries = do - candidates <- mapM (importLibraryToDLLFileName platform) [ cudaLibraryPath platform installPath lib <.> "lib" | lib <- libraries ] + let pathRoots = cudaLibraryPaths platform installPath + let toLibPath path lib = path lib <.> "lib" + candidates <- mapM (importLibraryToDLLFileName platform) (toLibPath <$> pathRoots <*> libraries) return [ dropExtension dll | Just dll <- candidates ] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..2d8f93b --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: + pkgs.mkShell { + buildInputs = [ pkgs.git pkgs.ghc pkgs.cabal-install ]; + }