From e27befb0031c5743e2ed30ec713a365e754c485d Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 9 Dec 2020 14:10:50 -0600 Subject: feat(bootstrap): Add support for same compilers as Fortran version --- bootstrap/src/Build.hs | 4 +- bootstrap/src/Fpm.hs | 181 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 2 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Build.hs b/bootstrap/src/Build.hs index 32d1979..8caf0c9 100644 --- a/bootstrap/src/Build.hs +++ b/bootstrap/src/Build.hs @@ -75,7 +75,7 @@ buildProgram programDirectory' libraryDirectories sourceExtensions buildDirector libraryModules <- findAvailableModules libraryDirectories let programDirectory = foldl1 () (splitDirectories programDirectory') let buildDirectory = foldl1 () (splitDirectories buildDirectory') - let includeFlags = map (includeFlag ++) libraryDirectories + let includeFlags = (includeFlag ++ buildDirectory) : map (includeFlag ++) libraryDirectories sourceFiles <- getDirectoriesFiles [programDirectory] sourceExtensions rawSources <- mapM sourceFileToRawSource sourceFiles let sources' = map processRawSource rawSources @@ -130,7 +130,7 @@ buildLibrary buildLibrary libraryDirectory sourceExtensions buildDirectory (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) libraryName otherLibraryDirectories = do otherModules <- findAvailableModules otherLibraryDirectories - let includeFlags = map (includeFlag ++) otherLibraryDirectories + let includeFlags = (includeFlag ++ buildDirectory) : map (includeFlag ++) otherLibraryDirectories sourceFiles <- getDirectoriesFiles [libraryDirectory] sourceExtensions rawSources <- mapM sourceFileToRawSource sourceFiles let sources = map processRawSource rawSources diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index 9fc1c91..294c77d 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -690,6 +690,187 @@ defineCompilerSettings specifiedFlags compiler release , compilerSettingsModuleFlag = "-J" , compilerSettingsIncludeFlag = "-I" } + | "f95" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [ "-O3" + , "-Wimplicit-interface" + , "-fPIC" + , "-fmax-errors=1" + , "-ffast-math" + , "-funroll-loops" + ] + else + [ "-Wall" + , "-Wextra" + , "-Wimplicit-interface" + , "-fPIC" + , "-fmax-errors=1" + , "-g" + , "-fbounds-check" + , "-fcheck-array-temporaries" + , "-Wno-maybe-uninitialized" + , "-Wno-uninitialized" + , "-fbacktrace" + ] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-J" + , compilerSettingsIncludeFlag = "-I" + } + | "nvfortran" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [ "-Mbackslash" + ] + else + [ "-Minform=inform" + , "-Mbackslash" + , "-g" + , "-Mbounds" + , "-Mchkptr" + , "-Mchkstk" + , "-traceback" + ] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-module" + , compilerSettingsIncludeFlag = "-I" + } + | "ifort" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [ "-fp-model precise" + , "-pc 64" + , "-align all" + , "-coarray" + , "-error-limit 1" + , "-reentrancy threaded" + , "-nogen-interfaces" + , "-assume byterecl" + , "-assume nounderscore" + ] + else + [ "-warn all" + , "-check:all:noarg_temp_created" + , "-coarray" + , "-error-limit 1" + , "-O0" + , "-g" + , "-assume byterecl" + , "-traceback" + ] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-module" + , compilerSettingsIncludeFlag = "-I" + } + | "ifx" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [] + else + [] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-module" + , compilerSettingsIncludeFlag = "-I" + } + | "pgfortran" `isInfixOf` compiler || "pgf90" `isInfixOf` compiler || "pgf95" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [] + else + [] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-module" + , compilerSettingsIncludeFlag = "-I" + } + | "flang" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [] + else + [] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-module" + , compilerSettingsIncludeFlag = "-I" + } + | "lfc" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [] + else + [] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-M" + , compilerSettingsIncludeFlag = "-I" + } + | "nagfor" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [ "-O4" + , "-coarray=single" + , "-PIC" + ] + else + [ "-g" + , "-C=all" + , "-O0" + , "-gline" + , "-coarray=single" + , "-PIC" + ] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-mdir" + , compilerSettingsIncludeFlag = "-I" + } + | "crayftn" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [] + else + [] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-J" + , compilerSettingsIncludeFlag = "-I" + } + | "xlf90" `isInfixOf` compiler + = let flags = case specifiedFlags of + [] -> if release + then + [] + else + [] + fs -> fs + in return $ CompilerSettings { compilerSettingsCompiler = compiler + , compilerSettingsFlags = flags + , compilerSettingsModuleFlag = "-qmoddir" + , compilerSettingsIncludeFlag = "-I" + } | otherwise = do putStrLn $ "Sorry, compiler is currently unsupported: " ++ compiler -- cgit v1.2.3 From 5cb18915d8622fc50bf139382d958a39797845a4 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 9 Dec 2020 14:51:33 -0600 Subject: fix(bootstrap-ifort): make adjustments for ifort's picky command line --- bootstrap/src/Build.hs | 4 ++-- bootstrap/src/Fpm.hs | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Build.hs b/bootstrap/src/Build.hs index 8caf0c9..724a1c6 100644 --- a/bootstrap/src/Build.hs +++ b/bootstrap/src/Build.hs @@ -108,7 +108,7 @@ buildProgram programDirectory' libraryDirectories sourceExtensions buildDirector in fileMatcher &?> \(objectFile : _) -> do need (sourceFile : directDependencies) cmd compiler - ["-c", moduleFlag ++ buildDirectory] + ["-c", moduleFlag, buildDirectory] includeFlags flags ["-o", objectFile, sourceFile] @@ -160,7 +160,7 @@ buildLibrary libraryDirectory sourceExtensions buildDirectory (CompilerSettings in fileMatcher &?> \(objectFile : _) -> do need (sourceFile : directDependencies) cmd compiler - ["-c", moduleFlag ++ buildDirectory] + ["-c", moduleFlag, buildDirectory] includeFlags flags ["-o", objectFile, sourceFile] diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index 294c77d..d647a10 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -745,24 +745,24 @@ defineCompilerSettings specifiedFlags compiler release = let flags = case specifiedFlags of [] -> if release then - [ "-fp-model precise" - , "-pc 64" - , "-align all" + [ "-fp-model", "precise" + , "-pc", "64" + , "-align", "all" , "-coarray" - , "-error-limit 1" - , "-reentrancy threaded" + , "-error-limit", "1" + , "-reentrancy", "threaded" , "-nogen-interfaces" - , "-assume byterecl" - , "-assume nounderscore" + , "-assume", "byterecl" + , "-assume", "nounderscore" ] else - [ "-warn all" + [ "-warn", "all" , "-check:all:noarg_temp_created" , "-coarray" - , "-error-limit 1" + , "-error-limit", "1" , "-O0" , "-g" - , "-assume byterecl" + , "-assume", "byterecl" , "-traceback" ] fs -> fs -- cgit v1.2.3 From f049ae6d8e4bfd58a5b69d692dd7e6273fd158af Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 9 Dec 2020 15:10:45 -0600 Subject: fix(bootstrap-ifort): remove coarray option, it is not supported --- bootstrap/src/Fpm.hs | 2 -- 1 file changed, 2 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index d647a10..1a41298 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -748,7 +748,6 @@ defineCompilerSettings specifiedFlags compiler release [ "-fp-model", "precise" , "-pc", "64" , "-align", "all" - , "-coarray" , "-error-limit", "1" , "-reentrancy", "threaded" , "-nogen-interfaces" @@ -758,7 +757,6 @@ defineCompilerSettings specifiedFlags compiler release else [ "-warn", "all" , "-check:all:noarg_temp_created" - , "-coarray" , "-error-limit", "1" , "-O0" , "-g" -- cgit v1.2.3 From 6e88f2ac8e569938e3cea7821d35ece0ce73b99c Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 9 Dec 2020 15:17:02 -0600 Subject: Revert "fix(bootstrap-ifort): remove coarray option, it is not supported" This reverts commit f049ae6d8e4bfd58a5b69d692dd7e6273fd158af. --- bootstrap/src/Fpm.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bootstrap') diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index 1a41298..d647a10 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -748,6 +748,7 @@ defineCompilerSettings specifiedFlags compiler release [ "-fp-model", "precise" , "-pc", "64" , "-align", "all" + , "-coarray" , "-error-limit", "1" , "-reentrancy", "threaded" , "-nogen-interfaces" @@ -757,6 +758,7 @@ defineCompilerSettings specifiedFlags compiler release else [ "-warn", "all" , "-check:all:noarg_temp_created" + , "-coarray" , "-error-limit", "1" , "-O0" , "-g" -- cgit v1.2.3 From 3ec6e97ccb77e01c55185d7d5a823b402f3ffca3 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 9 Dec 2020 15:17:55 -0600 Subject: feat(bootstrap-ifort): use `-coarray=single` by default --- bootstrap/src/Fpm.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index d647a10..6acf82b 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -748,7 +748,7 @@ defineCompilerSettings specifiedFlags compiler release [ "-fp-model", "precise" , "-pc", "64" , "-align", "all" - , "-coarray" + , "-coarray=single" , "-error-limit", "1" , "-reentrancy", "threaded" , "-nogen-interfaces" @@ -758,7 +758,7 @@ defineCompilerSettings specifiedFlags compiler release else [ "-warn", "all" , "-check:all:noarg_temp_created" - , "-coarray" + , "-coarray=single" , "-error-limit", "1" , "-O0" , "-g" -- cgit v1.2.3 From 1986edbbfa012d6bbe8ddbd9f1c487a901f587d8 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Thu, 10 Dec 2020 18:43:30 -0600 Subject: feat(bootstrap): try multiple ways to get compiler version info --- bootstrap/src/Fpm.hs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index 6acf82b..443d083 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -71,6 +71,7 @@ import System.Exit ( ExitCode(..) , exitWith ) import System.Process ( readProcess + , readProcessWithExitCode , system ) import Toml ( TomlCodec @@ -928,7 +929,23 @@ makeBuildPrefix :: FilePath -> [String] -> IO FilePath makeBuildPrefix compiler flags = do -- TODO Figure out what other info should be part of this -- Probably version, and make sure to not include path to the compiler - versionInfo <- readProcess compiler ["--version"] [] + versionInfo <- do + (exitCode, stdout, stderr) <- readProcessWithExitCode compiler + ["--version"] + [] + case exitCode of + ExitSuccess -> case stdout of + "" -> return stderr -- Guess this compiler outputs version info to stderr instead? + _ -> return stdout + _ -> do -- guess this compiler doesn't support the --version option. let's try -version + (exitCode, stdout, stderr) <- readProcessWithExitCode compiler + ["-version"] + [] + case exitCode of + ExitSuccess -> case stdout of + "" -> return stderr -- Guess this compiler outputs version info to stderr instead? + _ -> return stdout + _ -> return "" -- Don't know how to get version info, we'll let defineCompilerSettings report it as unsupported let compilerName = last (splitDirectories compiler) let versionHash = abs (hash versionInfo) let flagsHash = abs (hash flags) -- cgit v1.2.3 From 3ee23d827c3227200249791fa4cc73ce012f1a4f Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Thu, 10 Dec 2020 18:44:05 -0600 Subject: feat(boostrap-ifort): remove coarray option from ifort --- bootstrap/src/Fpm.hs | 2 -- 1 file changed, 2 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index 443d083..5b0e79b 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -749,7 +749,6 @@ defineCompilerSettings specifiedFlags compiler release [ "-fp-model", "precise" , "-pc", "64" , "-align", "all" - , "-coarray=single" , "-error-limit", "1" , "-reentrancy", "threaded" , "-nogen-interfaces" @@ -759,7 +758,6 @@ defineCompilerSettings specifiedFlags compiler release else [ "-warn", "all" , "-check:all:noarg_temp_created" - , "-coarray=single" , "-error-limit", "1" , "-O0" , "-g" -- cgit v1.2.3