scons: Simplify kvm architecture compatibility check. The original implementation had a function we'd call back into later which checked if a given ISA has KVM support on the current host. Instead, this change reverse that and statically figures out which single target ISA could possibly run under KVM on this host. Then later, we can just check if the ISA we're trying to build is that one. Change-Id: I3e7e06180983dfcc4611181718eb5d6210844d36 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40870 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Merge redundant checks for the socket library. scons can accept more than one library at a time, so lets check for both at once instead of writing out almost the same check twice. Change-Id: I82f9bdf59a349e28ca75a615d711051256ec73a4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40869 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Simplify the check for protoc. Collapse nesting, and constrain the try/except to only the line in that section which might actually be expected to throw an exception when things are working normally. This makes the code easier to read, and won't absorb and discard exceptions which are thrown for unexpected reasons. Change-Id: Id3ac417ab5545bef35ed8a87d05211c8ef2f5a50 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40867 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Create a Configure checker for pkg-config. This will check if a pkg-config package exists at all, and then if it does will attempt to use the supplied pkg-config arguments and ParseConfig to set up the environment as needed. Change-Id: I1495e5370b60dcebb1c9ce38517e84d727abc2fd Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40866 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Simplify the check for hdf5 support. Collapse the check_hdf5 to the only place it was called, to set a simple flag variable. Pull the invariant have_pkg_config check out of check_hdf5_pkg, since if we don't have pkg-config there's no reason to even try to use to set up hdf5. Turn the one-off, non-standard "Warning" print into an actual warning(). Change-Id: I04793ae862aeaf1605467d205837b9dd744f93cb Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40865 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Simplify backtrace implementation detection. There are really only two options current, glibc or none. If there's a working implementation there's no real reason to select none, and if there isn't there's no other option but to select none. Instead of building up a list, having a default, and making what option on the list is selected configurable, boil it down to either using glibc if that implementation is detected, or warning and using none. Also merge the "normal" and *BSD versions of the checks to reduce redundancy. The complexity can be added back in if/when there are other implementations to choose from. Change-Id: I27c77996a00018302f4daea40924cf059d5a4323 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40864 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Simplify check for have_posix_clock. The "library" argument can actually be a list, in which case each element of the list is checked, one after the other. Use that rather than calling the CheckLibWithHeader method multiple times and manually oring the results. Change-Id: I5c774be15eaa9a7e52ec3ee5a1bbcc5ef1fa0f41 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40863 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Move a displaced have_posix_clock check back where it goes. This check had been separated from the code handling have_posix_clock by some intervening code doing something else. Bring the check back alongside the code setting that variable. Change-Id: I6acb54fddbb5c41d6c38d4b93e649835a4775fa0 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40862 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Use conf to determine if some flags are supported. Use conf rather than checking for particular combinations of OS and/or compiler versions. This *should* be just as correct, and not require keeping track of what versions of the tools particular flags were added. Change-Id: Icaa4c273fe89801e2808e6a814ce476700fd6956 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40861 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Pull Configure() to earlier in SConstruct so we can use it more. This mechanism lets us check if headers are available, flags are supported, etc. We should use that more often, rather than checking for specific versions of tools where problematic new warnings were added, etc. Change-Id: I5b1a6499147f27cc8944fcb8c61eb69e9fa8fb7a Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40860 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons: Extract the gem5 specific Configure call to its own file. This modularizes that fairly generic code and pulls it out of the main SConstruct file. Change-Id: I5f5edc866af43753b4e0a9cc63774ded0fffe06b Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40858 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons: Trim down a check for mac OS and arch setting flags. This check used uname to determine if scons was running on macos, and then a fairly elaborate check to see if the version was above 9, and if the hardware supported 64 bit. I think at this point it's safe to assume both that we're at least at macos 10 which is 19 years old, and that Mac hardware supports 64 bit. Change-Id: Ice66df2530bbcc929d3a37e7679634b75ba7b860 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40857 Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Remove "TIMEOUT" variable and checks. This was used when regression tests were run from scons. Since that hasn't been done for a while, these checks and this setting have no purpose and can be removed. Change-Id: Ibe383944f1427571061fd25ed6e97d9acfbbc7f1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40856 Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
scons: Update the Check(Cxx|Link)Flag checks to set their vars. This avoids boilerplate where we check to see if flag X is supported, and if so then set flag X. Since there are shared and static versions of the linker flags but we only explicitly check the static ones, this change also adds a parameter to CheckLinkFlag to set both flavors. This defaults to true since I assume most of the time linking flags will apply to both. Change-Id: I983222169e9835aeb98570362f7004e2ef0240d0 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40855 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons: Remove partial linking. This feature didn't actually provide any benefit in the end, and increased build directory size and scons complexity. Change-Id: Ia5aa16a8dd008599645076cea8131799f6086e0f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40795 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons: Add support for debug info compression. If supported this will compress the debug information in object files, libraries, and binaries. This decreases the size of the build/ARM directory from 11GB to 7.2GB. Because the benefit of this mechanism depends on the performance and capacity of the build machine's storage, it can be disabled with the --no-compress-debug scons flag. For instance if your storage is very fast, writing out a larger binary may take less time than compressing that same number of bytes, plus the time to write out the smaller file. This feature seems to make our presubmit test machine run out of memory when trying to build gem5, and so is disabled in the testing scripts. Change-Id: I71919062d23742b7658918b0fa9c4d91d0521fbf Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40715 Reviewed-by: Gabe Black <gabe.black@gmail.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons,python: Fix `--without-python` flag Even with the `--without-python` flag, checks were still done to ensure the correct version of Python was being used. This commit fixes this so these checks are not performed when `--without-python` is enabled. Change-Id: I2242f2971a49ef28cff229ad0337bce0a998413d Issue-on: https://gem5.atlassian.net/browse/GEM5-880 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39715 Reviewed-by: Gabe Black <gabe.black@gmail.com> Reviewed-by: Lukas Steiner <lsteiner@rhrk.uni-kl.de> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons: Remove Python 2.7 compatibility code Remove the dependency on six and most 'import x from __future__'. A few instances of imports from the future have been left in place to ensure that Python 2.7 users still get an error message when invoking scons. Change-Id: I366275a6040f0084e91198b5b5c2a648bffbf2d2 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39585 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com>
scons: Stop auto including the git tool from the default too override. SCons has a system of "tools", which basically detect versions of build tools (compilers, linkers, etc) and set up an environment with the appropriate build variable substitutions for that tool to be used. For instance, there would be a "tool" for gcc, and it would detect if gcc is present on the system, and if so would set the "CC" variable to "gcc". An actually tool as defined by SCons would be a lot more sophisticated than that and set more variables, but that's the basic idea. To help modularize the gem5 SConstruct file, I moved code which would set up git commit hooks into a "tool" which helped modularize it and reduce the size of SConstruct. This isn't quite right since, while the code does detect if git was used to check out the source (if there is a .git file at the root), it doesn't really modify the environment at all. It will also be invoked every time any environment is set up, although right now that will only be the DefaultEnvironment, what's used when loose functions like Builder or Command are called with, and the "main" environment which all the others are Clone-d from. Normally, when SCons sets up a new environment, either implicitly or when Environment() is called, it sets up a bunch of built in tools which are fixed within SCons itself. If you want, you can add a "tools" argument to Environment (or to the DefaultEnvironment() function) which will replace that list of tools. That can be used to make an environment use the new "git" tool, but it isn't automatic. SCons also lets you override default tools by creating your own with the same name as the default. To make loading the git tool automatic, I added an override "default" tool which, in addition to setting some defaults which should apply to all environments, also pulled in other tools, at that time "git" and "mercurial" (RIP). Unfortunately, that meant that today, apparently particularly with SCons version 4, *any* Environment would pull in "git", and all of "git"'s dependencies, even if SCons wasn't set up enough for those to work. To break that dependency, this change stops the default tool from automatically loading the git tool, although it does continue to set other defaults which have very minimal external dependencies. When creating the "main" Environment in the SConstruct, the "git" tool is now added in explicitly. Since the list of tools replaces the original and doesn't extend it, we have to add in "default" explicitly as well. Really, the "git" tool should be converted from the tool interface into something more appropriate, like perhaps a small module under site_scons which site_init.py can import and call. When that happens, main can be declared like normal again. While making this change, I also got rid of a few nonstandard additions to the main environment that were little used and not really necessary. When reading the SConstruct, it wasn't very obvious where those extra values were coming from, and they didn't really add any value. Change-Id: I574db42fc2196bf62fc13d6754357c753ceb9117 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38616 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Yu-hsin Wang <yuhsingw@google.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
scons: Don't check for Python 2 The build system will now refuse to build gem5 if Python 2.x is detected. Remove Python 2 specific python-config variants from the list of candidates we try. Change-Id: Id59be4a2969ce180848e5df02afdfb4a5b8125c1 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36535 Reviewed-by: Gabe Black <gabe.black@gmail.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>