Commit Graph

405 Commits

Author SHA1 Message Date
Gabe Black
c2c9ddaf74 scons: Monkey patch a fix from 3.0.2 into 3.0.0 and 3.0.1.
Ensure that SCons.Subst.Literal can be hashed.

https: //pairlist2.pair.net/pipermail/scons-dev/2018-October/004766.html
Change-Id: I5221b63a5fd63189eb690c77e780805dc6d68125
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/58633
Maintainer: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-06 07:38:06 +00:00
Gabe Black
4c6790ada6 scons: Stop the fast model project file parser from writing files.
PLY tries to write these little files into the SCons installation
directory, which it shouldn't even if it was allowed to. This avoids
a bunch of annoying messages about not having enough permission.

Change-Id: Ifd4eda9dd9f8518b3fd075e8a46de1b6c12c2127
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/58353
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jui-min Lee <fcrh@google.com>
2022-04-01 02:28:56 +00:00
Gabe Black
964500f363 scons: Put internal build files in a gem5.build directory.
This keeps them organized, and also creates an anchor for the build
directory other than a directory named "build".

Change-Id: I3ed2f569e9fcd62eb4eca1c4556b45cd0c3552d4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56589
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-28 20:31:21 +00:00
Gabe Black
e6c0ba97db scons: Put all config variables in an env['CONF'] sub-dict.
This makes what are configuration and what are internal SCons variables
explicit and separate, and makes it unnecessary to call out what
variables to export to C++.

These variables will also be plumbed into and out of kconfiglib in later
changes.

Change-Id: Iaf5e098d7404af06285c421dbdf8ef4171b3f001
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56892
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-28 20:31:21 +00:00
Gabe Black
8618dd8ae7 scons: Turn all global sticky variables into variant ones.
Saved option files are processed twice, once to load the value of the
EXTRAS variable, and then again once variables have been set up by
SConsopts.

Change-Id: Id8d49051c8fe684142a68259c470ed7c86bdab53
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56753
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-16 21:11:48 +00:00
Gabe Black
9d3cd97920 scons: Turn a lot of compiler flag vars into env vars.
These are used to adapt gem5 to the system it's being built on, and so
should be attached to the host via the environment rather than gem5's
configuration.

Change-Id: I2adfe1af484dcdeae32a48097d9aa87752a7ed2a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56752
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2022-03-14 21:06:46 +00:00
Gabe Black
a8602e3b63 scons: Process the SConsopts files for each variant.
The SConsopts files that need to be processed is affected by the EXTRAS
setting, and if all settings are going to be local to the variants, that
means each variant can have a different set of SConsopts files to use.

This does result in Configure type output showing up repeatedly when
building multiple variants, but that's uncommon for users, and will
hopefully become unnecessary for developers over time.

Change-Id: I7df287c37fc32e91576dced80d0a9e56806c4581
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56751
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2022-03-14 21:06:46 +00:00
Gabe Black
64d1297d86 scons: Move the build of ext/ into the variant dirs.
These are no longer split out and shared in the root build/ directory.
This does result in a small amount of overhead from building redundant
copies of these files, although the overhead is not significant. When
building 7 different variants of gem5, all the ISAs and NULL, the
difference on my machine was:

Before:
real    41m25.372s
user    914m22.266s
sys     41m51.816s

After:
real    42m38.074s
user    921m36.852s
sys     43m2.949s

This is about a 2-3% difference, which is a worse than typical case,
since the overhead scales with the number of variants being built.

The benefit of pulling ext/ into the variant directory is that there can
now be a single config which applies to all files used to build gem5,
and that config is represented by the variant of gem5 being built.

Change-Id: I6f0db97c63a7f3e252e7e351aa862340978e701b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56750
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gabe Black <gabe.black@gmail.com>
2022-03-11 22:54:16 +00:00
Gabe Black
e7f1acc0dc scons: Add a "mold" value to the --linker option.
This new and improved linker approximately halves link time for
build/X86/gem5.opt for me compared to lld, the previously fastest
linker. The -fuse-ld=mold option is supported by current versions of
clang, and will be supported in gcc 12.

