Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid absolute RUNPATH to rts in GHC bindist #1131

Merged
merged 3 commits into from Oct 23, 2019
Merged

Conversation

aherrmann
Copy link
Member

Closes #1127

Before, rules_haskell only carried the non-threaded runtime library (libHSrts) as a LibraryToLink, while the threaded runtime library (libHSrts_thr) was completely ignored. Therefore libHSrts_thr was missing in the sandbox when linking with -threaded and the cc_wrapper could not purge the absolute RUNPATH to the GHC bindist that GHC generates automatically.

This PR adds libHSrts_thr to the tracked libraries, so that cc_wrapper can purge the absolute RUNPATH entry.

To avoid duplicate runtime libraries haskell_toolchain_libraries_impl chooses whether to forward the threaded or non-threaded runtime library based on whether -threaded is in the toolchain's compiler_flags. Ideally, this should be configurable on a per-target basis using Bazel configurations and transitions. However, given that previously only the non-threaded version of the library was tracked, this is no worse than the previous situation and the switch to configurations can be handled in a separate PR.

@mboes mboes added the merge-queue merge on green CI label Oct 23, 2019
The Haskell runtime library `libHSrts` comes in several flavors, e.g.
the default `libHSrts` and the threaded version `libHSrts_thr`.
GHC will link against one or the other, depending on whether the target
is built with the `-threaded` compiler flag.

If Bazel only tracks `libHSrts`, but GHC links against `libHSrts_thr`,
then the Bazel controlled RUNPATH (`$ORIGIN/.../_solib_k8/...`) will not
contain the correct runtime library, and the `cc_wrapper` will not
remove the absolute RUNPATH `/path/to/.cache/.../lib/rts`, since it
won't be redundant.

This change extends `pkgdb_to_bzl.py` to include the `_thr` versions of
the runtime library (and `ffi`) so that Bazel will track them and the
`cc_wrapper` can remove the then redundant absolute RUNPATH.
@mergify mergify bot merged commit f8fadae into master Oct 23, 2019
@mergify mergify bot deleted the absolute-rts-path branch October 23, 2019 12:55
@mergify mergify bot removed the merge-queue merge on green CI label Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Absolute runpaths in ELF binaries
2 participants