Skip to content

Commit 3972f70

Browse files
jeremyd2019lazka
authored andcommitted
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.
1 parent a197f1d commit 3972f70

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

setup.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,14 +807,25 @@ def add_cross_compiling_paths(self):
807807
elif line.startswith("End of search list"):
808808
in_incdirs = False
809809
elif (is_gcc or is_clang) and line.startswith("LIBRARY_PATH"):
810-
for d in line.strip().split("=")[1].split(":"):
810+
for d in line.strip().split("=")[1].split(os.pathsep):
811811
d = os.path.normpath(d)
812-
if '/gcc/' not in d:
812+
if '/gcc/' not in d and '/clang/' not in d:
813813
add_dir_to_list(self.compiler.library_dirs,
814814
d)
815815
elif (is_gcc or is_clang) and in_incdirs and '/gcc/' not in line and '/clang/' not in line:
816816
add_dir_to_list(self.compiler.include_dirs,
817817
line.strip())
818+
if is_clang:
819+
ret = run_command('%s -print-search-dirs >%s' % (CC, tmpfile))
820+
if ret == 0:
821+
with open(tmpfile) as fp:
822+
for line in fp.readlines():
823+
if line.startswith("libraries:"):
824+
for d in line.strip().split("=")[1].split(os.pathsep):
825+
d = os.path.normpath(d)
826+
if '/gcc/' not in d and '/clang/' not in d:
827+
add_dir_to_list(self.compiler.library_dirs,
828+
d)
818829
finally:
819830
os.unlink(tmpfile)
820831

0 commit comments

Comments
 (0)