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

Install GHC bindist in relocatable mode on Unix #853

Merged
merged 4 commits into from
May 2, 2019
Merged

Conversation

aherrmann
Copy link
Member

On Unix the GHC bindist requires to execute ./configure && make && make install. In its default configuration, it hard-codes the absolute path to the bindist installation dir into various places in the final bindist. This affects the hashes and thereby cache keys, as the absolute install path will likely differ on different machines. This patch builds the bindist in relocatable mode on Unix and patches the generated wrapper scripts to no longer hard-code the absolute installation path.

  • Pin the --libdir to EPREFIX/lib. On some platforms autotools defaults to EPREFIX/lib64, instead.
  • Patch the configure script to build in relocatable mode.
  • Patch the generated executable wrapper scripts to no longer hard-code the absolute path to the installation directory.

On some platforms autotools will instead default to EPREFIX/lib64. To
minimize differences in installed GHC bindists, we pin EPREFIX/lib.
Copy link
Member

@mboes mboes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 LGTM

_execute_fail_loudly(ctx, ["make", "install"])
ctx.file("patch_bins", executable=True, content="""#!/usr/bin/env bash
set -x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracing stuff should probably go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Sorry, overlooked that.

@@ -212,8 +212,20 @@ def _ghc_bindist_impl(ctx):

# On Windows the bindist already contains the built executables
if os != "windows":
_execute_fail_loudly(ctx, ["./configure", "--prefix", bindist_dir.realpath])
_execute_fail_loudly(ctx, ["sed", "-i", "s/RelocatableBuild = NO/RelocatableBuild = YES/", "mk/config.mk.in"])
_execute_fail_loudly(ctx, ["./configure", "--prefix", bindist_dir.realpath, "--libdir", "${exec_prefix}/lib"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does ${exec_prefix} come from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${exec_prefix} is defined within mk/install.mk. However, it turns out that ${exec_prefix}/lib is the default for RelocatableBuild = YES. So the --libdir flag is redundant. I've removed it.

- Configure Unix bindist to be relocatable.
- Patch bin wrapper scripts to not hard-code the execroot.
  This makes their cache key independent of platform details, like the
  path to the user's home directory.
`readlink -f` does not work on MacOS. Replace it by a cross platform
version.
`${exec_prefix}/lib` is the default in case of `RelocatableBuild = YES`.
@mboes mboes merged commit c98a445 into master May 2, 2019
@mboes mboes deleted the relocatable branch May 2, 2019 14:39
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.

2 participants