mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
f4d0eb636e
* Unmangled libz.so and libbz2.so * Use stack_snapshot instead of Hazel * Remove Hazel * Define stack_snapshot * Update rules_haskell * Document stack_snapshot * Clean stack's lock file from aborted builds
77 lines
3.0 KiB
Diff
77 lines
3.0 KiB
Diff
Work around build errors of ghc-lib due to missing libraries during template
|
|
Haskell on macOS. GHC doesn't forward the regular rpath flags in that case, and
|
|
we need to fall back to the library search paths to rewrite the load commands.
|
|
Upstream to rules_haskell and remove this patch.
|
|
diff --git a/haskell/private/cc_wrapper.py.tpl b/haskell/private/cc_wrapper.py.tpl
|
|
index 2fb4ec73..5ca79712 100644
|
|
--- a/haskell/private/cc_wrapper.py.tpl
|
|
+++ b/haskell/private/cc_wrapper.py.tpl
|
|
@@ -59,7 +59,7 @@ def main():
|
|
parsed = Args(load_response_files(sys.argv[1:]))
|
|
|
|
if parsed.linking:
|
|
- link(parsed.output, parsed.libraries, parsed.rpaths, parsed.args)
|
|
+ link(parsed.output, parsed.libraries, parsed.rpaths, parsed.library_paths, parsed.args)
|
|
elif parsed.printing_file_name:
|
|
print_file_name(parsed.print_file_name, parsed.args)
|
|
else:
|
|
@@ -419,13 +419,14 @@ def rpath_args(rpaths):
|
|
# Link binary or library
|
|
|
|
|
|
-def link(output, libraries, rpaths, args):
|
|
+def link(output, libraries, rpaths, library_paths, args):
|
|
"""Execute the link action.
|
|
|
|
Args:
|
|
output: The output binary or library.
|
|
libraries: Library dependencies.
|
|
rpaths: The provided rpaths.
|
|
+ library_paths: The provided library search paths.
|
|
args: The command-line arguments.
|
|
|
|
"""
|
|
@@ -433,7 +434,7 @@ def link(output, libraries, rpaths, args):
|
|
# Reserve space in load commands for later replacement.
|
|
args.append("-headerpad_max_install_names")
|
|
rpaths, darwin_rewrites = darwin_shorten_rpaths(
|
|
- rpaths, libraries, output)
|
|
+ rpaths, library_paths, libraries, output)
|
|
else:
|
|
rpaths = shorten_rpaths(rpaths, libraries, output)
|
|
|
|
@@ -477,7 +478,7 @@ def shorten_rpaths(rpaths, libraries, output):
|
|
return required_rpaths
|
|
|
|
|
|
-def darwin_shorten_rpaths(rpaths, libraries, output):
|
|
+def darwin_shorten_rpaths(rpaths, library_paths, libraries, output):
|
|
"""Avoid redundant rpaths and adapt library load commands.
|
|
|
|
Avoids redundant rpaths by detecting the solib directory and making load
|
|
@@ -485,6 +486,7 @@ def darwin_shorten_rpaths(rpaths, libraries, output):
|
|
|
|
Args:
|
|
rpaths: List of given rpaths.
|
|
+ library_paths: List of given library search paths.
|
|
libraries: List of library dependencies.
|
|
output: The output binary, used to resolve rpaths.
|
|
|
|
@@ -495,6 +497,7 @@ def darwin_shorten_rpaths(rpaths, libraries, output):
|
|
|
|
"""
|
|
input_rpaths = sort_rpaths(rpaths)
|
|
+ input_library_paths = sort_rpaths(library_paths)
|
|
|
|
# Keeps track of libraries that were not yet found in an rpath.
|
|
libs_still_missing = set(libraries)
|
|
@@ -544,7 +547,7 @@ def darwin_shorten_rpaths(rpaths, libraries, output):
|
|
|
|
# For the remaining missing libraries, determine which rpaths are required.
|
|
# Iterate over the given rpaths until all libraries are found.
|
|
- for rpath in input_rpaths:
|
|
+ for rpath in input_rpaths + input_library_paths:
|
|
if not libs_still_missing:
|
|
break
|
|
rpath, rpath_dir = resolve_rpath(rpath, output)
|