Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
- "9.0"
- "9.2"
- "9.4"
- "9.6"
- "9.8"
- "9.10"
- "9.12"

steps:

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.17.0
* Add XXH3-64 source hash to mod files for reliable change detection
* **breaks mod file compatibility** with previous versions
* New C library dependency: xxHash (Haskell: `xxhash-ffi`)

### 0.16.9
* Added support for legacy features in Fortran 90 free-form style (selected via `--fortranVersion=Fortran90Legacy`)

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ the file name:
* Unknown extensions are parsed like `*.f` files.

## Building
You will need the GMP library plus header files: on many platforms, this will be
via the package `libgmp-dev`.
You will need the following C libraries plus header files:

* GMP: on many platforms, via the package `libgmp-dev`
* xxHash: on many platforms, via the package `libxxhash-dev`

Haskell library dependencies are listed in `package.yaml`. fortran-src supports
building with Stack or Cabal.
Expand Down
24 changes: 14 additions & 10 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Main ( main ) where
import Prelude hiding (readFile, mod)
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as LB
import Data.Word (Word8)

import Text.PrettyPrint (render)

Expand Down Expand Up @@ -82,8 +83,8 @@ main = do
, not (null nxt) = do
let fnPaths = [ fn | (_, Just (MOFile fn)) <- nxt ]
newMods <- fmap concat . forM fnPaths $ \ fnPath -> do
tsStatus <- checkTimestamps fnPath
case tsStatus of
hashStatus <- checkModFileHash fnPath
case hashStatus of
NoSuchFile -> do
putStr $ "Does not exist: " ++ fnPath
pure [emptyModFile]
Expand Down Expand Up @@ -159,13 +160,15 @@ main = do
case decodeModFile contents' of
Left msg -> putStrLn $ "Error: " ++ msg
Right mfs -> forM_ mfs $ \ mf ->
putStrLn $ "Filename: " ++ moduleFilename mf ++
"\n\nStringMap:\n" ++ showStringMap (combinedStringMap [mf]) ++
"\n\nModuleMap:\n" ++ showModuleMap (combinedModuleMap [mf]) ++
"\n\nDeclMap:\n" ++ showGenericMap (combinedDeclMap [mf]) ++
"\n\nTypeEnv:\n" ++ showTypes (combinedTypeEnv [mf]) ++
"\n\nParamVarMap:\n" ++ showGenericMap (combinedParamVarMap [mf]) ++
"\n\nOther Data Labels: " ++ show (getLabelsModFileData mf)
let hashHex = concatMap (printf "%02x") (B.unpack (moduleSourceHash mf))
in putStrLn $ "Filename: " ++ moduleFilename mf ++
"\nSource Hash (XXH3-64): " ++ hashHex ++
"\n\nStringMap:\n" ++ showStringMap (combinedStringMap [mf]) ++
"\n\nModuleMap:\n" ++ showModuleMap (combinedModuleMap [mf]) ++
"\n\nDeclMap:\n" ++ showGenericMap (combinedDeclMap [mf]) ++
"\n\nTypeEnv:\n" ++ showTypes (combinedTypeEnv [mf]) ++
"\n\nParamVarMap:\n" ++ showGenericMap (combinedParamVarMap [mf]) ++
"\n\nOther Data Labels: " ++ show (getLabelsModFileData mf)
ShowFlows isFrom isSuper astBlockId -> do
let pf = analyseParameterVars pvm .
analyseBBlocks .
Expand Down Expand Up @@ -221,7 +224,8 @@ compileFileToMod mvers mods path moutfile = do
let version = fromMaybe (deduceFortranVersion path) mvers
mmap = combinedModuleMap mods
tenv = stripExtended $ combinedTypeEnv mods
runCompile = genModFile . fst . analyseTypesWithEnv tenv . analyseRenamesWithModuleMap mmap . initAnalysis
sourceHash = computeSourceHash contents
runCompile = genModFile sourceHash . fst . analyseTypesWithEnv tenv . analyseRenamesWithModuleMap mmap . initAnalysis
parsedPF <-
case (Parser.byVerWithMods mods version) path contents of
Right pf -> return pf
Expand Down
7 changes: 5 additions & 2 deletions fortran-src.cabal
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.39.1.
-- This file has been generated from package.yaml by hpack version 0.38.1.
--
-- see: https://github.com/sol/hpack

name: fortran-src
version: 0.16.9
version: 0.17.0
synopsis: Parsers and analyses for Fortran standards 66, 77, 90, 95 and 2003 (partial).
description: Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, Fortran 95, Fortran 2003 (partial) and some legacy extensions. Includes data flow and basic block analysis, a renamer, and type analysis. For example usage, see the @<https://hackage.haskell.org/package/camfort CamFort>@ project, which uses fortran-src as its front end.
category: Language
Expand Down Expand Up @@ -205,6 +205,7 @@ library
, temporary >=1.2 && <1.4
, text >=1.2 && <2.2
, uniplate >=1.6 && <2
, xxhash-ffi ==0.3.*
default-language: Haskell2010
if os(windows)
cpp-options: -DFS_DISABLE_WIN_BROKEN_TESTS
Expand Down Expand Up @@ -269,6 +270,7 @@ executable fortran-src
, temporary >=1.2 && <1.4
, text >=1.2 && <2.2
, uniplate >=1.6 && <2
, xxhash-ffi ==0.3.*
default-language: Haskell2010
if os(windows)
cpp-options: -DFS_DISABLE_WIN_BROKEN_TESTS
Expand Down Expand Up @@ -368,6 +370,7 @@ test-suite spec
, temporary >=1.2 && <1.4
, text >=1.2 && <2.2
, uniplate >=1.6 && <2
, xxhash-ffi ==0.3.*
default-language: Haskell2010
if os(windows)
cpp-options: -DFS_DISABLE_WIN_BROKEN_TESTS
5 changes: 5 additions & 0 deletions haskell-flake-ghc92.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ pkgs: {
singletons.source = "3.0.1"; # req because singletons-th-3.1 had bad bounds
th-desugar.source = "1.13.1";
th-abstraction.source = "0.4.5.0";
xxhash-ffi.source = "0.3";
};

otherOverlays = [
(self: super: { libxxhash = pkgs.xxHash; })
];

# (note this is actually unused/we have to duplicate because it doesn't get
# packed into basePackages or any key we can use... but nice to document here)
devShell = {
Expand Down
5 changes: 5 additions & 0 deletions haskell-flake-ghc94.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ pkgs: {
#singletons.source = "3.0.1";
th-desugar.source = "1.14";
th-abstraction.source = "0.4.5.0";
xxhash-ffi.source = "0.3";
};

otherOverlays = [
(self: super: { libxxhash = pkgs.xxHash; })
];

# (note this is actually unused/we have to duplicate because it doesn't get
# packed into basePackages or any key we can use... but nice to document here)
devShell = {
Expand Down
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fortran-src
version: '0.16.9'
version: '0.17.0'
synopsis: Parsers and analyses for Fortran standards 66, 77, 90, 95 and 2003 (partial).
description: >-
Provides lexing, parsing, and basic analyses of Fortran code covering
Expand Down Expand Up @@ -98,6 +98,7 @@ dependencies:
- temporary >=1.2 && <1.4
- either ^>=5.0.1.1
- process >= 1.2.0.0
- xxhash-ffi >= 0.3 && < 0.4

- singletons >= 3.0 && < 3.6

Expand Down
Loading
Loading