summaryrefslogtreecommitdiffstats
path: root/build/compiler_version.py
diff options
context:
space:
mode:
authormithro@mithis.com <mithro@mithis.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-17 14:11:21 +0000
committermithro@mithis.com <mithro@mithis.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-17 14:11:21 +0000
commit1c26c6a8fdc42b400b3a2ad3b7341fcebd4353a8 (patch)
tree1063973174d05a75ea5e58ec80ea1ff2c8f985db /build/compiler_version.py
parentc140f9bd4757f5395a03b094f31824f9cea2390d (diff)
downloadchromium_src-1c26c6a8fdc42b400b3a2ad3b7341fcebd4353a8.zip
chromium_src-1c26c6a8fdc42b400b3a2ad3b7341fcebd4353a8.tar.gz
chromium_src-1c26c6a8fdc42b400b3a2ad3b7341fcebd4353a8.tar.bz2
This change helps with two significant problems with Chrome debug
builds, * Slow link times. * Slow gdb startup times. Lots more detailed information at http://gcc.gnu.org/wiki/DebugFission Overall, this improves linking speed of debug Chrome builds on Linux by ~12% and speeds up gdb by around 30%. This requires a objcopy with --extract-dwo object (binutils newer then 2.22.52.0.4 // 2.23). Ubuntu Precise only comes with 2.23 BUG= Review URL: https://codereview.chromium.org/197013010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/compiler_version.py')
-rwxr-xr-xbuild/compiler_version.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/build/compiler_version.py b/build/compiler_version.py
index b349199..bc3bee5 100755
--- a/build/compiler_version.py
+++ b/build/compiler_version.py
@@ -14,42 +14,66 @@ import re
import subprocess
import sys
-def GetVersion(compiler):
+
+def GetVersion(compiler, tool):
+ tool_output = tool_error = None
try:
# Note that compiler could be something tricky like "distcc g++".
- compiler = compiler + " -dumpversion"
+ if tool == "compiler":
+ compiler = compiler + " -dumpversion"
+ # 4.6
+ version_re = re.compile(r"(\d+)\.(\d+)")
+ elif tool == "assembler":
+ compiler = compiler + " -Xassembler --version -x assembler -c /dev/null"
+ # GNU assembler (GNU Binutils for Ubuntu) 2.22
+ version_re = re.compile(r"GNU [^ ]+ \(.*\) (\d+).(\d+)")
+ elif tool == "linker":
+ compiler = compiler + " -Xlinker --version"
+ # GNU gold (GNU Binutils for Ubuntu 2.22) 1.11
+ version_re = re.compile(r"GNU [^ ]+ \(.*\) (\d+).(\d+)")
+ else:
+ raise Exception("Unknown tool %s" % tool)
+
pipe = subprocess.Popen(compiler, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- gcc_output, gcc_error = pipe.communicate()
+ tool_output, tool_error = pipe.communicate()
if pipe.returncode:
raise subprocess.CalledProcessError(pipe.returncode, compiler)
- result = re.match(r"(\d+)\.(\d+)", gcc_output)
+ result = version_re.match(tool_output)
return result.group(1) + result.group(2)
except Exception, e:
- if gcc_error:
- sys.stderr.write(gcc_error)
+ if tool_error:
+ sys.stderr.write(tool_error)
print >> sys.stderr, "compiler_version.py failed to execute:", compiler
print >> sys.stderr, e
return ""
-def main():
+
+def main(args):
+ tool = "compiler"
+ if len(args) == 1:
+ tool = args[0]
+ elif len(args) > 1:
+ print "Unknown arguments!"
+
# Check if CXX environment variable exists and
# if it does use that compiler.
cxx = os.getenv("CXX", None)
if cxx:
- cxxversion = GetVersion(cxx)
+ cxxversion = GetVersion(cxx, tool)
if cxxversion != "":
print cxxversion
return 0
else:
# Otherwise we check the g++ version.
- gccversion = GetVersion("g++")
+ gccversion = GetVersion("g++", tool)
if gccversion != "":
print gccversion
return 0
return 1
+
if __name__ == "__main__":
- sys.exit(main())
+ sys.exit(main(sys.argv[1:]))