Skip to content

Commit

Permalink
fix mingw cross compiling in setup.py
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeremyd2019 authored and lazka committed Aug 25, 2023
1 parent a197f1d commit 3972f70
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,14 +807,25 @@ def add_cross_compiling_paths(self):
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)

Expand Down

0 comments on commit 3972f70

Please sign in to comment.