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

[WIP] Start fix of --experimental_use_sandboxfs #1298

Closed
wants to merge 1 commit into from

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Apr 2, 2020

Fixes #1265

This draft PR starts implementing the solution drafted by @aherrmann in #1265 (comment) to make --experimental_use_sandboxfs work when using bindists (no NixOS, no nix-shell context). Let me record that the intended setup to test this PR is described here.

It fixes the issue that executables - within ghc's install bin directory - need content in the sibling lib directory. Because this content is not tracked precisely right now, it is missing when executing within sandboxfs with --experimental_use_sandboxfs (see bazel+sandboxfs usage).

The first commit fixes failures of the form ../lib/path being missing. I made a checkpoint here because with this commit, bazel test //tests/... now fails in a different manner:

  File "bazel-out/host/bin/haskell/cc_wrapper-python", line 111, in FindModuleSpace
    raise AssertionError('Cannot find .runfiles directory for %s' % sys.argv[0])
AssertionError: Cannot find .runfiles directory for bazel-out/host/bin/haskell/cc_wrapper-python
compiling bazel-out/k8-fastbuild/bin/tests/library-with-cbits/_hsc/library-with-cbits-static/AddOne_hsc_make.c failed (exit code 1)
command was: bazel-out/host/bin/haskell/cc_wrapper-python -c bazel-out/k8-fastbuild/bin/tests/library-with-cbits/_hsc/library-with-cbits-static/AddOne_hsc_make.c -o bazel-out/k8-fastbuild/bin/tests/library-with-cbits/_hsc/library-with-cbits-static/AddOne_hsc_make.o -fno-stack-protector -iquote . -iquote bazel-out/k8-fastbuild/bin -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" -Iexternal/rules_haskell_ghc_linux_amd64/bin/../lib/include/

And here's one specific failure when running bazel test --experimental_use_sandboxfs --sandbox_debug //tests/cc_haskell_import/...:

ERROR: /media/crypt1/repos/rules_haskell/rules_haskell_1265_alt/tests/cc_haskell_import/BUILD.bazel:19:1: HaskellBuildLibrary //tests/cc_haskell_import:hs-lib-b failed (Exit 1) linux-sandbox failed: error executing command 
  (cd /home/churlin/.cache/bazel/_bazel_churlin/31b8c33fa4dcf9eee06a0a8329314f3e/sandbox/sandboxfs/75 && \
  exec env - \
    LANG=C.UTF-8 \
    TMPDIR=/tmp \
  /home/churlin/.cache/bazel/_bazel_churlin/install/d687aca87a7669724cc958527f2423da/linux-sandbox -t 15 -w /home/churlin/.cache/bazel/_bazel_churlin/31b8c33fa4dcf9eee06a0a8329314f3e/sandbox/linux-sandbox/80/execroot/rules_haskell -w /tmp -w /dev/shm -D -- bazel-out/host/bin/haskell/ghc_wrapper bazel-out/k8-fastbuild/bin/tests/cc_haskell_import/compile_flags_hs-lib-b_HaskellBuildLibrary bazel-out/k8-fastbuild/bin/tests/cc_haskell_import/extra_args_hs-lib-b_HaskellBuildLibrary)
...
tests/cc_haskell_import/LibB_stub.h: openFile: permission denied (Permission denied)

@smelc smelc requested a review from aherrmann April 2, 2020 15:41
@@ -105,11 +106,13 @@ def _haskell_toolchain_impl(ctx):
if not tool in ghc_binaries:
fail("Cannot find {} in {}".format(tool, ctx.attr.tools.label))

full_ghc = depset(transitive = [x.files for x in ctx.attr.full_ghc])
Copy link
Member

Choose a reason for hiding this comment

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

@aherrmann
Copy link
Member

The first commit fixes failures of the form ../lib/path being missing. I made a checkpoint here because with this commit, bazel test //tests/... now fails in a different manner:

  File "bazel-out/host/bin/haskell/cc_wrapper-python", line 111, in FindModuleSpace
    raise AssertionError('Cannot find .runfiles directory for %s' % sys.argv[0])
AssertionError: Cannot find .runfiles directory for bazel-out/host/bin/haskell/cc_wrapper-python
compiling bazel-out/k8-fastbuild/bin/tests/library-with-cbits/_hsc/library-with-cbits-static/AddOne_hsc_make.c failed (exit code 1)
command was: bazel-out/host/bin/haskell/cc_wrapper-python -c bazel-out/k8-fastbuild/bin/tests

That's interesting. This indicates that the cc_wrapper's runfiles are not included in the sandbox. If you haven't, yet, I recommend reading the runfiles guide to get a good understanding of them.

@smelc
Copy link
Contributor Author

smelc commented Apr 20, 2020

Closing request as it's not planned for me to have time allocated to continue this work in the near future.

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.

rules_haskell fails when using docker sandbox (and --experimental_use_sandboxfs)
2 participants