To use the mold linker with gcc prior to version 12, you need to set
the LINKFLAGS_EXTRA scons variable to pass in a -B option as described
on this page:

https://github.com/rui314/mold

Change-Id: Ic5ad0e532fac078d384a0aebb3e04a4b04ce4880
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/57173
Maintainer: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Earl Ou <shunhsingou@google.com>
2022-03-01 02:02:27 +00:00
Gabe Black
8767fca212 scons: Remove a blanket USE_KVM disable check from SConstruct.
Whether to honor the USE_KVM setting can be handled in a more targeted
way down at individual consumers. They will know what ISA the host needs
to be for their particular model to make sense, where the SConstruct has
to enable or disable it for the entire build of gem5.

Change-Id: I9e82e232203834f6fe56d0ce5cf696809a0970bc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56188
Maintainer: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-09 02:36:49 +00:00
Gabe Black
e7f2d17338 scons: Make CC, CXX and PROTOC no longer sticky.
These variables will always be imported from the environment, and never
from previous builds. For SCons to actually use these values, they need
to not only be in the environment variables external commands SCons runs
sees, they also have to be promoted to actual SCons construction
variables.

Change-Id: I54035442d70972396f1788bd0773877222d7a7c5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56386
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-04 18:18:58 +00:00
Bobby R. Bruce
5e6a561a3f misc: Revert v21.2 specific commits for develop
These changes were made to the release staging branch for the v21.2
release. This commit reverts them for the develop branch.

Change-Id: I9f02470d00d5034a0797f32d4c1fe0e7055860a6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54904
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-12-28 21:30:21 +00:00
Gabe Black
dda149ecf8 scons: Add a --linker option.
There is currently a "--gold-linker" option, which tells SCons to use
the gold linker. This puts the gold linker in a special position where
it has its own command line option, and makes it impossible to
explicitly select any other linker.

This change adds a --linker option which can be set to "bfd" (the
default gnu linker), "gold" (the gnu gold linker), or "lld" which is the
clang linker. If none is specified, SCons will let the compiler fall
back to whatever its default is.

The --gold-linker option is modified so that it just sets the --linker
option for you. Because of how SCons handles adding command line
options, there isn't a good way to complain if both it and --linker is
used, nor is there a good way to warn that the user is using a
deprecated command line option. A warning is in the help text for that
option now, though.

If the gold linker is selected, this change also sets the --threads
option, and sets the --thread-count option. This tells the gold linker
to run multi-threaded to speed up linking. Apparently the gold linker
must have been built with an option that enables threading for these
options to have any effect. If threads and LTO are both enabled, the
gold linker segfaults. To avoid that problem, we don't add --threads if
LTO has been enabled.

This change also enables a new configuration, where lld, the clang
linker, can be used with gcc. Unfortunately the format of LTO
information gcc/g++ generates is not compatible with lld, and so if you
set the linker to lld and enable LTO, you'll probably get errors like
not being able to find the symbol "main".

This change also allows you to select the default gnu linker ("bfd")
when using clang, although it's not clear why you would want to do that.

Change-Id: Ib37030431527f5d0bc626e9594b2e1142df889be
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49003
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
2021-12-28 05:28:32 +00:00
Bobby R. Bruce
594145849c scons: Remove -Werror for the gem5 v21.2 release
While gem5 compiles on our supported compilers, removing the -Werror
flag on the stable branch ensures that, as new compilers are released
with stricter warnings, gem5 remains compilable.

Change-Id: I05989356997bc7f6606c43944d15da6c3958a3f5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54463
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-12-21 22:29:07 +00:00
Gabe Black
6106301957 scons: Ensure the gem5py_env always has embedded python.
Even if the gem5 binary itself won't.

