metomi / fab

Flexible build system for scientific software

Home Page:https://metomi.github.io/fab/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent hash codes when using ifort

hiker opened this issue · comments

While working on #278, I realised that using ifort causes a test failure when verifying that the hashes for output files is independent of the work space name (to allow to re-use pre-builds from one workspace in another).

fab/tests/system_tests/prebuild/project-source$ FC=ifort pytest -vv  -s -k test_repeatable_fmod_hashes  prebuild/test_prebuild.py
...
E         -  PosixPath('_prebuild/my_mod.1aa4290e6.mod'): 2725749175,
E         ?                                                ^  ^^ --
E         +  PosixPath('_prebuild/my_mod.1aa4290e6.mod'): 2920253950,
E         ?                                                ^^^  ^  +
E            PosixPath('_prebuild/my_mod.1b78f4c0f.o'): 3724373647,
E         -  PosixPath('_prebuild/my_prog.1e21c6108.o'): 2143634917,
E         ?                                 ^^^^^^^
E         +  PosixPath('_prebuild/my_prog.1edb4494f.o'): 2143634917,
E         ?                                 ^^^^^^^
E           }

The difference in the .mod file is just one byte atm, caused by a kind of time stamp:

< 00000030  f2 36 f0 65 00 00 00 00  0b 00 00 00 00 00 00 00  |.6.e............|
---
> 00000030  f4 36 f0 65 00 00 00 00  0b 00 00 00 00 00 00 00  |.6.e............|

If I convert the 4 bytes around this one byte difference I get the #seconds since epoch :)

I assume the difference in the hashed file names for my_prog is caused by the different hashes of the mod files?

The question is, should the failing test:

  1. NOT test if the hashes of the .mod files are identical
  2. NOT test if the hashes of the .o files are identical
  3. The hashes used when computing the combined-hash from dependencies should be changed so that it does NOT use the hashes of the .o and .mod files (which I believe it is doing), but maybe use the hash of the source file combined with the hash of compiler version and flags? E g. in the example above my_mod.1aa...e6.mod, assuming that 1aa...e6 hashes the source file, compiler and flags - wouldn't that be a better hash then that avoids these problems?