compiler-rt fix for Python 3

Marcoen Hirschberg marcoen at gmail.com
Tue Dec 17 04:11:48 PST 2013


Hi there,

I tried to build LLVM with compiler-rt and got some errors because I'm
using python 3 (version 3.3.3)

  File
"/home/markun/src/llvm/projects/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py",
line 78
    print '{'
            ^
SyntaxError: invalid syntax

and

Traceback (most recent call last):
  File
"/home/markun/src/llvm/projects/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py",
line 85, in <module>
    main(sys.argv)
  File
"/home/markun/src/llvm/projects/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py",
line 51, in main
    all_functions = get_global_functions(library)
  File
"/home/markun/src/llvm/projects/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py",
line 38, in get_global_functions
    nm_out = nm_proc.communicate()[0].split('\n')
TypeError: Type str doesn't support the buffer API

I fixed them in the attached patch. I also tried building with python2
(2.7.6) and that still worked. Is it good enough for inclusion?

With regards,

Marcoen Hirschberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131217/6f455722/attachment.html>
-------------- next part --------------
diff --git a/lib/sanitizer_common/scripts/gen_dynamic_list.py b/lib/sanitizer_common/scripts/gen_dynamic_list.py
index 32ba922..b60c5b9 100755
--- a/lib/sanitizer_common/scripts/gen_dynamic_list.py
+++ b/lib/sanitizer_common/scripts/gen_dynamic_list.py
@@ -35,7 +35,7 @@ def get_global_functions(library):
   functions = []
   nm_proc = subprocess.Popen(['nm', library], stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
-  nm_out = nm_proc.communicate()[0].split('\n')
+  nm_out = nm_proc.communicate()[0].decode().split('\n')
   if nm_proc.returncode != 0:
     raise subprocess.CalledProcessError(nm_proc.returncode, 'nm')
   for line in nm_out:
@@ -75,11 +75,11 @@ def main(argv):
     for line in f:
       result.append(line.rstrip())
   # Print the resulting list in the format recognized by ld.
-  print '{'
+  print('{')
   result.sort()
   for f in result:
-    print '  ' + f + ';'
-  print '};'
+    print('  ' + f + ';')
+  print ('};')
 
 if __name__ == '__main__':
   main(sys.argv)


More information about the llvm-commits mailing list