Change-Id: I825e2cbed35a3dcc4fb4bec6f2fd71e78164e7c0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49422
Maintainer: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-12-08 08:01:23 +00:00
Gabe Black
5290ae8dbd scons: Make the perf and prof builds into options.
That makes it possible to add profiling options to debug or opt builds,
and not just the fast build which the perf/prof builds were implicitly
modeled after.

Change-Id: Id8502825146b01b4869e18d1239e32ebe3303d87
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51988
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-11-12 21:43:40 +00:00
Gabe Black
e1de4abdb0 scons: Fix linker flags for prof/perf builds.
SCons does not use a variable called LDFLAGS, it uses one called
LINKFLAGS. Switch some errant uses to the correct name.

Also, adjust all the other variable names to use LINK, for consistency
and to avoid confusion and avoid mistakes in the future.

Change-Id: I38d40f5231afdf62bcfba04478d403d65e9b1e26
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51987
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-10-26 03:32:10 +00:00
Gabe Black
cc75a47b84 python,scons: Move grammar.py and code_formatter.py into build_tools.
These are only used in a build, and so don't need to be built into gem5.
grammar.py is used by slicc and the fast model project file parser, and
code_formatter.py is only used by SConscripts.

Change-Id: Id43e62459d69f07fdb2ed125548a83e38bbb7590
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49396
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
2021-09-24 21:23:27 +00:00
Gabe Black
dfec508976 scons,python: Split the marshal binary into a c++ wrapper and script.
The new c++ wrapper is called gem5py, and will run any python script
using gem5's embedded python interpreter. The "marshal" functionality is
split out into a separate python script gem5py can run.

The command line for gem5py should look like this:

gem5py ${SCRIPT TO RUN} ${ARGS TO THE SCRIPT}

So, for instance, to marshal a file called foo.py, the command line
might look like this:

gem5py python/marshal.py foo.py

Also, this change reorders the sources for the python embedding action
and limits the max_sources for Transform() to 1, so that it just shows
the python file being embedded and not gem5py or the marshal.py script.
Those are still sources so dependency tracking works correctly, but they
are also implied and just add visual noise to the build output.

Change-Id: I7ae6bd114973ae44c3b634884b6dafc6577e0788
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49392
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
2021-09-24 18:49:53 +00:00
Eric Ye
e61f62b478 scons: Allow clean non-interactive builds
On a clean build, the git tool will wait for input() before installing
git hooks. Allow bypassing this via a command-line flag, making it
possible to perform a clean build non-interactively.

Bug: 199780674
Test: build_gem5 --install-hooks
Change-Id: I48be2c1a7c2335a2f4f6359adf582ca8b0ae5939
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50410
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-09-17 17:23:02 +00:00
Gabe Black
8e28a06f11 scons: Pull the "Blob" builder out of src/SConscript.
Change-Id: Ib52c7b51d52aeccdcd2ca05cb0a71267268d969d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48378
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-09-15 04:18:26 +00:00
Gabe Black
b61f539f05 scons: Move the source related helper classes out of src/SConscript.
By having them in gem5_scons.sources, they can be used by mechanisms
outside of src/SConscript, like separated out builders.

Change-Id: Ic3769723c8413e7db48aef536572ad3f2f948658
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48376
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
2021-09-14 23:26:49 +00:00
Gabe Black
f4d8200178 scons: Pull some python related mechanisms out of USE_PYTHON guards.
We don't want to build certain files if USE_PYTHON is disabled, but we
can still tell scons how to.

Change-Id: I38c7c93f609cfcedc350f8270f0b239b69c4f101
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48367
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-09-10 04:19:24 +00:00
Gabe Black
9fa9840691 scons: Turn the Blob method into a builder.
Build the blob .cc and .hh files in the same directory as the file
they're based off of. Move the GDB XML files into the arch directories
they go with.

Change-Id: I12fe48873312c3aba5910989d6e3049ebd5e5bbf
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48136
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-08-28 04:19:40 +00:00
Gabe Black
5199f6b00d scons: Disable the duplicate-environment warning by default.
Disable warnings when targets can be built with multiple environments
but with the same actions. This can happen intentionally if, for
instance, a generated source file is used to build object files in
different ways in different environments, but generating the source
file itself is exactly the same. This can be re-enabled from the
command line if desired.

