Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions haskell/private/cabal_wrapper.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,16 @@ def tmpdir():
# Executables are placed into `<distdir>/build/<package-name>/<binary>`.
# Libraries are placed into `<distdir>/build/<library>`. I.e. there is an
# extra subdirectory for libraries.
if component.startswith("exe:"):
distdir = tempfile.mkdtemp(dir=os.path.dirname(os.path.dirname(pkgroot)))
#
# On Windows we don't do dynamic linking and prefer shorter paths to avoid
# exceeding `MAX_PATH`.
if "%{is_windows}" == "True":
distdir = tempfile.mkdtemp()
else:
distdir = tempfile.mkdtemp(dir=os.path.dirname(pkgroot))
if component.startswith("exe:"):
distdir = tempfile.mkdtemp(dir=os.path.dirname(os.path.dirname(pkgroot)))
else:
distdir = tempfile.mkdtemp(dir=os.path.dirname(pkgroot))
try:
yield distdir
finally:
Expand All @@ -140,6 +146,7 @@ with tmpdir() as distdir:
# absolute ones before doing so (using $execroot).
old_cwd = os.getcwd()
os.chdir(srcdir)
os.putenv("RULES_HASKELL_EXEC_ROOT", old_cwd)
os.putenv("HOME", "/var/empty")
os.putenv("TMPDIR", os.path.join(distdir, "tmp"))
os.putenv("TMP", os.path.join(distdir, "tmp"))
Expand All @@ -165,7 +172,7 @@ with tmpdir() as distdir:
# absolute paths refer the temporary directory that GHC uses for
# intermediate template Haskell outputs. `cc_wrapper` should improved
# in that regard.
"--builddir=" + os.path.relpath(distdir), \
"--builddir=" + (os.path.relpath(distdir) if "%{is_windows}" != "True" else distdir), \
"--prefix=" + pkgroot, \
"--libdir=" + libdir, \
"--dynlibdir=" + dynlibdir, \
Expand Down
10 changes: 5 additions & 5 deletions haskell/private/cc_wrapper.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -711,17 +711,17 @@ def find_solib_rpath(rpaths, output):
"""
for rpath in rpaths:
components = rpath.replace("\\", "/").split("/")
solib_rpath = []
solib_rpath = ""
for comp in components:
solib_rpath.append(comp)
if comp.startswith("_solib_"):
return "/".join(solib_rpath)
solib_rpath = os.path.join(solib_rpath, comp)
if comp.startswith("_solib_") and os.path.isdir(resolve_rpath(solib_rpath, output)[1]):
return solib_rpath

if is_temporary_output(output):
# GHC generates temporary libraries outside the execroot. In that case
# the Bazel generated RPATHs are not forwarded, and the solib directory
# is not visible on the command-line.
for (root, dirnames, _) in breadth_first_walk("."):
for (root, dirnames, _) in breadth_first_walk(os.environ.get("RULES_HASKELL_EXEC_ROOT", ".")):
if "_solib_{:cpu:}" in dirnames:
return os.path.join(root, "_solib_{:cpu:}")

Expand Down