Jason Lowe-Power has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/46380 )

Change subject: scons: Put all Params::create funcs in one file
......................................................................

scons: Put all Params::create funcs in one file

The automatic generation of the params' create functions is causing GCC
linking errors on debug builds. The problem is that many of the .o files
are much larger than 1MB, and when there are 100s of 10-20MB files to
link, GCC cannot include debug symbols within a 32 bit offset.

The underlying issue seems to be that there are many header files which
include inline functions and they are replicated in the .o files.

Instead of moving code around in many files hoping to accidentally fix
the issue (this seemed to have happened recently on develop), this
change instead makes sure that all of the headers are only included in a
single .o file by grouping all of the create() functions in a single
file.

In the future, we should probably revisit how we are automatically
creating the create functions. See the linked issue below for more
details.

Change-Id: I45cd47e0027c72922cd65466f58e962d8bc46797
Issue-on: https://gem5.atlassian.net/browse/GEM5-1003
Signed-off-by: Jason Lowe-Power <[email protected]>
---
M src/SConscript
1 file changed, 32 insertions(+), 5 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index cc51b9f..c671f27 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -986,6 +986,7 @@
     obj.cxx_param_decl(code)
     code.write(target[0].abspath)

+# Note: This function is unused because of the hack below.
 def createSimObjectParamDef(target, source, env):
     assert len(target) == 1 and len(source) == 1

@@ -996,6 +997,16 @@
     obj.cxx_param_def(code)
     code.write(target[0].abspath)

+# This function puts all of the create() parameter implementations in a single
+# file to get around GCC's limit on the size of the debug symbols in the
+# linking stage.
+def createAllSimObjectParamDef(target, source, env):
+    code = code_formatter()
+    for name,simobj in sorted(sim_objects.items()):
+ if not getattr(simobj, 'abstract', False) and hasattr(simobj, 'type'):
+            simobj.cxx_param_def(code)
+    code.write(target[0].abspath)
+
 def createSimObjectCxxConfig(is_header):
     def body(target, source, env):
         assert len(target) == 1 and len(source) == 1
@@ -1041,6 +1052,7 @@

 # Generate all of the SimObject param C++ struct header files
 params_hh_files = []
+all_deps = []
 for name,simobj in sorted(sim_objects.items()):
     # If this simobject's source changes, we need to regenerate the header.
     py_source = PySource.modules[simobj.__module__]
@@ -1060,11 +1072,26 @@
     env.Depends(hh_file, depends + extra_deps)

     if not getattr(simobj, 'abstract', False) and hasattr(simobj, 'type'):
-        cc_file = File('params/%s.cc' % name)
-        env.Command(cc_file, Value(name),
- MakeAction(createSimObjectParamDef, Transform("SOPARMCC")))
-        env.Depends(cc_file, depends + extra_deps)
-        Source(cc_file)
+ # NOTE: The code below will create one cc file for each param. However, + # this results in many MB+ object files that when linked causes + # GCC to die in many cases. TODO: Find a better solution to this
+        #       bug. See GEM5-1003.
+        # cc_file = File('params/%s.cc' % name)
+        # env.Command(cc_file, Value(name),
+        #             MakeAction(createSimObjectParamDef,
+        #                        Transform("SOPARMCC")))
+        # env.Depends(cc_file, depends + extra_deps)
+        # Source(cc_file)
+        all_deps += extra_deps
+
+# Create a single large cc file for all of the create() functions. This is
+# needed so that there is only one large object file instead of 100s when each
+# param has it's own cc file. See GEM5-1003.
+params_cc_file = File('params/create_functions.cc')
+env.Command(params_cc_file, Value('create_functions'),
+            MakeAction(createAllSimObjectParamDef, Transform('SOPARMCC')))
+env.Depends(params_cc_file, depends + all_deps)
+Source(params_cc_file)

 # C++ parameter description files
 if GetOption('with_cxx_config'):

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/46380
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: I45cd47e0027c72922cd65466f58e962d8bc46797
Gerrit-Change-Number: 46380
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <[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