Change-Id: I426ca3331267f026553c9a2bccc79494cace8109
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48133
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-08-14 14:54:16 +00:00
Gabe Black
db1ec14120 scons: Disable the free-nonheap-object warning for gcc.
g++ 11.1 has a false positive in the systemc kernel for
free-nonheap-object which breaks the build. The check sees that an
EventWrapper is part of the systemc scheduler object, and doesn't
realize that it was *not* set to autodelete, and so would *not* delete
itself (as part of the scheduler) when it is descheduled.

Change-Id: Ia9f48f2113e8c165923e55d7db1442b11bb6a2e8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48646
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-08-04 05:23:34 +00:00
Bobby R. Bruce
64390cd2a1 scons: Re-add -Werror for the gem5 develop branch
This reverts commit 3c61200c2b,
https://gem5-review.googlesource.com/c/public/gem5/+/48584

Change-Id: Idc071168857746f4c8d3e577949939ecf1761cda
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48812
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-30 04:44:09 +00:00
Bobby R. Bruce
76ceda55f7 misc: Merge branch 'release-staging-v21-1' into develop
Change-Id: I0f69d3d0863f77c02ac8089fb4dccee3aa70a4ea
2021-07-28 17:37:04 -07:00
Gabe Black
0d998a3c53 scons: Add the "print_suppressions=0" option to the LSAN warning.
This is part of what SCons uses internally, and is probably what someone
using LSAN_OPTIONS would want to use externally too.

Change-Id: I413c680829e0edab76598122637e3236c35e8209
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48645
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gabe Black <gabe.black@gmail.com>
2021-07-28 02:41:07 +00:00
Gabe Black
496835cd20 scons: Get rid of some redundant text in a print out.
When printing the LSAN_OPTIONS setting to use, we were manually
prefixing "suppressions=" to it, but it already had that built into the
option. This made that text print twice. Remove the duplicate.

Change-Id: Ie599e02d0cf17bcf18278d72350831a2e0ac09f6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48644
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-28 02:40:36 +00:00
Gabe Black
a4b3db0b9e scons: Increase the minimum version of gcc to 7.
This was bumped up to 7 by policy, but the SConsctruct was still
enforcing the old minimum of version 5.

Change-Id: I91966f95b18451f880af279dae286119f7b282d6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48512
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-28 00:07:15 +00:00
Bobby R. Bruce
3c61200c2b scons: Remove -Werror for the gem5 21.1 release
While gem5 compiles on all our supported compilers, removing the -Werror
flag on the stable branch ensures that, as new compilers are released
with stricters warnings, gem5 remains compilable.

Change-Id: If306785e3f0822e1c435e1f10bf507a9e7a87eb6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48584
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-27 18:20:12 +00:00
Gabe Black
ff3ffc7461 scons: Switch to c++17.
Change-Id: I90d121ab4dbf53f3bd30bcdb5f5101d9c7cdc437
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45902
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-07 05:43:39 +00:00
Gabe Black
5e2f1a08b7 scons: Increase the minimum version of clang to 6.
Change-Id: I41f7e96922c273827c72df06145f0fe433936b59
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45621
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-05-24 23:13:48 +00:00
Gabe Black
2e27ed2351 python,scons: Move readCommand and compareVersions into site_scons.
These functions are only used by scons, so it makes sense to move them
to site_scons/gem5_scons/util.py.

Change-Id: If2b3995f208cb71adf3c59aac4eabe378c47f94f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41599
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-05-10 23:33:22 +00:00
Gabe Black
24175fb9bd scons: Update comments in SConstruct.
Make them consistently styled, gramatically and factually correct, and
try to make sure they're reasonably clear.

Change-Id: I3566734b0ac386113ef45ac7fd24c9fb1f2007d3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40972
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-05-10 23:33:04 +00:00
Gabe Black
8bfcaa8abc scons: Simplify finding the python lib with ParseConfig.
A comment in that section of SConstruct talked about how ParseConfig
couldn't understand -Xlinker and -export-dynamic, and how that meant
they needed to parse the output of python-config manually. Some
searching around turned up this:

