Backout expandlibs part of bug 812179 for breaking bug 603370. r=me
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 06 Mar 2013 11:11:43 +0100
changeset 134324 92824d900e2576622751f1f51ea2ece1408b805a
parent 134323 c77fdc51aa60457a9efa7bbfb147d9376a2d0ce5
child 134325 33390040087addf33c301bc618bcbf80923245d0
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs812179, 603370
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout expandlibs part of bug 812179 for breaking bug 603370. r=me
config/expandlibs.py
config/expandlibs_exec.py
config/expandlibs_gen.py
js/src/config/expandlibs.py
js/src/config/expandlibs_exec.py
js/src/config/expandlibs_gen.py
--- a/config/expandlibs.py
+++ b/config/expandlibs.py
@@ -21,26 +21,27 @@ given a list of files, expandlibs will r
 - If a ${DLL_PREFIX}${ROOT}.${DLL_SUFFIX} or
   ${DLL_PREFIX}${ROOT}.${IMPORT_LIB_SUFFIX} file exists, use that instead
 - If the ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} file exists, use it
 - If a ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX}.${LIB_DESC_SUFFIX} file exists,
   replace ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} with the OBJS and LIBS the
   descriptor contains. And for each of these LIBS, also apply the same
   rules.
 '''
+from __future__ import with_statement
 import sys, os, errno
 import expandlibs_config as conf
 
 def ensureParentDir(file):
     '''Ensures the directory parent to the given file exists'''
     dir = os.path.dirname(file)
     if dir and not os.path.exists(dir):
         try:
             os.makedirs(dir)
-        except OSError as error:
+        except OSError, error:
             if error.errno != errno.EEXIST:
                 raise
 
 def relativize(path):
     '''Returns a path relative to the current working directory, if it is
     shorter than the given path'''
     def splitpath(path):
         dir, file = os.path.split(path)
@@ -84,18 +85,17 @@ class LibDescriptor(dict):
         if not content:
             return
         for key, value in [(s.strip() for s in item.split('=', 2)) for item in content if item.find('=') >= 0]:
             if key in self.KEYS:
                 self[key] = value.split()
 
     def __str__(self):
         '''Serializes the lib descriptor'''
-        return '\n'.join('{0} = {1}'.format(k, ' '.join(self[k]))
-                         for k in self.KEYS if len(self[k]))
+        return '\n'.join('%s = %s' % (k, ' '.join(self[k])) for k in self.KEYS if len(self[k]))
 
 class ExpandArgs(list):
     def __init__(self, args):
         '''Creates a clone of the |args| list and performs file expansion on
         each item it contains'''
         super(ExpandArgs, self).__init__()
         for arg in args:
             self += self._expand(arg)
@@ -130,9 +130,9 @@ class ExpandLibsDeps(ExpandArgs):
     '''Same as ExpandArgs, but also adds the library descriptor to the list'''
     def _expand_desc(self, arg):
         objs = super(ExpandLibsDeps, self)._expand_desc(arg)
         if os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
             objs += [relativize(arg + conf.LIBS_DESC_SUFFIX)]
         return objs
 
 if __name__ == '__main__':
-    print(" ".join(ExpandArgs(sys.argv[1:])))
+    print " ".join(ExpandArgs(sys.argv[1:]))
--- a/config/expandlibs_exec.py
+++ b/config/expandlibs_exec.py
@@ -15,21 +15,20 @@ of a command line. The kind of list file
 EXPAND_LIBS_LIST_STYLE variable: 'list' for MSVC style lists (@file.list)
 or 'linkerscript' for GNU ld linker scripts.
 See https://bugzilla.mozilla.org/show_bug.cgi?id=584474#c59 for more details.
 
 With the --symbol-order argument, followed by a file name, it will add the
 relevant linker options to change the order in which the linker puts the
 symbols appear in the resulting binary. Only works for ELF targets.
 '''
