Skip to content

Commit

Permalink
[SCons] Fix nondeterminism in source generation
Browse files Browse the repository at this point in the history
In Fedora rebuilds to test package build reproducibility
(see https://reproducible-builds.org/,
https://fedoraproject.org/wiki/Changes/ReproduciblePackageBuilds),
we get the following differences like the following for various CMakeLists.txt
and SConstruct files:

/usr/share/cantera/samples/cxx/LiC6_electrode/CMakeLists.txt:
│ │ -include_directories("/usr/include" "/usr/include/eigen3" "/usr/include/highfive")
│ │ +include_directories("/usr/include/highfive" "/usr/include/eigen3" "/usr/include")

Those end up in the -debugsources package and cause the whole build to be
flagged as irreproducible. In addition, if the an include file with the same
name happened to be present in more than one location, the unpredictable sort
order would mean that different files would be used in different builds. Sort
the directories alphabetically for predictable results.
  • Loading branch information
keszybz authored and speth committed Oct 30, 2024
1 parent 3ba21c4 commit ee461a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions samples/cxx/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ for sample in samples:
incdirs.extend([localenv["sundials_include"], localenv["boost_inc_dir"]])
incdirs.append(localenv["hdf_include"])
incdirs.extend(localenv["extra_inc_dirs"])
incdirs = list(set(incdirs))
incdirs = sorted(set(incdirs))

libdirs.extend(localenv["extra_lib_dirs"])
libdirs = list(set(libdirs))
libdirs = sorted(set(libdirs))

if env["OS"] == "Darwin" and env["use_rpath_linkage"] and not env.subst("$__RPATH"):
# SCons fails to specify RPATH on macOS, so circumvent that behavior by
Expand Down
4 changes: 2 additions & 2 deletions samples/f77/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ else:
incdirs.extend([localenv["sundials_include"], localenv["boost_inc_dir"]])
incdirs.append(localenv["hdf_include"])
incdirs.extend(localenv["extra_inc_dirs"])
incdirs = list(set(incdirs))
incdirs = sorted(set(incdirs))

libdirs.extend([localenv["sundials_libdir"], localenv["blas_lapack_dir"]])
libdirs.append(localenv["hdf_libdir"])
libdirs.extend(localenv["extra_lib_dirs"])
libdirs = list(set(libdirs))
libdirs = sorted(set(libdirs))

libs = ["cantera_fortran"] + localenv["cantera_libs"] + localenv["cxx_stdlib"]

Expand Down
2 changes: 1 addition & 1 deletion samples/f90/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for programName, sources in samples:
libdirs.extend([localenv["sundials_libdir"], localenv["blas_lapack_dir"]])
libdirs.append(localenv["hdf_libdir"])
libdirs.extend(localenv["extra_lib_dirs"])
libdirs = list(set(libdirs))
libdirs = sorted(set(libdirs))

libs = ['cantera_fortran'] + localenv['cantera_libs'] + env['cxx_stdlib']

Expand Down

0 comments on commit ee461a3

Please sign in to comment.