https://bugs.python.org/issue36508

which seems to suggest that exactly those two options weren't actually
supposed to be returned by python-config in the first place, and are
really for python's own internal build.

This change switches over to using ParseConfig, but to avoid bad options
sneaking through, it uses an option argument to ParseConfig to intervene
before the options are consumed and filter out everything except
required libraries, and library and header search directories.

Change-Id: I1a50eb030019a447b919381c32168fb3bb27b89b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40971
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-05-10 23:32:53 +00:00
Gabe Black
3c2fa06bff scons: Pull builder definitions out of SConstruct.
Put them in site_scons/gem5_scons/builders.py. This decreases the bulk
of SConstruct and keeps related functionality together.

Change-Id: I9e1f2d606c3801131badad15f8f4419186bb7e1d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40969
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-05-10 23:32:45 +00:00
Bobby R. Bruce
1cd7e3471d scons: Add --with-lto to enabled LTO; remove --no-lto
LTO is no longer enabled by default and can instead be enabled by
`--with-lto`.

Change-Id: I2eea7d447703491675c02730707cf9026cface5f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44887
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-30 21:13:57 +00:00
Bobby R. Bruce
679c698c56 scons: Revert "Enable LTO for opt, perf and prof builds."
This reverts
https://gem5-review.googlesource.com/c/public/gem5/+/40815

Change-Id: I7dbd2b555570c90c98f38c7c02eb052571f7b6bd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44886
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-30 21:13:57 +00:00
Gabe Black
e035575ea0 scons: Move MakeAction into gem5_scons.
That will make it usable from builders defined outside of SConstruct.

Change-Id: Id1231a1a370b7d519a382db892ded93c604eb56f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40968
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
2021-04-18 02:32:45 +00:00
Gabe Black
6ca6f41052 scons: Move the "duplicate" setting into gem5_env_defaults.py.
This is a generic default environment setting, and so should go
alongside all the other generic default environment settings.

Change-Id: If3032a4893dd84f7c7d77e7e9420436ab445cf2b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40967
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2021-04-18 02:32:45 +00:00
Gabe Black
789b6eb615 scons: Stop piggy-backing on the default tool for default settings.
Instead, create a new tool called EnvDefaults. This tool now needs
to be explicitly listed in the set of tools available through an
Environment, but that's easy to do in on place (all environments should
stem from main). Hijacking default like we were doing was (as far as I
can tell) not how that tool was intended to be used, and doing things
this way is a bit less hacky.

Also, we can split more Builders, etc, out of SConstruct, and these will
need to attach to main in the same way. We're going to need a list of
tools when main is constructed one way or the other, so we might as well
follow the rules.

Change-Id: I392e1639cb69d373c64970dccf45258000498cc3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40965
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-04-17 22:41:07 +00:00
Gabe Black
960b9246c5 scons: Convert gem5_scons.Configure to a context manager.
This has two purposes. First, SCons assumes that once you call
Configure, you won't set up the environment the Configure is based on
until after you get the environment back from it again with
conf.Finish(). We get away with this when the cache mode for config
tests is not "force", since Configure just reuses the environment we
pass in, and any changes we make are immediately communicated between
the two.

If the cache mode *is* "force" though, SCons modifies the decider so
that everything the conf environment goes to build looks like it's out
of date. It does that by cloning the original environment, and then
using that clone to do its tests. That causes a problem because we have
a long lived "conf" object and make further changes to main, and since
the two environments are now separate the one in conf doesn't see those
updates.

Second, and more subtly, we export our "main" and "env" environments so
that other SConsopts and SConscript files can use them and define things
in them. The way Configure is designed, if the config caching mode is
"force", then it will create a new environment, and then that
environment will replace what the, for instance, "main" variable points
to when "main = conf.Finish()" is executed.

