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

Project created through start script doesn't build in nix shell #2203

Open
jonathanlking opened this issue Jun 10, 2024 · 4 comments
Open

Project created through start script doesn't build in nix shell #2203

jonathanlking opened this issue Jun 10, 2024 · 4 comments

Comments

@jonathanlking
Copy link

Describe the bug

Trying to build the example project generated with the start script fails.

To Reproduce

I have used a pure nix shell to try and rule out any local setup on my machine.

flake.nix
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-23.11";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: {
    devShells.default = let
      pkgs = import nixpkgs { inherit system; };
    in pkgs.mkShell {
      buildInputs = [
        pkgs.bazel
        pkgs.curl
      ];
    };
  });
}
$ mkdir example && cd example
$ # copy flake.nix into directory
$ nix develop -i
$ sh <(curl https://raw.githubusercontent.com/tweag/rules_haskell/master/start)
$ bazel run //:example
Error
Starting local Bazel server and connecting to it...
Loading: 
Loading: 
Loading: 0 packages loaded
Analyzing: target //:example (1 packages loaded, 0 targets configured)
DEBUG: /home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/external/rules_haskell/haskell/cabal.bzl:2390:10: Stack not found.
DEBUG: /home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/external/rules_haskell/haskell/cabal.bzl:2391:10: Downloading Stack 2.7.5 ...
Analyzing: target //:example (43 packages loaded, 137 targets configured)
Analyzing: target //:example (43 packages loaded, 137 targets configured)
Analyzing: target //:example (44 packages loaded, 137 targets configured)
Analyzing: target //:example (44 packages loaded, 137 targets configured)
Analyzing: target //:example (44 packages loaded, 137 targets configured)
INFO: Analyzed target //:example (62 packages loaded, 10937 targets configured).
 checking cached actions
INFO: Found 1 target...
[0 / 54] [Prepa] action 'SolibSymlink _solib_k8/external_Srules_Uhaskell_Ughc_Ulinux_Uamd64/libHStemplate-haskell-2.19.0.0-ghc9.4.6.so'
[59 / 63] HaskellCabalLibrary @stackage//:zlib; 0s linux-sandbox
ERROR: /home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/external/stackage/BUILD.bazel:12:22: HaskellCabalLibrary @stackage//:zlib failed: (Exit 1): cabal_wrapper failed: error executing command (from target @stackage//:zlib) bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cabal_wrapper bazel-out/k8-fastbuild/bin/external/stackage/zlib_cabal_wrapper_args.json

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Traceback (most recent call last):
  File "/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/runghc.runfiles/rules_haskell/haskell/runghc.py", line 9, in <module>
    subprocess.run([r.Rlocation("rules_haskell_ghc_linux_amd64/bin/runghc")] + sys.argv[1:], check=True)
  File "/nix/store/ffy6s77zhixlwvzprz5j0zj4ma8n8h2q-python3-3.11.8/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/runghc.runfiles/rules_haskell_ghc_linux_amd64/bin/runghc', '/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/Setup.hs', 'configure', 'lib:zlib', '--verbose=0', '--user', '--with-compiler=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/external/rules_haskell_ghc_linux_amd64/bin/ghc', '--with-hc-pkg=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/external/rules_haskell_ghc_linux_amd64/bin/ghc-pkg', '--with-hsc2hs=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/external/rules_haskell_ghc_linux_amd64/bin/hsc2hs', '--with-ar=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/ar', '--with-gcc=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--with-ld=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/ld', '--with-strip=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/strip', '--enable-deterministic', '--ghc-option=-pgma', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgmc', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgml', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgmP', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python -E -undef -traditional', '--ghc-option=-optc-fno-stack-protector', '--ghc-option=-pgml-supports-no-pie', '--ghc-option=-pgmlm', '--ghc-option=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/ld', '--ghc-option=-optlm', '--ghc-option=-r', '--hsc2hs-option=-c/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--hsc2hs-option=-l/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--enable-relocatable', '--builddir=../../../bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/zlib-0.6.3.0', '--prefix=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install', '--libdir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_iface', '--dynlibdir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/lib', '--libsubdir=', '--bindir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/bin', '--datadir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_data', '--datasubdir=', '--haddockdir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_haddock', '--htmldir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_haddock_html', '--package-db=clear', '--package-db=global', '--flags=-pkg-config', '--ghc-option=-w', '--ghc-option=-optF=-w', '--ghc-option=-optl-Wl,-rpath,$ORIGIN/../../../../../_solib_k8/external_Srules_Uhaskell_Ughc_Ulinux_Uamd64', '--ghc-option=-optl-Wl,-rpath,$ORIGIN/../../../../../_solib_k8/[email protected]_S_S_Czlib___Uexternal_Szlib.dev', '--extra-include-dirs=../../../external/zlib.dev', '--extra-include-dirs=../../../bazel-out/k8-fastbuild/bin/external/zlib.dev', '--extra-lib-dirs=../../../bazel-out/k8-fastbuild/bin/_solib_k8/[email protected]_S_S_Czlib___Uexternal_Szlib.dev', '--package-db=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0.conf.d']' died with <Signals.SIGSEGV: 11>.
Traceback (most recent call last):
  File "/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cabal_wrapper.runfiles/rules_haskell/haskell/private/cabal_wrapper.py", line 301, in <module>
    run([runghc] + runghc_args + [setup, "configure", \
  File "/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cabal_wrapper.runfiles/rules_haskell/haskell/private/cabal_wrapper.py", line 69, in run
    subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, *args, **kwargs)
  File "/nix/store/ffy6s77zhixlwvzprz5j0zj4ma8n8h2q-python3-3.11.8/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/runghc', '/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/Setup.hs', 'configure', 'lib:zlib', '--verbose=0', '--user', '--with-compiler=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/external/rules_haskell_ghc_linux_amd64/bin/ghc', '--with-hc-pkg=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/external/rules_haskell_ghc_linux_amd64/bin/ghc-pkg', '--with-hsc2hs=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/external/rules_haskell_ghc_linux_amd64/bin/hsc2hs', '--with-ar=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/ar', '--with-gcc=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--with-ld=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/ld', '--with-strip=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/strip', '--enable-deterministic', '--ghc-option=-pgma', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgmc', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgml', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgmP', '--ghc-option=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python -E -undef -traditional', '--ghc-option=-optc-fno-stack-protector', '--ghc-option=-pgml-supports-no-pie', '--ghc-option=-pgmlm', '--ghc-option=/nix/store/shdkxxdlpv66wl33rh9d01zfypaka1dn-gcc-wrapper-12.3.0/bin/ld', '--ghc-option=-optlm', '--ghc-option=-r', '--hsc2hs-option=-c/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--hsc2hs-option=-l/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/cc_wrapper-python', '--enable-relocatable', '--builddir=../../../bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/zlib-0.6.3.0', '--prefix=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install', '--libdir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_iface', '--dynlibdir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/lib', '--libsubdir=', '--bindir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/bin', '--datadir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_data', '--datasubdir=', '--haddockdir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_haddock', '--htmldir=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0_haddock_html', '--package-db=clear', '--package-db=global', '--flags=-pkg-config', '--ghc-option=-w', '--ghc-option=-optF=-w', '--ghc-option=-optl-Wl,-rpath,$ORIGIN/../../../../../_solib_k8/external_Srules_Uhaskell_Ughc_Ulinux_Uamd64', '--ghc-option=-optl-Wl,-rpath,$ORIGIN/../../../../../_solib_k8/[email protected]_S_S_Czlib___Uexternal_Szlib.dev', '--extra-include-dirs=../../../external/zlib.dev', '--extra-include-dirs=../../../bazel-out/k8-fastbuild/bin/external/zlib.dev', '--extra-lib-dirs=../../../bazel-out/k8-fastbuild/bin/_solib_k8/[email protected]_S_S_Czlib___Uexternal_Szlib.dev', '--package-db=/home/jonathan/.cache/bazel/_bazel_jonathan/7c28c4ae27345253884c3695ec67b112/sandbox/linux-sandbox/19/execroot/YOUR_PROJECT_NAME_HERE/bazel-out/k8-fastbuild/bin/external/stackage/zlib-0.6.3.0/_install/zlib-0.6.3.0.conf.d']' returned non-zero exit status 1.
Target //:example failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 83.659s, Critical Path: 1.32s
INFO: 60 processes: 42 internal, 18 linux-sandbox.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target

Expected behavior

The build to succeed.

Environment

  • OS name + version: Ubuntu 22.04.4 LTS
  • Bazel version: 6.4.0
  • Version of the rules: v0.19

Additional context

  • Using sh <(curl https://haskell.build/start) (rather than the script in the repo) makes no difference.
  • The project generated with --with-bzlmod=true also fails.
  • The project generated with --use-nix succeeds.
@jonathanlking
Copy link
Author

Apologies if I'm doing something very obviously wrong/stupid, but I've stared at the error message for a while now and it isn't making much sense to me!

@avdv
Copy link
Member

avdv commented Jun 11, 2024

Hi @jonathanlking,

I can reproduce the issue inside of the nix dev shell. This seems to be a problem with ghc using the glibc from nix:

# gdb /root/.cache/bazel/_bazel_root/35a3e53a80b7147c6d4c8f9a2593f914/external/rules_haskell_ghc_linux_amd64/lib/bin/ghc
(No debugging symbols found in /root/.cache/bazel/_bazel_root/35a3e53a80b7147c6d4c8f9a2593f914/external/rules_haskell_ghc_linux_amd64/lib/bin/ghc)
(gdb) run --interactive                                                               
Starting program: /root/.cache/bazel/_bazel_root/35a3e53a80b7147c6d4c8f9a2593f914/external/rules_haskell_ghc_linux_amd64/lib/bin/ghc --interactive
warning: Error disabling address space randomization: Function not implemented
[Thread debugging using libthread_db enabled]                                
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7e4e84800640 (LWP 145212)]                                              
[New Thread 0x7e4e83e00640 (LWP 145213)]                                              
[New Thread 0x7e4e83400640 (LWP 145214)]                                              
[New Thread 0x7e4e82a00640 (LWP 145215)]                                              
GHCi, version 9.4.6: https://www.haskell.org/ghc/  :? for help
[Detaching after vfork from child process 145216]                                                                                                                            
[Detaching after vfork from child process 145221]                              
                                                                                      
Thread 1 "ghc" received signal SIGSEGV, Segmentation fault.                           
0x0000000000027e70 in ?? ()                                                           
(gdb) bt                                                                              
#0  0x0000000000027e70 in ?? ()                                                                                                                                              
#1  0x00007e4e8d9b547e in call_init (l=<optimized out>, argc=argc@entry=2, argv=argv@entry=0x7ffcf5074f58, env=env@entry=0x7ffcf5074f70) at ./elf/dl-init.c:70
#2  0x00007e4e8d9b5568 in call_init (env=0x7ffcf5074f70, argv=0x7ffcf5074f58, argc=2, l=<optimized out>) at ./elf/dl-init.c:33
#3  _dl_init (main_map=0x2123430, argc=2, argv=0x7ffcf5074f58, env=0x7ffcf5074f70) at ./elf/dl-init.c:117                                   
#4  0x00007e4e8560daf5 in __GI__dl_catch_exception (exception=<optimized out>, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:182
#5  0x00007e4e8d9bcff6 in dl_open_worker (a=0x7ffcf50704f0) at ./elf/dl-open.c:808
#6  dl_open_worker (a=a@entry=0x7ffcf50704f0) at ./elf/dl-open.c:771
#7  0x00007e4e8560da98 in __GI__dl_catch_exception (exception=<optimized out>, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:208
#8  0x00007e4e8d9bd34e in _dl_open (file=<optimized out>, mode=-2147483647, caller_dlopen=0x7e4e857c4adb <internal_dlopen+43>, nsid=-2, argc=2, argv=<optimized out>, 
    env=0x7ffcf5074f70) at ./elf/dl-open.c:883       
#9  0x00007e4e8552963c in dlopen_doit (a=a@entry=0x7ffcf5070760) at ./dlfcn/dlopen.c:56
#10 0x00007e4e8560da98 in __GI__dl_catch_exception (exception=exception@entry=0x7ffcf50706c0, operate=<optimized out>, args=<optimized out>)                                 
    at ./elf/dl-error-skeleton.c:208                                                                                                                                         
#11 0x00007e4e8560db63 in __GI__dl_catch_error (objname=0x7ffcf5070718, errstring=0x7ffcf5070720, mallocedp=0x7ffcf5070717, operate=<optimized out>, args=<optimized out>)
    at ./elf/dl-error-skeleton.c:227     
#12 0x00007e4e8552912e in _dlerror_run (operate=<optimized out>, args=<optimized out>) at ./dlfcn/dlerror.c:138                                                              
#13 0x00007e4e855296c8 in dlopen_implementation (dl_caller=<optimized out>, mode=1, 
    file=0x7ffcf50707f8 "/nix/store/j0by58xwyc66f884x0q8rpzvgpwvjmf2-glibc-2.38-77/lib/libc.so.6") at ./dlfcn/dlopen.c:71
