Skip to content

Commit bf0a157

Browse files
authored
Disable -Xcheck-hashes, at least for the moment (#1940)
* Version increment to 0.5.1 This is to remove the requirement on Chez >9.5 * Disable -Xcheck-hases, at least for the moment If we're going to have this as an option, we need to have a portable way of finding a sha256sum command. At the moment, we might find a command, but different versions accept different options. We should at least allow setting it via an environment variable, and we certainly shouldn't fail if running the command fails. * Update bootstrap code ready for 0.5.1 release
1 parent 1e90182 commit bf0a157

File tree

10 files changed

+2397
-2381
lines changed

10 files changed

+2397
-2381
lines changed

bootstrap/idris2_app/idris2.rkt

Lines changed: 1171 additions & 1172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/idris2_app/idris2.ss

Lines changed: 1171 additions & 1172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Core/Binary.idr

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import public Libraries.Utils.Binary
3333
||| (Increment this when changing anything in the data format)
3434
export
3535
ttcVersion : Int
36-
ttcVersion = 62
36+
ttcVersion = 63
3737

3838
export
3939
checkTTCVersion : String -> Int -> Int -> Core ()
@@ -44,7 +44,7 @@ record TTCFile extra where
4444
constructor MkTTCFile
4545
version : Int
4646
totalReq : TotalReq
47-
sourceHash : String
47+
sourceHash : Maybe String
4848
ifaceHash : Int
4949
importHashes : List (Namespace, Int)
5050
incData : List (CG, String, List String)
@@ -289,12 +289,13 @@ writeToTTC extradata sourceFileName ttcFileName
289289
totalReq <- getDefaultTotalityOption
290290
log "ttc.write" 5 $ unwords
291291
[ "Writing", ttcFileName
292-
, "with source hash", sourceHash
292+
, "with source hash", show sourceHash
293293
, "and interface hash", show (ifaceHash defs)
294294
]
295295
writeTTCFile bin
296296
(MkTTCFile ttcVersion totalReq
297-
sourceHash (ifaceHash defs) (importHashes defs)
297+
sourceHash
298+
(ifaceHash defs) (importHashes defs)
298299
(incData defs)
299300
gdefs
300301
(keys (userHoles defs))
@@ -522,7 +523,7 @@ getImportHashes file b
522523
ver <- fromBuf @{Wasteful} b
523524
checkTTCVersion file ver ttcVersion
524525
totalReq <- fromBuf {a = TotalReq} b
525-
sourceFileHash <- fromBuf {a = String} b
526+
sourceFileHash <- fromBuf {a = Maybe String} b
526527
interfaceHash <- fromBuf {a = Int} b
527528
fromBuf b
528529

@@ -546,7 +547,7 @@ readTotalReq fileName
546547
(\err => pure Nothing)
547548

548549
export
549-
getHashes : String -> Ref Bin Binary -> Core (String, Int)
550+
getHashes : String -> Ref Bin Binary -> Core (Maybe String, Int)
550551
getHashes file b
551552
= do hdr <- fromBuf {a = String} b
552553
when (hdr /= "TT2") $ corrupt ("TTC header in " ++ file ++ " " ++ show hdr)
@@ -559,13 +560,13 @@ getHashes file b
559560

560561
export
561562
readHashes : (fileName : String) -> -- file containing the module
562-
Core (String, Int)
563+
Core (Maybe String, Int)
563564
readHashes fileName
564565
= do Right buffer <- coreLift $ readFromFile fileName
565-
| Left err => pure ("", 0)
566+
| Left err => pure (Nothing, 0)
566567
b <- newRef Bin buffer
567568
catch (getHashes fileName b)
568-
(\err => pure ("", 0))
569+
(\err => pure (Nothing, 0))
569570

570571
export
571572
readImportHashes : (fname : String) -> -- file containing the module

src/Core/Binary/Prims.idr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,9 @@ modTime fname
408408
pure t
409409

410410
export
411-
hashFileWith : String -> String -> Core String
412-
hashFileWith sha256sum fileName
411+
hashFileWith : Maybe String -> String -> Core (Maybe String)
412+
hashFileWith Nothing _ = pure Nothing
413+
hashFileWith (Just sha256sum) fileName
413414
= do Right fileHandle <- coreLift $ popen
414415
(sha256sum ++ " \"" ++ osEscape fileName ++ "\"") Read
415416
| Left _ => err
@@ -420,9 +421,9 @@ hashFileWith sha256sum fileName
420421
coreLift $ pclose fileHandle
421422
let w@(_::_) = words hashLine
422423
| Nil => err
423-
pure $ last w
424+
pure $ Just $ last w
424425
where
425-
err : Core String
426+
err : Core a
426427
err = coreFail $ InternalError ("Can't get " ++ sha256sum ++ " of " ++ fileName)
427428
osEscape : String -> String
428429
osEscape = if isWindows

src/Core/Options.idr

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ record Options where
201201
primnames : PrimNames
202202
extensions : List LangExt
203203
additionalCGs : List (String, CG)
204-
hashFn : String
204+
hashFn : Maybe String
205205

206206
export
207207
availableCGs : Options -> List (String, CG)
@@ -237,24 +237,31 @@ export
237237
defaultElab : ElabDirectives
238238
defaultElab = MkElabDirectives True True CoveringOnly 3 50 50 True
239239

240+
-- FIXME: This turns out not to be reliably portable, since different systems
241+
-- may have tools with the same name but different required arugments. We
242+
-- probably need another way (perhaps our own internal hash function, although
243+
-- that's not going to be as good as sha256).
240244
export
241-
defaultHashFn : Core String
245+
defaultHashFn : Core (Maybe String)
242246
defaultHashFn
243247
= do Nothing <- coreLift $ pathLookup ["sha256sum", "gsha256sum"]
244-
| Just p => pure $ p ++ " --tag"
248+
| Just p => pure $ Just $ p ++ " --tag"
245249
Nothing <- coreLift $ pathLookup ["sha256"]
246-
| Just p => pure $ p
250+
| Just p => pure $ Just p
247251
Nothing <- coreLift $ pathLookup ["openssl"]
248-
| Just p => pure $ p ++ " sha256"
249-
coreFail $ InternalError ("Can't get util to get sha256sum (tried `sha256sum`, `gsha256sum`, `sha256`, `openssl`)")
252+
| Just p => pure $ Just $ p ++ " sha256"
253+
pure Nothing
250254

251255
export
252256
defaults : Core Options
253257
defaults
254-
= do hashFn <- defaultHashFn
258+
= do -- hashFn <- defaultHashFn
259+
-- Temporarily disabling the hash function until we have a more
260+
-- portable way of working out what to call, and allowing a way for
261+
-- it to fail gracefully.
255262
pure $ MkOptions
256263
defaultDirs defaultPPrint defaultSession defaultElab Nothing Nothing
257-
(MkPrimNs Nothing Nothing Nothing Nothing) [] [] hashFn
264+
(MkPrimNs Nothing Nothing Nothing Nothing) [] [] Nothing
258265

259266
-- Reset the options which are set by source files
260267
export

src/Idris/ModTree.idr

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ checkDepHashes : {auto c : Ref Ctxt Defs} ->
174174
String -> Core Bool
175175
checkDepHashes depFileName
176176
= catch (do defs <- get Ctxt
177-
depCodeHash <- hashFileWith (defs.options.hashFn) depFileName
177+
Just depCodeHash <- hashFileWith (defs.options.hashFn) depFileName
178+
| _ => pure False
178179
depTTCFileName <- getTTCFileName depFileName "ttc"
179-
(depStoredCodeHash, _) <- readHashes depTTCFileName
180+
(Just depStoredCodeHash, _) <- readHashes depTTCFileName
181+
| _ => pure False
180182
pure $ depCodeHash /= depStoredCodeHash)
181183
(\error => pure False)
182184

@@ -186,11 +188,15 @@ needsBuildingHash : {auto c : Ref Ctxt Defs} ->
186188
(sourceFile : String) -> (ttcFile : String) ->
187189
(depFiles : List String) -> Core Bool
188190
needsBuildingHash sourceFile ttcFile depFiles
189-
= do defs <- get Ctxt
190-
codeHash <- hashFileWith (defs.options.hashFn) sourceFile
191-
(storedCodeHash, _) <- readHashes ttcFile
192-
depFilesHashDiffers <- any id <$> traverse checkDepHashes depFiles
193-
pure $ codeHash /= storedCodeHash || depFilesHashDiffers
191+
= do defs <- get Ctxt
192+
-- If there's no hash available, either in the TTC or from the
193+
-- current source, then it needs building
194+
Just codeHash <- hashFileWith (defs.options.hashFn) sourceFile
195+
| _ => pure True
196+
(Just storedCodeHash, _) <- readHashes ttcFile
197+
| _ => pure True
198+
depFilesHashDiffers <- any id <$> traverse checkDepHashes depFiles
199+
pure $ codeHash /= storedCodeHash || depFilesHashDiffers
194200

195201
export
196202
needsBuilding :

src/Idris/ProcessIdr.idr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ unchangedTime sourceFileName ttcFileName
237237

238238

239239
||| If the source file hash hasn't changed
240-
unchangedHash : (hashFn : String) -> (sourceFileName : String) -> (ttcFileName : String) -> Core Bool
240+
unchangedHash : (hashFn : Maybe String) -> (sourceFileName : String) -> (ttcFileName : String) -> Core Bool
241241
unchangedHash hashFn sourceFileName ttcFileName
242-
= do sourceCodeHash <- hashFileWith hashFn sourceFileName
243-
(storedSourceHash, _) <- readHashes ttcFileName
242+
= do Just sourceCodeHash <- hashFileWith hashFn sourceFileName
243+
| _ => pure False
244+
(Just storedSourceHash, _) <- readHashes ttcFileName
245+
| _ => pure False
244246
pure $ sourceCodeHash == storedSourceHash
245247

246248
export

src/Idris/SetOptions.idr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ preOptions (IgnoreShadowingWarnings :: opts)
413413
= do updateSession (record { showShadowingWarning = False })
414414
preOptions opts
415415
preOptions (HashesInsteadOfModTime :: opts)
416-
= do updateSession (record { checkHashesInsteadOfModTime = True })
416+
= do throw (InternalError "-Xcheck-hashes disabled (see issue #1935)")
417+
updateSession (record { checkHashesInsteadOfModTime = True })
417418
preOptions opts
418419
preOptions (CaseTreeHeuristics :: opts)
419420
= do updateSession (record { caseTreeHeuristics = True })

tests/idris2/import001/expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ Test> Bye for now!
66
2/3: Building Mult (Mult.idr)
77
Test> S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Z)))))))))))))))))
88
Test> Bye for now!
9-
Test> S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Z)))))))))))))))))
10-
Test> Bye for now!

tests/idris2/import001/run

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ $1 --no-color --console-width 0 --no-banner --no-prelude Test.idr < input
44
sleep 1
55
touch Mult.idr
66
$1 --no-color --console-width 0 --no-banner --no-prelude Test.idr < input
7-
sleep 1
8-
touch Mult.idr
9-
$1 --no-color --console-width 0 --no-banner --no-prelude -Xcheck-hashes Test.idr < input
7+
8+
# Disabled until we have a portable way to do this
9+
#sleep 1
10+
#touch Mult.idr
11+
#$1 --no-color --console-width 0 --no-banner --no-prelude -Xcheck-hashes Test.idr < input
1012

0 commit comments

Comments
 (0)