Unfortunately, if we've already Export()-ed main, we've exported what
the "main" variable pointed to at that time. Our view of "main" will
track with the value that conf.Finish() returned, but since that
construction environment is mearly derived from the main we Exported and
not actually the same thing, they have diverged at that point and will
behave independently.

To solve both of these problems, this change modifies the
gem5_scons.Configure() method so that it's a context manager instead of
a regular function. As before, it will call Configure for us and create
a configuration context, which it will yield as the "with" value. When
the context exits, all the variables in the context Finish() returns
will be shoved back into the original context with Replace(). This isn't
perfect since variables which were deleted in the environment (probably
very rare in practice) will not exist and so will not overwrite the
still existent variable in the original dict.

This has several advantages. The environment never splits into two
copies which continue on independently. It makes the lifetime of a
configuration context short, which is good because behavior during that
time is tricky and unintuitive. It also makes the scope of the context
very clear, so that you won't miss the fact that you're in a special
setting and need to pay attention to what environment you're modifying.

Also, this keeps the conceptual overhead of configuration localized to
where the configuration is happening. In parts of the SConscripts which
are not doing anything with conf, etc, they don't have to modify their
behavior since no configuration context is active.

This change is based on this change from Hanhwi Jang who identified this
problem and proposed an initial solution:

https://gem5-review.googlesource.com/c/public/gem5/+/44265

Change-Id: Iae0a292d6b375c5da98619f31392ca1de6216fcd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44389
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Hanhwi Jang <jang.hanhwi@gmail.com>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-13 01:04:54 +00:00
Gabe Black
ea631194d9 scons: Eliminate the useless USE_SSE2 flag.
This option would set the -msse2 compiler flag to avoid using x87
floating point, but every 64 bit x86 CPU supports sse2, and so sse2 is
enabled by default on compilers targeting it. 32 bit x86 CPUs are
obscure enough that it's not worth preserving this marginally meaningful
option which would only matter for them.

Change-Id: Ib425c261b27f1f74300e714619787d04970065ce
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40879
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-03 14:03:10 +00:00
Gabe Black
0d569c559b scons: Streamline the LTO option setting code and add options for clang.
Clang also supports an -flto option, although not with a thread count.

Change-Id: Ifc783ac3ab2e0ea93fad0402b288605a20725aa0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40962
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-03 05:53:31 +00:00
Gabe Black
59e0ce27a3 scons: Include libthr on freebsd no matter what compiler you're using.
The compiler won't change where the thread library is implemented.

Change-Id: Ic6fbaae2ff9c4a91ce86b06d62049b9d9a0e3132
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40960
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Reviewed-by: B.A. Zeeb <baz21@cam.ac.uk>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-03 05:53:17 +00:00
Gabe Black
dd0d54d749 scons: Narrow the scope of the -Wno-parentheses flag.
This was added to avoid warnings from code generated as part of Ruby's
AST. Instead of applying this to all of gem5, apply it only to files
generated by Ruby.

Change-Id: I2b11d2df3cb631debdc594059d9d480a0e695c59
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40958
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-03 05:53:01 +00:00
Gabe Black
c017caad88 scons: More narrowly target -Wno-self-assign.
This flag was necessary because of self assignments in the ISA parser
where self assignments are often hints to the parser itself, and in one
case because a pybind-ism used to attach the -= operator looked like a
self assignment.

This change narrows the scope of the flag that disables this warning to
only files generated by the ISA parser, and the single file in the
systemc code which uses that operator overload.

Change-Id: Ib64fc72e46f894cba9064afcdbdcc5859c30e745
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40952
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-03 05:52:24 +00:00
Gabe Black
64d71220d1 scons: Delete unnecessary imports from SConstruct.
Also get rid of the joinpath and splitpath aliases for os.path.join and
os.path.split. The aliases are only slightly shorter, and obscure these
extremely common python methods.

Change-Id: I0784e2d8dbaacb0690a59e9fa8c8258c1df0e6c3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40874
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-03 05:51:35 +00:00