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

Unable to compile Bisons/Flex benchmarks #5

Open
ju1m opened this issue Sep 2, 2020 · 8 comments
Open

Unable to compile Bisons/Flex benchmarks #5

ju1m opened this issue Sep 2, 2020 · 8 comments

Comments

@ju1m
Copy link
Contributor

ju1m commented Sep 2, 2020

Looks like C files listed in:
https://github.com/J-mie6/ParsleyHaskell/blob/a20a8a6ad1c266b4eb3e5f3c3cb72be3daf1e6de/parsley.cabal#L51
are missing or voluntarily not committed in the git repository.
I thus naïvely tried to generate them manually like so:

cd benchmarks/Bisons/
flex Nandlang.l
bison -d Nandlang.y # -d also generates Nandlang.tab.h

However, when compiling benchmarks I hit this error:

$ nix -L run .#benchmarks
[…]
  ghc: panic! (the 'impossible' happened)
    (GHC version 8.6.5 for x86_64-unknown-linux):
        Loading temp shared object failed: /build/ghc396_0/libghc_5.so: undefined symbol: yylex

Should I add some pkgconfig-depends: or extra-libraries: because some C lib is missing?
Or is it related to haskell/cabal#5623 ? But then how could it have ever worked?
Anyway, everything works as expected after removing this problematic benchmark: https://github.com/J-mie6/ParsleyHaskell/blob/a20a8a6ad1c266b4eb3e5f3c3cb72be3daf1e6de/benchmarks/Benchmarks.hs#L189

Thanks for this amazing library.

My current hacky flake.nix to reproduce if need be:

{
# Update inputs with:
# nix flake update --recreate-lock-file
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.haskell-nix.url = "github:input-output-hk/haskell.nix";
inputs.all-hies.url = "github:infinisil/all-hies";
inputs.all-hies.flake = false;
outputs = inputs: let
  projectName = "parsley";
  in inputs.flake-utils.lib.eachDefaultSystem (system: let
    #pkgs = inputs.haskell-nix.legacyPackages.${system};
    pkgs = import inputs.haskell-nix.sources.nixpkgs (inputs.haskell-nix.nixpkgsArgs // {
      localSystem = { inherit system; };
      overlays = inputs.haskell-nix.nixpkgsArgs.overlays ++ [
        (import inputs.all-hies {}).overlay
        (self: super: {
          fl = self.flex;
        })
      ];
    });
    compiler-nix-name = "ghc865";
    project = pkgs.haskell-nix.cabalProject {
      src = pkgs.haskell-nix.haskellLib.cleanGit {
        name = projectName;
        src = ./.;
      };
      inherit compiler-nix-name;
      index-state = "2020-08-28T00:00:00Z";
      # To be kept up to date with source-repository-package entries in cabal.project
      sha256map = {
        "https://github.com/J-mie6/lift-plugin.git"."e7bf0b4ee361a17c55170ce234a5542544625991" =
          "kLw6EjBApspjMs9kC+2Jl9sIgTnM/wfO+iADElpTfa0=";
        "https://github.com/J-mie6/idioms-plugins.git"."1ca37d047d5c8568bee6caf5a506995cd53265f5" =
          "PoBllnC7Q2S+cKriqjGR58QsA0GvrZ8R8h7GWHsZyxc=";
      };
      # Update by commenting materialized and running:
      # nix run .#materialize
      #materialized = ./plan-nix;
    };
    in {
    # Build with: nix build
    defaultPackage = project.${projectName}.components.exes."playground";
    #packages.${projectName} = project;
    # Run with: nix run .#benchmarks -- --output=benchmarks.html
    apps."benchmarks" = {
      type = "app";
      program = "${project.${projectName}.components.exes."benchmarks"}/bin/benchmarks";
    };
    # Run with: nix run .#playground
    apps."playground" = {
      type = "app";
      program = "${inputs.self.defaultPackage.${system}}/bin/playground";
    };
    # Run with: nix run .#materialize
    apps.materialize = {
      type = "app";
      program = (pkgs.writeShellScript "materialize" ''
        ${pkgs.rsync}/bin/rsync --delete -ai ${project.plan-nix}/ plan-nix/
      '').outPath;
    };
    # Run with: nix run .#register
    apps.register = {
      type = "app";
      program = (pkgs.writeShellScript "register" ''
        set -x
        nix-store --add-root nix.root --indirect --realise ${project.roots}
      '').outPath;
    };
    # Get a development environment with: nix develop
    devShell = project.shellFor {
      packages = hpkgs: [
        hpkgs."${projectName}"
      ];
      #components = hpkgs: [];
      #additional = hpkgs: [];
      withHoogle = false;
      tools = {
        cabal = "3.2.0.0";
        #hie = "unstable";
        #hlint = "2.2.11";
      };
      builtInputs = with project.haskellPackages; [
      ];
      exactDeps = true;
      shellHook = ''
      '';
    };
    }
  );
}
@j-mie6
Copy link
Owner

j-mie6 commented Sep 2, 2020

Yeah, they are voluntarily left out, because I consider it bad form to keep them in the repo when they are essentially "precompiled" files. I've forgotten the exact commands I used to generate my lex.yy.c, Nandlang.tab.c and Nandlang.tab.h files, but I can find that out for you later. I'm not sure if a c lib is missing for you or not I'm afraid. It's a shame I couldn't figure out how to make cabal generate them for me!

@knothed
Copy link

knothed commented Nov 12, 2021

Is there a solution already? I get the following error after generating the c and h files with bison and lex:

ghc: panic! (the 'impossible' happened)
  (GHC version 8.6.5 for x86_64-unknown-linux):
	Loading temp shared object failed: /run/user/29829/ghc19759_0/libghc_1.so: undefined symbol: set_input_string

@j-mie6
Copy link
Owner

j-mie6 commented Nov 13, 2021

I don't know what would cause that: I would just recommend disabling the nandlang benchmarks in the cabal file.

@j-mie6
Copy link
Owner

j-mie6 commented Nov 13, 2021

(Also as an aside, I would recommend upgrading to 8.10+ when running benchmarks, the Parsley backend for 8.10+ has way more in the way of optimisations and general optimisation stability compared with 8.8-)

@knothed
Copy link

knothed commented Nov 13, 2021

Okay I’ll try upgrading GHC. But I would actually like to run the Nandland benchmarks, so disabling them is not an option for me :D

@j-mie6
Copy link
Owner

j-mie6 commented Nov 13, 2021

very well, try the prebuilt-bison branch: I've added my pregenerated bison binaries there.

@knothed
Copy link

knothed commented Nov 17, 2021

Thank you! It still doesn't seem to work with GHC 8.6.5... I'll need to upgrade then probably.

@j-mie6
Copy link
Owner

j-mie6 commented Nov 17, 2021

that's strange, it works for 8.6.5 for me (with those generated files)! It looks like set_input_string is included in lex.yy.c, and is needed by Nandlang.tab.c. Perhaps you need to update your cabal as well, which might not be linking the files properly?

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

No branches or pull requests

3 participants