Files
MINGW-packages/mingw-w64-python/0123-fix-mingw-cross-compiling-in-setup.py.patch
2022-03-18 15:48:33 +01:00

48 lines
2.3 KiB
Diff

From aa01d34ce3557e29dda2d614be2343f90bd20582 Mon Sep 17 00:00:00 2001
From: jeremyd2019 <github@jdrake.com>
Date: Mon, 22 Nov 2021 13:15:12 -0800
Subject: [PATCH 123/N] fix mingw cross compiling in setup.py
gcc outputs with `;` path delimiter on mingw, so use `os.pathsep` instead of `:` (assuming this is a host rather than target decision)
clang does not output `LIBRARY_PATH` with `-E -v`, so add an extra call to `-print-search-dirs` to find its library path.
---
setup.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index efc9ec7..6b0e709 100644
--- a/setup.py
+++ b/setup.py
@@ -715,14 +715,25 @@ class PyBuildExt(build_ext):
elif line.startswith("End of search list"):
in_incdirs = False
elif (is_gcc or is_clang) and line.startswith("LIBRARY_PATH"):
- for d in line.strip().split("=")[1].split(":"):
+ for d in line.strip().split("=")[1].split(os.pathsep):
d = os.path.normpath(d)
- if '/gcc/' not in d:
+ if '/gcc/' not in d and '/clang/' not in d:
add_dir_to_list(self.compiler.library_dirs,
d)
elif (is_gcc or is_clang) and in_incdirs and '/gcc/' not in line and '/clang/' not in line:
add_dir_to_list(self.compiler.include_dirs,
line.strip())
+ if is_clang:
+ ret = run_command('%s -print-search-dirs >%s' % (cc, tmpfile))
+ if ret == 0:
+ with open(tmpfile) as fp:
+ for line in fp.readlines():
+ if line.startswith("libraries:"):
+ for d in line.strip().split("=")[1].split(os.pathsep):
+ d = os.path.normpath(d)
+ if '/gcc/' not in d and '/clang/' not in d:
+ add_dir_to_list(self.compiler.library_dirs,
+ d)
finally:
os.unlink(tmpfile)
--
2.35.1