#14 ___dlopen (file=file@entry=0x7ffcf50707f8 "/nix/store/j0by58xwyc66f884x0q8rpzvgpwvjmf2-glibc-2.38-77/lib/libc.so.6", mode=mode@entry=1) at ./dlfcn/dlopen.c:81
#15 0x00007e4e857c4adb in internal_dlopen (dll_name=0x7ffcf50707f8 "/nix/store/j0by58xwyc66f884x0q8rpzvgpwvjmf2-glibc-2.38-77/lib/libc.so.6") at rts/Linker.c:601
#16 0x00007e4e857c5557 in addDLL (dll_name=<optimized out>) at rts/Linker.c:769                                                                                              
#17 0x00007e4e87be92c7 in ghcizm9zi4zi6_GHCiziObjLink_czuaddDLL_info ()                                                                                                      
   from /root/.cache/bazel/_bazel_root/35a3e53a80b7147c6d4c8f9a2593f914/external/rules_haskell_ghc_linux_amd64/lib/bin/../lib/x86_64-linux-ghc-9.4.6/libHSghci-9.4.6-ghc9.4.6
.so                                                                                   
#18 0x0000004200419498 in ?? ()                                                                                                                                              
#19 0x0000000000000000 in ?? ()

Setting LD_LIBRARY_PATH helps a bit, but fails later with a different error:

# LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/ $(bazel info output_base)/external/rules_haskell_ghc_linux_amd64/lib/bin/ghc --interactive
GHCi, version 9.4.6: https://www.haskell.org/ghc/  :? for help
/nix/store/yisjp6hkqc1qz8lmgnc0dklx0hgg9w2x-bash-5.2-p15/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.36' not found (required by /nix/store/yisjp6hkqc1qz8lmgnc0dklx0hgg9w2x-bash-5.2-p15/bin/bash)
/nix/store/yisjp6hkqc1qz8lmgnc0dklx0hgg9w2x-bash-5.2-p15/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /nix/store/yisjp6hkqc1qz8lmgnc0dklx0hgg9w2x-bash-5.2-p15/bin/bash)
`gcc' failed in phase `gcc'. (Exit code: 1)

It seems running ghc from a bindist is not really supported inside of a nix shell... (at least when you want to mix toolchains from the system and ones from nix)

@jonathanlking
Copy link
Author

@avdv thank you so much for the investigation and explanation 🙏

I think this might be a case of "user error", rather than an issue with rules_haskell, so maybe it's fine to close?
If you think there's a good place to document this, I'd happily open a PR, but hopefully this issue will provide some context if anyone runs into the same problem 🤞.

@jonathanlking jonathanlking changed the title Project created through start script doesn't build Project created through start script doesn't build in nix shell Jun 11, 2024
@avdv
Copy link
Member

avdv commented Jun 13, 2024

I think this might be a case of "user error", rather than an issue with rules_haskell, so maybe it's fine to close?

Yes, I think there is not much we can do in rules_haskell in this case, but the compiler should not crash. Maybe it is just a bad combination of glibc versions / incompatible libraries that causes it...

In general, it would be desirable that this works but combining non-nix ghc with nix provided tools is definitely in the not-well-tested area. Lets keep this open to have it visible for others trying the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants