011-support-library-path-old-compilers.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. python3: do not rely only on LIBRARY_PATH for old compilers
  2. The cross-compilation improvements integrated in Python rely on the
  3. compiler exposing a line starting with LIBRARY_PATH when called with
  4. -E -v. This is used by Python setup.py to find the installation
  5. locations of libraries.
  6. However, this LIBRARY_PATH line is not shown by very old compilers,
  7. such as the gcc 4.2.x compiler used on the AVR32 architecture. This
  8. causes libraries installed in the sysroot, such as libffi, to not be
  9. detected by the setup.py script.
  10. To fix this problem, this patch adds addtional logic to setup.py,
  11. which consists in deriving the library paths from the sysroot
  12. location, if no LIBRARY_PATH field was found.
  13. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  14. Index: b/setup.py
  15. ===================================================================
  16. --- a/setup.py
  17. +++ b/setup.py
  18. @@ -427,6 +427,7 @@
  19. in_incdirs = False
  20. inc_dirs = []
  21. lib_dirs = []
  22. + compiler_has_library_path = False
  23. try:
  24. if ret >> 8 == 0:
  25. with open(tmpfile) as fp:
  26. @@ -438,6 +439,7 @@
  27. elif line.startswith("End of search list"):
  28. in_incdirs = False
  29. elif is_gcc and line.startswith("LIBRARY_PATH"):
  30. + compiler_has_library_path = True
  31. for d in line.strip().split("=")[1].split(":"):
  32. d = os.path.normpath(d)
  33. if '/gcc/' not in d:
  34. @@ -449,6 +451,15 @@
  35. finally:
  36. os.unlink(tmpfile)
  37. + if not compiler_has_library_path:
  38. + ret = os.system("%s -print-file-name=libc.a | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::' >%s" % (gcc, tmpfile))
  39. + with open(tmpfile) as fp:
  40. + line = fp.readline().strip()
  41. + add_dir_to_list(self.compiler.library_dirs,
  42. + os.path.join(line, "usr", "lib"))
  43. + add_dir_to_list(self.compiler.library_dirs,
  44. + os.path.join(line, "lib"))
  45. +
  46. def detect_modules(self):
  47. # Ensure that /usr/local is always used, but the local build
  48. # directories (i.e. '.' and 'Include') must be first. See issue