Commit Graph

87 Commits

Author SHA1 Message Date
Bobby R. Bruce
e85592da14 scons: Fix scons 'readCommand' non-zero exits (#1587)
There appears to have been an assumption here that `Popen` would raise
an exception if the command run returned non-zero. This is not the case.
This commit fixes this by obtaining the return code and throwing an
exception if it is non-zero.

This bug caused some minor issues as Exception handling code to handle
the non-zero case elsewhere in Scons was never executed.
2024-09-23 10:09:23 -07:00
Alexander Richardson
e7d7199ea4 scons: Add option to use libc++ (#680)
this adds an option --with-libcxx, that adds the -stdlib=libc++ flag to
link against libc++ instead of libstdc++ on Linux. Currently this is
only possible with clang and may not work with all build configurations
(e.g. protobuf linked against libstdc++), so this needs to be opt-in
rather than being on by default for clang whenever libc++ is detected.

Change-Id: Ib4022a58bb2dbd32417c58f01c7443a02ff710fe
2023-12-28 12:49:44 -08:00
Hoa Nguyen
39fd61d7dd misc: Fix precommit install (#634)
Previously, the `subprocess` module was used to execute shell command
installing precommit hook. However, after #431 [1], the import of the
`subprocess` module was overriden by `asyncio.subprocess`, which has a
different API to execute the shell command. This change removes the
`asyncio.subprocess` import.

[1] https://github.com/gem5/gem5/pull/431

Change-Id: I9a7d51f85518089d258ab57c5d849a36dcf128e9

Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-12-01 14:03:59 -08:00
Bobby R. Bruce
d11c40dcac misc: Run pre-commit run --all-files
This ensures `isort` is applied to all files in the repo.

Change-Id: Ib7ced1c924ef1639542bf0d1a01c5737f6ba43e9
2023-11-29 22:06:41 -08:00
Gabe Black
63919f6a68 scons: Hook up oldconfig and olddefconfig.
These two utilities help update an old config to add settings for new
config options. The difference between them is that oldconfig asks what
new settings you want to use, while olddefconfig automatically picks the
defaults.

Change-Id: Icd3e57f834684e620705beb884faa5b6e2cc7baa
2023-11-23 08:26:11 +08:00
Gabe Black
ec76214f68 scons: Hook up the savedefconfig kconfig helper.
This helper utility lets you save the defconfig which would give rise to
a given config. For instance, you could use menuconfig to set up a
config how you want it with the options you cared about configured, and
then use savedefconfig to save a defconfig of that somewhere to the
side, in the gem5 defconfig directory, etc. Then later, you could use
that defconfig to set up a new build directory with that same config,
even if the kconfig options have changed a little bit since then.

A saved defconfig like that can also be a good way to visually see what
options have been set to something interesting, and an easier way to
pass a config to someone else to use, to put in bug reports, etc.

Change-Id: Ifd344278638c59b48c261b36058832034c009c78
2023-11-23 08:26:11 +08:00
Gabe Black
51b8cfcede scons: Hook up the kconfig guiconfig program.
Change-Id: I0563a2fb2d79cea5974aeaf65a400be5ee51dc63
2023-11-23 08:26:11 +08:00
Gabe Black
91b3da016b scons: Hook in the listnewconfig kconfig helper.
This helper lists config options which are new in the Kconfig and which
are not currently set in the config file.

Change-Id: I0c426d85c0cf0d2bdbac599845669165285a82a0
2023-11-23 08:26:11 +08:00
Gabe Black
083bca1e23 scons: Hook in the kconfig setconfig utility.
This little utility lets you set particular values in an existing config
without having to open up the whole menuconfig interface.

Also reorganize things in kconfig.py a little to help share code between
wrappers.

Change-Id: I7cba0c0ef8d318d6c39e49c779ebb2bbdc3d94c8
2023-11-23 08:26:11 +08:00
Gabe Black
1e84d9f941 scons: Add a mechanism to run menuconfig to set up a build dir.
If you call scons with the fist argument set to menuconfig, that means
to run menuconfig on the path following it. Or in other words, if
you ran this command:

scons menuconfig build/foo/bar

That would tell SCons to set up a build directory at the path
build/foo/bar, and then invoke menuconfig so you can set up its
configuration.

In addition to using this mechanism to set up a new build directory, you
can also use it to reconfigure an existing directory.

This supplements and does not replace the existing mechanism of using
"build/${VARIANT}" to select a config with defconfig.

Change-Id: Ief8e8c2ee6477799455c2004bef06c64be5cc1db
2023-11-23 08:26:11 +08:00
Gabe Black
db3a6e8e84 scons: Use Kconfig to configure gem5.
These are not yet consumed by anything, but convert all the settings
from SCons variables to Kconfig variables.

If you have existing SConsopts files which need to be converted, you
should take a look at KCONFIG.md to learn about how kconfig is used in
gem5. You should decide if any variables need to be available to C++ or
kconfig itself, and whether those are options which should be detected
automatically, or should be up to the user. Options which should be
measured automatically should still be in SConsopts files, while user
facing options should be added to new or existing Kconfig files.

Generally, make sure you're storing c++/kconfig visible options in
env['CONF'][...]. Also remove references to sticky_vars since persistent
options should now be handled with kconfig, and export_vars since
everything in env['CONF'] is now exported automatically.

Switch SCons/gem5 to use Kconfig for configuration, except EXTRAS which
is still a sticky SCons variable. This is necessary because EXTRAS also
controls what config options exist. If it came from Kconfig itself, then
there would be a circular dependency. This dependency could
theoretically be handled by reparsing the Kconfig when EXTRAS
directories were added or removed, but that would be complicated, and
isn't supported by kconfiglib. It wouldn't be worth the significant
effort it would take to add it, just to use Kconfig more purely.

Change-Id: I29ab1940b2d7b0e6635a490452d05befe5b4a2c9
2023-11-23 08:26:10 +08:00
Gabe Black
5f73a9bbf0 scons: Use either the "build" or "gem5.build" as build anchor.
If gem5.build already exists within a directory, then that build
directory can be used without having to worry about variants.

If it doesn't exist and we find a build/${VARIANT} style path, then we
use that as the anchor.

In either case, the variant name is the final component of the build
path. The parse_build_path function had been separating that out, but it
was just put back onto the path again anyway by the only caller, and
then split out again when that path was consumed. We save a step by not
splitting it out in parse_build_path.

Change-Id: I8705b3dbb7664748f5525869cb188df70319d403
2023-11-23 08:26:10 +08:00
Bobby R. Bruce
298119e402 misc,python: Run pre-commit run --all-files
Applies the `pyupgrade` hook to all files in the repo.

Change-Id: I9879c634a65c5fcaa9567c63bc5977ff97d5d3bf
2023-10-10 21:47:07 -07:00
Yu-hsin Wang
42c52b1add scons: Update default environment comments
Change-Id: Ib6dcf1a6390010682365f393241c1e022aeeb813
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/72058
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2023-07-07 07:11:03 +00:00
Yu-hsin Wang
7cc4f820d7 scons: Pass the CPATH environment variable through to SCons.
For sandbox environment, the default include may be override by CPATH.
To make the SCons can work in this environment, we need to pass CPATH
into SCons.

Change-Id: I1015f20a553a2e18595c8d2a89b209ca665879fd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/72038
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
2023-07-06 02:27:07 +00:00
Gabe Black
1aa8d6c004 scons: Pass the DISPLAY environment variable through to SCons.
This lets gui programs run correctly within SCons, specifically the
kconfig "guiconfig" helper utility.

Change-Id: Iec51df3db89ac7e7411e6c08fe8201afb69dc63e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56952
Reviewed-by: Matthew Poremba <matthew.poremba@amd.com>
Maintainer: Matthew Poremba <matthew.poremba@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2023-06-30 01:50:23 +00:00
Luming Wang
332ef131dc scons: fix build failed caused by Non-ASCII directory path
This patch addresses the issue of gem5 failing to build when
the build directory path contains non-ASCII characters.
The previous patches[1] that attempted to fix this issue
became ineffective after the upgrade of Python and pybind11
to new versions. This new patch manually sets the locale in
marshal.py based on the `LC_CTYPE` environment variable,
providing a comprehensive solution that works with Non-ASCII
build directory paths.

[1] https://gem5-review.googlesource.com/c/public/gem5/+/58369

Change-Id: I3ad28b6ee52fd347d2fe71f279baab629e88d12c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70818
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
2023-05-23 07:24:59 +00:00
Richard Cooper
aff1bfe491 scons: Fix gem5 Python3.11 build.
The code generation in gem5's build system requires the use of Regular
Expression flags when defining the regular expressions used for
tokenization. However, the Python Lex-Yacc (PLY) [1] library used by
gem5 does not allow the user sufficient control of the flags for RE
compilation.

Previously, gem5 used inline RE flags to control RE compilation.
However, from Python 3.11, inline RE flags must be at the start of the
RE string. Because PLY wraps the user supplied RE strings before
compilation, there is no way for the user to supply a RE string with
the inline flag at the start. This makes gem5 incompatible with Python
3.11 when using PLY.

This change modifies gem5's build files to patch `re.compile` with a
wrapped version that can handle embedded flags anywhere in the RE
string, for all current versions of Python. The patched version
re-formats the user supplied RE string to convert inline RE flags to
explicit RE flags.

This patch is intended as a temporary stop-gap until PLY can be fixed
upstream.

See the gem5 Issue Tracker [2] for more details.

[1] https://github.com/dabeaz/ply
[2] https://gem5.atlassian.net/browse/GEM5-1321

Change-Id: I3ab371f2e5cf267c0a89caaf8a2bacfed78545ef
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70237
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Boris Shingarov <shingarov@labware.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2023-05-05 07:36:36 +00:00
Alex Richardson
5e096f5b5d scons: allow building without duplicating source files
This adds a new scons flag --no-duplicate-sources to build without
linking source files to the build directory.

I find this very helpful when using CLion, since I can now generate a
compilation database using
`bear scons build/ALL/gem5.debug --no-duplicate-sources` and CLion will
now correctly semantically analyze all the files inside src/.
It also ensures that clicking on a build warning/error now opens the
real source file rather than a symlink.

This is not enabled by default since it's possible that certain use
cases are not working correctly, but the basic testing I've done so
far appears to work just fine.

It appears that with this change the `<root>/src` directory is no longer
added to `PYTHONPATH` when running `tests/main.py`, so this change
depends on https://gem5-review.git.corp.google.com/c/public/gem5/+/68757

Change-Id: Iddc9bf9c8211e68e5432c0a07f5c95f427c1ca16
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/68518
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
2023-04-05 22:00:07 +00:00
Giacomo Travaglini
e73655d038 misc: Use python f-strings for string formatting
This patch has been generated by applying flynt to the
gem5 repo (ext has been excluded)

JIRA: https://gem5.atlassian.net/browse/GEM5-831

Change-Id: I0935db6223d5426b99515959bde78e374cbadb04
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/68957
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
2023-03-16 09:05:29 +00:00
handsomeliu
a13549ebef scons: Capture TMPDIR envvar
During gem5 build, the compiler may produce some large intermediate
files. The default path is /tmp, but in some usecase, it's under a small
file system, and we may want to change the storage path to a sufficient
large file system. This CL captures TMPDIR environment variables, to
allow users change the default temporary directory.

Change-Id: Ib3fad301f36df9f3f08eb9b6cfeb4df1b7df5d1a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64873
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-10-27 09:17:41 +00:00
Jason Lowe-Power
9a1074d27f scons: Fix variable not found error
Change-Id: I09708fea777a57a35e55409c8997ed0b25de2b46
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64012
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Melissa Jost <melissakjost@gmail.com>
2022-10-01 01:17:13 +00:00
Bobby R. Bruce
700f64c1c1 scons: Ensure style_hooks check exits if hook cannot install
If the pre-commit could not be installed the compilation would continue
as the exit code from running the pre-commit install script was not
read or processed. This commit adds a check. If the install is
unsuccessful the users is asked whether they want to continue the
compilation or not.

This check can be ignored with the '--ignore-style'. The tests have been
updated to include this flag in all cases we compile gem5 to ensure
tests remain automated and uninterrupted on Kokoro/Jenkins.

Change-Id: Iaf4db71300883b828b00d77784c9bb46b2698f89
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63012
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
2022-09-08 18:31:08 +00:00
Bobby R. Bruce
5a88dcfdef scons: Update automatic hook install for pre-commit
This replaces the old hooks with the pre-commit check. If Python
pre-commit has not been installed an error is thrown asking the user to
install the requirements via pip.

Change-Id: I2d42f42624e10d38d0da39b473f0363db128ce1c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62553
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2022-08-24 21:47:07 +00:00
Bobby R. Bruce
2bc5a8b71a misc: Run pre-commit run on all files in repo
The following command was run:

```
pre-commit run --all-files
```

This ensures all the files in the repository are formatted to pass our
checks.

Change-Id: Ia2fe3529a50ad925d1076a612d60a4280adc40de
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62572
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
2022-08-24 21:47:07 +00:00
Gabe Black
dfc8614ee2 scons: Ensure config file values are strings.
Apparently, sometimes a SCons Value node created with an integer value
0 will have a string representation which is the empty string, which
is obviously problematic. To work around this bug, convert the value
to a string explicitly before creating the Value node, so that we get
a sensible translation instead.

Change-Id: I4a09b2fb366aaf2d4d1c7e6f8cc84224b2d010c4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59472
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Yu-hsin Wang <yuhsingw@google.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
2022-05-09 02:55:52 +00:00
Luming Wang
8756f57aa1 scons: fix build failed caused by Non-ASCII directory path
This path fix build failed when gem5's path contains Non-ASCII
characters.

build_tools/marshal.py embed "abspath" and "modpath" into the
generated c++ file. However, if either of them contains Non-ASCII
characters, marshal.py will throw an exception.

This can be fixed if we set a suitable $LANG for gem5py. For
example, we can simply set $LANG=en_US.UTF-8 in src/SConscript
to fix this.

This patch fixes this bug by passing the host's $LANG environment
variable to gem5py. Because for users who may use Non-ASCII
characters, their $LANG is generally set to their native language
(e.g. zh_CN.UTF-8, en_US.UTF-8, etc.), which contains Non-ASCII
characters. Also, it is more reasonable to use the host $LANG than
to directly hard-code the $LANG used by gem5py into a language
that supports non-ASCII characters.

Change-Id: Ia0343cbd6995af3a9e43bf217ad3f186d5633fed
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/58369
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-05 08:46:51 +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
b9f4b9e130 scons: Add a SourceLib method for adding libs to gem5.
Sometimes a library is needed to support particular functionality in
gem5, and that functionality is only used (or even desirable) in
certain binaries SCons can build. We can currently filter sources to
include in a particular executable using tags, but libraries have been
added to the environment globally using the LIBS variable which applies
to all Executables.

This change adds a SourceLib() mechanism which is a new category of
source which represents libraries. This is independent from classes
which inherit from SourceFile which represent actual files, as opposed
to more abstract libraries.

When gem5 builds an executable, the filters it provides are used to
select both Source()-es, aka c/c++ files, and libraries. If something
like a unit test does not need all the libraries gem5 proper does,
then those won't be picked up by its filter, and it won't include them.

Change-Id: I003e029eb82f7800a7ecff698c260e2d18ea2900
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/58069
Reviewed-by: Yu-hsin Wang <yuhsingw@google.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-22 07:08:59 +00:00
Giacomo Travaglini
d1ba94ac41 util: Remove python3-six package from dockerfiles
python six package is not used in gem5 as we don't support
python2 anymore

Change-Id: I25a682842ad00c0b5e09c9cb4ea6efac5114da6d
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/57969
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 09:38:14 +00:00
Gabe Black
443067253c ext,scons: Make kconfiglib available for use in SCons.
Change-Id: Ie9c902819ed0750a04f8318911fa914701c2a0fe
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56755
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
2022-03-15 00:30:39 +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
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
db921c890e scons: Fix 'CheckLinkFlag' so '-Werror' is not enabled
A small error in 'CheckLinkFlag' was resulting in `-Werror` being set
as a CXXFLAG after the function was run. This patch fixes this.

Change-Id: I786f81a4f94be0356573eb6d4673d04ee5aa844d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54863
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-12-27 05:58:04 +00:00
Gabe Black
2bc3f873a9 scons: Add werror explicitly when checking for compatible options.
When checking whether a given option is supported, we try to compile or
link a small test program and see if that succeeded or not. There are
some options which are not really supported, but if you use them the
compiler might produce an error instead of failing to build. An example
of that is clang (version 9 at least) which will warn if you try to
disabled a warning it doesn't know about.

On the develop branch, this is fine since we have werror enabled, and
even these warnings will prevent the options from being enabled. On the
release branches where we disable werror for better future
compatibility, this causes a problem because these options still pass
the test and end up being enabled. This doesn't break the build, but
can cause a bunch of annoying and unnecessary warnings which clutter
up the build output.

To remove this inconsistency, we can enable werror just for the test
compiles or links which decide whether or not an option is supported.
That won't necessarily differentiate *why* a warning was generated, so
if through some strange combination of circumstances something else
causes a warning pervasively through the build, then this may think
an option is to blame and not enable it even though it's fine. This
seems unlikely though, and not worth worrying about without a specific
example showing that it can/will actually happen.

Change-Id: I6a1e3273c0b646a5636dc9986c70dcd5332f6f64
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54624
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
2021-12-21 22:09:11 +00:00
Arun Rodrigues
353d2063b1 scons: CheckLinkFlag() only adds to flags if test succeeds
Previously, did not check the return of TryLink() before appending, so
unsupported flags can be used when building shared libraries. This
patch adds checking.

Jira Issue: https://gem5.atlassian.net/browse/GEM5-1115

Change-Id: Ief62be15009cae9e02aaaa81b4d9c2d7b26e0223
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53025
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>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-12-01 19:01:48 +00:00
Austin Harris
45cfd99ce9 scons: allow building gem5 in a nix environment
Binaries in nixpkgs are wrapped to use NIX_ environment variables, so
add these to the variables used by scons so that gem5 can be built on a
system using nix.

Change-Id: Iad59db6a4c84d8c7131f309af83618ced1624cfb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50257
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-10-25 14:23:08 +00:00
Gabe Black
645e315180 scons: Copy the value of "tags" before adding "add_tags" to it.
Otherwise the tags in "add_tags" are added into the original, modifying
it for the caller.

Change-Id: I6a82168d54f80ec9f919825edebe7f0ef154c5ae
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51830
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-10-22 11:39:00 +00:00
Gabe Black
741cb727ca scons: Resolve tags for source files as well as for filters.
The tags for source files need to be resolved as well as the tags for
the filters themselves.

For example, the 'x86 isa' tag could imply 'gem5 lib'. If we filter for
all files which include the tag 'gem5 lib', we would also want to get
all the files that used the tag 'x86 isa' by itself, since that would
imply 'gem5 lib' as well.

Change-Id: Ie513778cc5b8ac1f1893728b14e84cabdaabf0e6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51828
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
2021-10-21 19:57:12 +00:00
Gabe Black
64c9e07498 scons: Pull bytesToCppArray into build_tools.
This mechanism will be used by various small scripts which perform steps
of the build.

Change-Id: I91d842c022d6f568715e8a10310894cb8afbab20
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49398
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:52 +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
17afe4e7ab scons: Fix checking the --install-hooks option in the "git" tool.
The option should be checked with 'install_hooks' and not
'install-hooks', even though the option is '--install-hooks' to the
user.

This bug was due to an incorrect review suggestion from me on this
original change:

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

JIRA: https://gem5.atlassian.net/browse/GEM5-1091

Change-Id: Ifb4526307bea015de1fe73d3d685477be711b7cb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50628
Maintainer: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Eric Ye <ericye@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-09-19 06:02:03 +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
88a932522d scons: Move the bytesToCppArray helper to gem5_scons.util.
Change-Id: Ib8789dd33ebbfb8e10446de5d1079654a2200d2d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48377
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
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
8dcf606015 scons: Turn gem5_scons.builders from a module into a package.
This will make it easier to organize when there are more builders in the
future.

Change-Id: I3db2f2c87b39ed0d427a2e505c7c9152e47ee58b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48374
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-09-14 23:25:48 +00:00
Gabe Black
2a4f01b87f scons: Add a pair of functions for working with Value nodes.
These nodes are really for working with text, and they do strange and
broken things otherwise. This change adds a pair of convenience
functions which uses pickle to serialize an object for the Value to
hold, and to unpack the Value later.

Change-Id: Id48822ce3de283b003d4cc7ef6b563a70e321ca6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48371
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
2021-09-14 22:12:25 +00:00
Gabe Black
fc75880d25 scons: Update the minimum version of python to 3.6.
The gem5 website says the minimum version of python is 3.6, but SCons
was only enforcing version 3.0.

Change-Id: I50e406538b29d2ee469d5fcc16cd509cfa6a7540
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48513
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-27 15:47:15 +00:00