Hello Matthew Poremba,

I'd like you to do a code review. Please visit

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

to review the following change.


Change subject: scons: Borrow distcc setup from amd-master
......................................................................

scons: Borrow distcc setup from amd-master

Gotta go fast.

Change-Id: I90a7628e0930e35fd1e33bf89df79951e5d2e9fa
---
M SConstruct
1 file changed, 81 insertions(+), 6 deletions(-)



diff --git a/SConstruct b/SConstruct
index 4dc48ae..e9ebcaf 100755
--- a/SConstruct
+++ b/SConstruct
@@ -161,21 +161,86 @@
                help='Build with Undefined Behavior Sanitizer if available')
 AddLocalOption('--with-asan', action='store_true',
                help='Build with Address Sanitizer if available')
-AddLocalOption('--with-systemc-tests', action='store_true',
-               help='Build systemc tests')
+AddLocalOption('--with-systemc-tests', dest='with_systemc_tests',
+               action='store_true', help='Build systemc tests')
+AddLocalOption('--distcc', dest='distcc', action='store_true',
+               help='Build with distcc on rtllsmake hosts')

 from gem5_scons import Transform, error, warning, summarize_warnings

 if GetOption('no_lto') and GetOption('force_lto'):
     error('--no-lto and --force-lto are mutually exclusive')

+#####################################################################
+#
+# Generate distcc hosts
+#
+if (GetOption('distcc')):
+    print("Setting up distcc")
+
+    num_jobs = GetOption('num_jobs')
+    available_hosts = "lsf_lslsmake -RHEL7_64 | head -%s" % (num_jobs)
+    output = subprocess.check_output(available_hosts, shell=True)
+
+    unique_machines = {}
+    for machine in output.split():
+        if machine in unique_machines:
+            unique_machines[machine] += 1
+        else:
+            unique_machines[machine] = 1
+
+    hosts = ["%s/%d,cpp,lzo" % (line, unique_machines[line]) for line in \
+             unique_machines]
+    hosts.append("--randomize")
+
+    pumpEnv = os.environ
+    pumpEnv['DISTCC_HOSTS'] = ' '.join(hosts)
+    output = subprocess.check_output("pump --startup", shell=True,
+                                     env=pumpEnv)
+    exports = output.rstrip().split('\n')
+    print(", using (%s)" % ' '.join(hosts))
+
 ########################################################################
 #
 # Set up the main build environment.
 #
 ########################################################################

-main = Environment()
+# export TERM so that clang reports errors in color
+use_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH',
+                 'LIBRARY_PATH', 'PATH', 'PKG_CONFIG_PATH', 'PROTOC',
+                 'PYTHONPATH', 'RANLIB', 'TERM' ])
+
+use_prefixes = [
+    "ASAN_",           # address sanitizer symbolizer path and settings
+    "CCACHE_",         # ccache (caching compiler wrapper) configuration
+    "CCC_",            # clang static analyzer configuration
+ "DISTCC_", # distcc (distributed compiler wrapper) configuration
+    "INCLUDE_SERVER_", # distcc pump server settings
+    "M5",              # M5 configuration (e.g., path to kernels)
+    "UBSAN",
+    "ASAN",
+    ]
+
+use_env = {}
+for key,val in sorted(os.environ.iteritems()):
+    if key in use_vars or \
+            any([key.startswith(prefix) for prefix in use_prefixes]):
+        use_env[key] = val
+
+if (GetOption('distcc')):
+    for export in exports:
+        [env, val] = export.lstrip("export ").split("=")
+        val = val.strip("'")
+        use_env[env] = val
+
+# Tell scons to avoid implicit command dependencies to avoid issues
+# with the param wrappes being compiled twice (see
+# http://scons.tigris.org/issues/show_bug.cgi?id=2811)
+main = Environment(ENV=use_env, IMPLICIT_COMMAND_DEPENDENCIES=0)
+main.Decider('MD5-timestamp')
+main.root = Dir(".") # The current directory (where this file lives).
+main.srcdir = Dir("src")     # The source directory

 from gem5_scons.util import get_termcap
 termcap = get_termcap()
@@ -276,14 +341,17 @@
     ('PYTHON_CONFIG', 'Python config binary to use',
      [ 'python2.7-config', 'python-config', 'python3-config' ]),
     ('PROTOC', 'protoc tool', environ.get('PROTOC', 'protoc')),
-    ('BATCH', 'Use batch pool for build and tests', False),
-    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
+    ('BATCH', 'Use batch pool for build and tests', True if
+        GetOption('distcc') else False),
+    ('BATCH_CMD', 'Batch pool submission command name', 'distcc' if \
+                                      GetOption('distcc') else ''),
     ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
     ('EXTRAS', 'Add extra directories to the compilation', '')
     )

 # Update main environment with values from ARGUMENTS & global_vars_file
 global_vars.Update(main)
+
 help_texts["global_vars"] += global_vars.GenerateHelpText(main)

 # Save sticky variable settings back to current variables file
@@ -472,6 +540,7 @@
                          # use struct hash and class hash
                          # interchangeably.
                          '-Wno-mismatched-tags',
+                         '-Wno-dynamic-class-memaccess',
                          ])
     if compareVersions(clang_version, "10.0") >= 0:
         main.Append(CCFLAGS=['-Wno-c99-designator'])
@@ -999,7 +1068,7 @@
                  False),
     BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
     BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
-    BoolVariable('USE_PNG',  'Enable support for PNG images', have_png),
+    BoolVariable('USE_PNG',  'Enable support for PNG images', False),
BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability',
                  False),
     BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models',
@@ -1159,6 +1228,12 @@

 main.AddMethod(switching_headers, 'SwitchingHeaders')

+def endOfBuild(**ignored):
+    if (GetOption('distcc')):
+        print("Shutting down distcc-pump")
+        subprocess.call("pump --shutdown", shell=True)
+main.Append(BUILDERS = {'Dummy': Builder(action=MakeAction(endOfBuild, None))})
+
 ###################################################
 #
 # Define build environments for selected configurations.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32854
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I90a7628e0930e35fd1e33bf89df79951e5d2e9fa
Gerrit-Change-Number: 32854
Gerrit-PatchSet: 1
Gerrit-Owner: Bradford Beckmann <[email protected]>
Gerrit-Reviewer: Matthew Poremba <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to