scons: When spawning the linker process, don't involve the shell.
authorGabe Black <gabeblack@google.com>
Fri, 14 Apr 2017 00:13:10 +0000 (17:13 -0700)
committerGabe Black <gabeblack@google.com>
Fri, 14 Apr 2017 01:56:47 +0000 (01:56 +0000)
The command line can be too long, causing bash to choke. This means we can't
use any shell syntax like shell variables or redirection when linking, but
that should be easy to avoid.

Change-Id: Ie6c8ecab337cef6bd3c7e403346ced06f46f0993
Reviewed-on: https://gem5-review.googlesource.com/2780
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Steve Reinhardt <stever@gmail.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/SConscript

index 521d73bac3d4e7f8140e226bfea9870bd8784422..645b9251a017d83842c8806fede8b80d4a6f9d19 100755 (executable)
@@ -34,6 +34,7 @@ import imp
 import marshal
 import os
 import re
+import subprocess
 import sys
 import zlib
 
@@ -1194,7 +1195,18 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
     if strip:
         progname += '.unstripped'
 
-    targets = new_env.Program(progname, main_objs + static_objs)
+    # When linking the gem5 binary, the command line can be too big for the
+    # shell to handle. Use "subprocess" to spawn processes without passing
+    # through the shell to avoid this problem. That means we also can't use
+    # shell syntax in any of the commands this will run, but that isn't
+    # currently an issue.
+    def spawn_with_subprocess(sh, escape, cmd, args, env):
+        return subprocess.call(args, env=env)
+
+    # Since we're not running through a shell, no escaping is necessary either.
+    targets = new_env.Program(progname, main_objs + static_objs,
+                              SPAWN=spawn_with_subprocess,
+                              ESCAPE=lambda x: x)
 
     if strip:
         if sys.platform == 'sunos5':