-from __future__ import print_function
+from __future__ import with_statement
 import sys
 import os
-from expandlibs import (ExpandArgs, relativize, isObject, ensureParentDir,
-                        ExpandLibsDeps)
+from expandlibs import ExpandArgs, relativize, isObject, ensureParentDir, ExpandLibsDeps
 import expandlibs_config as conf
 from optparse import OptionParser
 import subprocess
 import tempfile
 import shutil
 import subprocess
 import re
 
@@ -88,20 +87,20 @@ class ExpandArgsMore(ExpandArgs):
     def makelist(self):
         '''Replaces object file names with a temporary list file, using a
         list format depending on the EXPAND_LIBS_LIST_STYLE variable
         '''
         objs = [o for o in self if isObject(o)]
         if not len(objs): return
         fd, tmp = tempfile.mkstemp(suffix=".list",dir=os.curdir)
         if conf.EXPAND_LIBS_LIST_STYLE == "linkerscript":
-            content = ['INPUT("{0}")\n'.format(obj) for obj in objs]
+            content = ['INPUT("%s")\n' % obj for obj in objs]
             ref = tmp
         elif conf.EXPAND_LIBS_LIST_STYLE == "list":
-            content = ["{0}\n".format(obj) for obj in objs]
+            content = ["%s\n" % obj for obj in objs]
             ref = "@" + tmp
         else:
             os.close(fd)
             os.remove(tmp)
             return
         self.tmp.append(tmp)
         f = os.fdopen(fd, "w")
         f.writelines(content)
@@ -135,23 +134,19 @@ class ExpandArgsMore(ExpandArgs):
                     result[quoted[5]].append(quoted[1])
                 else:
                     result[quoted[5]] = [quoted[1]]
         return result
 
     def _getOrderedSections(self, ordered_symbols):
         '''Given an ordered list of symbols, returns the corresponding list
         of sections following the order.'''
-        if conf.EXPAND_LIBS_ORDER_STYLE not in ['linkerscript',
-                                                'section-ordering-file']:
-            raise Exception('EXPAND_LIBS_ORDER_STYLE "{0}" is not supported'
-                            .format(conf.EXPAND_LIBS_ORDER_STYLE))
-        finder = SectionFinder([arg for arg in self 
-                                if isObject(arg) or 
-                                os.path.splitext(arg)[1] == conf.LIB_SUFFIX])
+        if not conf.EXPAND_LIBS_ORDER_STYLE in ['linkerscript', 'section-ordering-file']:
+            raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
+        finder = SectionFinder([arg for arg in self if isObject(arg) or os.path.splitext(arg)[1] == conf.LIB_SUFFIX])
         folded = self._getFoldedSections()
         sections = set()
         ordered_sections = []
         for symbol in ordered_symbols:
             symbol_sections = finder.getSections(symbol)
             all_symbol_sections = []
             for section in symbol_sections:
                 if section in folded:
@@ -182,64 +177,59 @@ class ExpandArgsMore(ExpandArgs):
                     else:
                         split_sections[linked_section] = [s]
                     break
         content = []
         # Order is important
         linked_sections = [s for s in linked_sections if s in split_sections]
 
         if conf.EXPAND_LIBS_ORDER_STYLE == 'section-ordering-file':
-            option = '-Wl,--section-ordering-file,{0}'
+            option = '-Wl,--section-ordering-file,%s'
             content = sections
             for linked_section in linked_sections:
                 content.extend(split_sections[linked_section])
-                content.append('{0}.*'.format(linked_section))
+                content.append('%s.*' % linked_section)
                 content.append(linked_section)
 
         elif conf.EXPAND_LIBS_ORDER_STYLE == 'linkerscript':
-            option = '-Wl,-T,{0}'
+            option = '-Wl,-T,%s'
             section_insert_before = dict(SECTION_INSERT_BEFORE)
             for linked_section in linked_sections:
-                content.append('SECTIONS {{')
-                content.append('  {0} : {{'.format(linked_section))
-                content.extend('    *({0})'
-                               .format(s for s in split_sections[linked_section]))
-                content.append('  }}')
-                content.append('}}')
-                content.append('INSERT BEFORE {0}'
-                               .format(section_insert_before[linked_section]))
+                content.append('SECTIONS {')
+                content.append('  %s : {' % linked_section)
+                content.extend('    *(%s)' % s for s in split_sections[linked_section])
+                content.append('  }')
+                content.append('}')
+                content.append('INSERT BEFORE %s' % section_insert_before[linked_section])
         else:
-            raise Exception('EXPAND_LIBS_ORDER_STYLE "{0}" is not supported'
-                            .format(conf.EXPAND_LIBS_ORDER_STYLE))
+            raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
 
         fd, tmp = tempfile.mkstemp(dir=os.curdir)
         f = os.fdopen(fd, "w")
         f.write('\n'.join(content)+'\n')
         f.close()
         self.tmp.append(tmp)
-        self.append(option.format(tmp))
+        self.append(option % tmp)
 
 class SectionFinder(object):
     '''Instances of this class allow to map symbol names to sections in
     object files.'''
 
     def __init__(self, objs):
         '''Creates an instance, given a list of object files.'''
         if not conf.EXPAND_LIBS_ORDER_STYLE in ['linkerscript', 'section-ordering-file']:
-            raise Exception('EXPAND_LIBS_ORDER_STYLE "{0}" is not supported'
-                            .format(conf.EXPAND_LIBS_ORDER_STYLE))
+            raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
         self.mapping = {}
         for obj in objs:
             if not isObject(obj) and os.path.splitext(obj)[1] != conf.LIB_SUFFIX:
-                raise Exception('{0} is not an object nor a static library'
-                                .format(obj))
+                raise Exception('%s is not an object nor a static library' % obj)
             for symbol, section in SectionFinder._getSymbols(obj):
                 sym = SectionFinder._normalize(symbol)
                 if sym in self.mapping:
-                    if section not in self.mapping[sym]:
+                    if not section in self.mapping[sym]:
                         self.mapping[sym].append(section)
                 else:
                     self.mapping[sym] = [section]
 
     def getSections(self, symbol):
         '''Given a symbol, returns a list of sections containing it or the
         corresponding thunks. When the given symbol is a thunk, returns the
         list of sections containing its corresponding normal symbol and the
@@ -273,21 +263,21 @@ class SectionFinder(object):
             # and where the [FfO] flag is either F (function) or O (object).
             if len(tmp) > 1 and len(tmp[1]) > 6 and tmp[1][6] in ['O', 'F']:
                 tmp = tmp[1][8:].split()
                 # That gives us ["<section>","<length>", "<symbol>"]
                 syms.append((tmp[-1], tmp[0]))
         return syms
 
 def print_command(out, args):
-    print("Executing: " + " ".join(args), file=out)
+    print >>out, "Executing: " + " ".join(args)
     for tmp in [f for f in args.tmp if os.path.isfile(f)]:
-        print(tmp + ":", file=out)
+        print >>out, tmp + ":"
         with open(tmp) as file:
-            print("".join(["    " + l for l in file.readlines()]), file=out)
+            print >>out, "".join(["    " + l for l in file.readlines()])
     out.flush()
 
 def main():
     parser = OptionParser()
     parser.add_option("--depend", dest="depend", metavar="FILE",
         help="generate dependencies for the given execution and store it in the given file")
     parser.add_option("--target", dest="target", metavar="FILE",
         help="designate the target for dependencies")
@@ -328,16 +318,13 @@ def main():
         sys.stderr.write(stdout)
         sys.stderr.flush()
         if proc.returncode:
             exit(proc.returncode)
     if not options.depend:
         return
     ensureParentDir(options.depend)
     with open(options.depend, 'w') as depfile:
-        depfile.write("{0} : {1}\n"
-                      .format(options.target, ' '.join(dep for dep in deps 
-                                                       if os.path.isfile(dep) and 
-                                                       dep != options.target)))
+        depfile.write("%s : %s\n" % (options.target, ' '.join(dep for dep in deps if os.path.isfile(dep) and dep != options.target)))
 
 
 if __name__ == '__main__':
     main()
--- a/config/expandlibs_gen.py
+++ b/config/expandlibs_gen.py
@@ -1,47 +1,47 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from __future__ import print_function
+
 '''Given a list of object files and library names, prints a library
 descriptor to standard output'''
 
+from __future__ import with_statement
 import sys
 import os
 import expandlibs_config as conf
 from expandlibs import LibDescriptor, isObject, ensureParentDir, ExpandLibsDeps
 from optparse import OptionParser
 
 def generate(args):
     desc = LibDescriptor()
     for arg in args:
         if isObject(arg):
             if os.path.exists(arg):
                 desc['OBJS'].append(os.path.abspath(arg))
             else:
-                raise Exception("File not found: {0}".format(arg))
+                raise Exception("File not found: %s" % arg)
         elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX:
             if os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
                 desc['LIBS'].append(os.path.abspath(arg))
             else:
-                raise Exception("File not found: {0}".format(arg))
+                raise Exception("File not found: %s" % arg)
     return desc
 
 if __name__ == '__main__':
     parser = OptionParser()
     parser.add_option("--depend", dest="depend", metavar="FILE",
         help="generate dependencies for the given execution and store it in the given file")
     parser.add_option("-o", dest="output", metavar="FILE",
         help="send output to the given file")
 
     (options, args) = parser.parse_args()
     if not options.output:
         raise Exception("Missing option: -o")
 
     ensureParentDir(options.output)
     with open(options.output, 'w') as outfile:
-        print(generate(args), file=outfile)
+        print >>outfile, generate(args)
     if options.depend:
         ensureParentDir(options.depend)
         with open(options.depend, 'w') as depfile:
-            depfile.write("{0} : {1}\n".format(options.output, 
-                                               ' '.join(ExpandLibsDeps(args))))
+            depfile.write("%s : %s\n" % (options.output, ' '.join(ExpandLibsDeps(args))))
--- a/js/src/config/expandlibs.py
+++ b/js/src/config/expandlibs.py
@@ -21,26 +21,27 @@ given a list of files, expandlibs will r
 - If a ${DLL_PREFIX}${ROOT}.${DLL_SUFFIX} or
   ${DLL_PREFIX}${ROOT}.${IMPORT_LIB_SUFFIX} file exists, use that instead
 - If the ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} file exists, use it
 - If a ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX}.${LIB_DESC_SUFFIX} file exists,
   replace ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} with the OBJS and LIBS the
   descriptor contains. And for each of these LIBS, also apply the same
   rules.
 '''
+from __future__ import with_statement
 import sys, os, errno
 import expandlibs_config as conf
 
 def ensureParentDir(file):
     '''Ensures the directory parent to the given file exists'''
     dir = os.path.dirname(file)
     if dir and not os.path.exists(dir):
         try:
             os.makedirs(dir)
-        except OSError as error:
+        except OSError, error:
             if error.errno != errno.EEXIST:
                 raise
 
 def relativize(path):
     '''Returns a path relative to the current working directory, if it is
     shorter than the given path'''
     def splitpath(path):
         dir, file = os.path.split(path)
@@ -84,18 +85,17 @@ class LibDescriptor(dict):
         if not content:
             return
         for key, value in [(s.strip() for s in item.split('=', 2)) for item in content if item.find('=') >= 0]:
             if key in self.KEYS:
                 self[key] = value.split()
 
     def __str__(self):
         '''Serializes the lib descriptor'''
-        return '\n'.join('{0} = {1}'.format(k, ' '.join(self[k]))
-                         for k in self.KEYS if len(self[k]))
+        return '\n'.join('%s = %s' % (k, ' '.join(self[k])) for k in self.KEYS if len(self[k]))
 
 class ExpandArgs(list):
     def __init__(self, args):
         '''Creates a clone of the |args| list and performs file expansion on
         each item it contains'''
         super(ExpandArgs, self).__init__()
         for arg in args:
             self += self._expand(arg)
@@ -130,9 +130,9 @@ class ExpandLibsDeps(ExpandArgs):
     '''Same as ExpandArgs, but also adds the library descriptor to the list'''
     def _expand_desc(self, arg):
         objs = super(ExpandLibsDeps, self)._expand_desc(arg)
         if os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
             objs += [relativize(arg + conf.LIBS_DESC_SUFFIX)]
         return objs
 
 if __name__ == '__main__':
-    print(" ".join(ExpandArgs(sys.argv[1:])))
+    print " ".join(ExpandArgs(sys.argv[1:]))
--- a/js/src/config/expandlibs_exec.py
+++ b/js/src/config/expandlibs_exec.py
@@ -15,21 +15,20 @@ of a command line. The kind of list file
 EXPAND_LIBS_LIST_STYLE variable: 'list' for MSVC style lists (@file.list)
 or 'linkerscript' for GNU ld linker scripts.
 See https://bugzilla.mozilla.org/show_bug.cgi?id=584474#c59 for more details.
 
 With the --symbol-order argument, followed by a file name, it will add the
 relevant linker options to change the order in which the linker puts the
 symbols appear in the resulting binary. Only works for ELF targets.
 '''
-from __future__ import print_function
+from __future__ import with_statement
 import sys
 import os
-from expandlibs import (ExpandArgs, relativize, isObject, ensureParentDir,
-                        ExpandLibsDeps)
+from expandlibs import ExpandArgs, relativize, isObject, ensureParentDir, ExpandLibsDeps
 import expandlibs_config as conf
 from optparse import OptionParser
 import subprocess
 import tempfile
 import shutil
 import subprocess
 import re
 
@@ -88,20 +87,20 @@ class ExpandArgsMore(ExpandArgs):
     def makelist(self):
         '''Replaces object file names with a temporary list file, using a
         list format depending on the EXPAND_LIBS_LIST_STYLE variable
         '''
         objs = [o for o in self if isObject(o)]
         if not len(objs): return
         fd, tmp = tempfile.mkstemp(suffix=".list",dir=os.curdir)
         if conf.EXPAND_LIBS_LIST_STYLE == "linkerscript":
-            content = ['INPUT("{0}")\n'.format(obj) for obj in objs]
+            content = ['INPUT("%s")\n' % obj for obj in objs]
             ref = tmp
         elif conf.EXPAND_LIBS_LIST_STYLE == "list":
-            content = ["{0}\n".format(obj) for obj in objs]
+            content = ["%s\n" % obj for obj in objs]
             ref = "@" + tmp
         else:
             os.close(fd)
             os.remove(tmp)
             return
         self.tmp.append(tmp)
         f = os.fdopen(fd, "w")
         f.writelines(content)
@@ -135,23 +134,19 @@ class ExpandArgsMore(ExpandArgs):
                     result[quoted[5]].append(quoted[1])
                 else:
                     result[quoted[5]] = [quoted[1]]
         return result
 
     def _getOrderedSections(self, ordered_symbols):
         '''Given an ordered list of symbols, returns the corresponding list
         of sections following the order.'''
-        if conf.EXPAND_LIBS_ORDER_STYLE not in ['linkerscript',
-                                                'section-ordering-file']:
-            raise Exception('EXPAND_LIBS_ORDER_STYLE "{0}" is not supported'
-                            .format(conf.EXPAND_LIBS_ORDER_STYLE))
-        finder = SectionFinder([arg for arg in self 
-                                if isObject(arg) or 
-                                os.path.splitext(arg)[1] == conf.LIB_SUFFIX])
+        if not conf.EXPAND_LIBS_ORDER_STYLE in ['linkerscript', 'section-ordering-file']:
+            raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
+        finder = SectionFinder([arg for arg in self if isObject(arg) or os.path.splitext(arg)[1] == conf.LIB_SUFFIX])
         folded = self._getFoldedSections()
         sections = set()
         ordered_sections = []
         for symbol in ordered_symbols:
             symbol_sections = finder.getSections(symbol)
             all_symbol_sections = []
             for section in symbol_sections:
                 if section in folded:
@@ -182,64 +177,59 @@ class ExpandArgsMore(ExpandArgs):
                     else:
                         split_sections[linked_section] = [s]
                     break
         content = []
         # Order is important
         linked_sections = [s for s in linked_sections if s in split_sections]
 
         if conf.EXPAND_LIBS_ORDER_STYLE == 'section-ordering-file':
-            option = '-Wl,--section-ordering-file,{0}'
+            option = '-Wl,--section-ordering-file,%s'
             content = sections
             for linked_section in linked_sections:
                 content.extend(split_sections[linked_section])
-                content.append('{0}.*'.format(linked_section))
+                content.append('%s.*' % linked_section)
                 content.append(linked_section)
 
         elif conf.EXPAND_LIBS_ORDER_STYLE == 'linkerscript':
-            option = '-Wl,-T,{0}'
+            option = '-Wl,-T,%s'
             section_insert_before = dict(SECTION_INSERT_BEFORE)
             for linked_section in linked_sections:
-                content.append('SECTIONS {{')
-                content.append('  {0} : {{'.format(linked_section))
-                content.extend('    *({0})'
-                               .format(s for s in split_sections[linked_section]))
-                content.append('  }}')
-                content.append('}}')
-                content.append('INSERT BEFORE {0}'
-                               .format(section_insert_before[linked_section]))
+                content.append('SECTIONS {')
+                content.append('  %s : {' % linked_section)
+                content.extend('    *(%s)' % s for s in split_sections[linked_section])
+                content.append('  }')
+                content.append('}')
+                content.append('INSERT BEFORE %s' % section_insert_before[linked_section])
         else:
-            raise Exception('EXPAND_LIBS_ORDER_STYLE "{0}" is not supported'
-                            .format(conf.EXPAND_LIBS_ORDER_STYLE))
+            raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
 
         fd, tmp = tempfile.mkstemp(dir=os.curdir)
         f = os.fdopen(fd, "w")
         f.write('\n'.join(content)+'\n')
         f.close()
         self.tmp.append(tmp)
-        self.append(option.format(tmp))
+        self.append(option % tmp)
 
 class SectionFinder(object):
     '''Instances of this class allow to map symbol names to sections in
     object files.'''
 
     def __init__(self, objs):
         '''Creates an instance, given a list of object files.'''
         if not conf.EXPAND_LIBS_ORDER_STYLE in ['linkerscript', 'section-ordering-file']:
-            raise Exception('EXPAND_LIBS_ORDER_STYLE "{0}" is not supported'
-                            .format(conf.EXPAND_LIBS_ORDER_STYLE))
+            raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
         self.mapping = {}
         for obj in objs:
             if not isObject(obj) and os.path.splitext(obj)[1] != conf.LIB_SUFFIX:
-                raise Exception('{0} is not an object nor a static library'
-                                .format(obj))
+                raise Exception('%s is not an object nor a static library' % obj)
             for symbol, section in SectionFinder._getSymbols(obj):
                 sym = SectionFinder._normalize(symbol)
                 if sym in self.mapping:
-                    if section not in self.mapping[sym]:
+                    if not section in self.mapping[sym]:
                         self.mapping[sym].append(section)
                 else:
                     self.mapping[sym] = [section]
 
     def getSections(self, symbol):
         '''Given a symbol, returns a list of sections containing it or the
         corresponding thunks. When the given symbol is a thunk, returns the
         list of sections containing its corresponding normal symbol and the
@@ -273,21 +263,21 @@ class SectionFinder(object):
             # and where the [FfO] flag is either F (function) or O (object).
             if len(tmp) > 1 and len(tmp[1]) > 6 and tmp[1][6] in ['O', 'F']:
                 tmp = tmp[1][8:].split()
                 # That gives us ["<section>","<length>", "<symbol>"]
                 syms.append((tmp[-1], tmp[0]))
         return syms
 
 def print_command(out, args):
-    print("Executing: " + " ".join(args), file=out)
+    print >>out, "Executing: " + " ".join(args)
     for tmp in [f for f in args.tmp if os.path.isfile(f)]:
-        print(tmp + ":", file=out)
+        print >>out, tmp + ":"
         with open(tmp) as file:
-            print("".join(["    " + l for l in file.readlines()]), file=out)
+            print >>out, "".join(["    " + l for l in file.readlines()])
     out.flush()
 
 def main():
     parser = OptionParser()
     parser.add_option("--depend", dest="depend", metavar="FILE",
         help="generate dependencies for the given execution and store it in the given file")
     parser.add_option("--target", dest="target", metavar="FILE",
         help="designate the target for dependencies")
@@ -328,16 +318,13 @@ def main():
         sys.stderr.write(stdout)
         sys.stderr.flush()
         if proc.returncode:
             exit(proc.returncode)
     if not options.depend:
         return
     ensureParentDir(options.depend)
     with open(options.depend, 'w') as depfile:
-        depfile.write("{0} : {1}\n"
-                      .format(options.target, ' '.join(dep for dep in deps 
-                                                       if os.path.isfile(dep) and 
-                                                       dep != options.target)))
+        depfile.write("%s : %s\n" % (options.target, ' '.join(dep for dep in deps if os.path.isfile(dep) and dep != options.target)))
 
 
 if __name__ == '__main__':
     main()
--- a/js/src/config/expandlibs_gen.py
+++ b/js/src/config/expandlibs_gen.py
@@ -1,47 +1,47 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from __future__ import print_function
+
 '''Given a list of object files and library names, prints a library
 descriptor to standard output'''
 
+from __future__ import with_statement
 import sys
 import os
 import expandlibs_config as conf
 from expandlibs import LibDescriptor, isObject, ensureParentDir, ExpandLibsDeps
 from optparse import OptionParser
 
 def generate(args):
     desc = LibDescriptor()
     for arg in args:
         if isObject(arg):
             if os.path.exists(arg):
                 desc['OBJS'].append(os.path.abspath(arg))
             else:
-                raise Exception("File not found: {0}".format(arg))
+                raise Exception("File not found: %s" % arg)
         elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX:
             if os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
                 desc['LIBS'].append(os.path.abspath(arg))
             else:
-                raise Exception("File not found: {0}".format(arg))
+                raise Exception("File not found: %s" % arg)
     return desc
 
 if __name__ == '__main__':
     parser = OptionParser()
     parser.add_option("--depend", dest="depend", metavar="FILE",
         help="generate dependencies for the given execution and store it in the given file")
     parser.add_option("-o", dest="output", metavar="FILE",
         help="send output to the given file")
 
     (options, args) = parser.parse_args()
     if not options.output:
         raise Exception("Missing option: -o")
 
     ensureParentDir(options.output)
     with open(options.output, 'w') as outfile:
-        print(generate(args), file=outfile)
+        print >>outfile, generate(args)
     if options.depend:
         ensureParentDir(options.depend)
         with open(options.depend, 'w') as depfile:
-            depfile.write("{0} : {1}\n".format(options.output, 
-                                               ' '.join(ExpandLibsDeps(args))))
+            depfile.write("%s : %s\n" % (options.output, ' '.join(ExpandLibsDeps(args))))