runtimeverification / k

K Framework Tools 7.0
BSD 3-Clause "New" or "Revised" License
450 stars 149 forks source link

[K-Bug] nix build failure in KMIR #3879

Closed yanliu18 closed 7 months ago

yanliu18 commented 10 months ago

What component is the issue in?

llvm-backend

Which command

What K Version?

K version: v6.1.58 Build date: Thu Dec 14 03:41:52 CST 2023

Operating System

MacOS (Intel)

K Definitions (If Possible)

No response

Steps to Reproduce

Not sure if it is the right place to post, when attempt to build the bison parser using nix, it failed on my mac but succeeded in a linux machine. Another strange behaviour is it failed to print the build date when attempting to print kompile version in nix. It failed with an file not found error.

OS: ProductName: macOS ProductVersion: 12.7.1 BuildVersion: 21G920 Hardware: 3.3 GHz Dual-Core Intel Core i7

Steps to reproduce:

git checkout make-glr

- add `kompile --version` to below [line 69](https://github.com/runtimeverification/mir-semantics/blob/e7be9c372630b76f80ffb4136260d4d9cc943318/flake.nix#L69).

- run nix build locally with the following command under the same dir.
```sh
nix build . --extra-experimental-features 'nix-command flakes' --print-build-logs

Error log:

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/a8svqyp25mcqswz9i5i9mvr556ws45jx-kmir
source root is kmir
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
patching script interpreter paths in .
./check_k_version.sh: interpreter directive changed from "#!/usr/bin/env bash" to "/nix/store/k1fvf8l2ymiz9px5rw7msnbby>
./set_env.sh: interpreter directive changed from "#! /bin/bash" to "/nix/store/k1fvf8l2ymiz9px5rw7msnbbyb6bkgpj-bash-5.>
./src/tests/nix/nix-tests.sh: interpreter directive changed from "#!/usr/bin/env bash" to "/nix/store/k1fvf8l2ymiz9px5r>
./src/kmir/preprocessor.py: interpreter directive changed from "#!/usr/bin/env python3" to "/nix/store/c6bvvf2n4njczix1>
date: 1702496512: No such file or directory
K version:    v6.1.58
Build date:
rm -rf kdist/;
rm -rf dist .mypy_cache .pytest_cache
find . -type d -name __pycache__ -prune -exec rm -rf {} \;
./check_k_version.sh 6.1.58
date: 1702496512: No such file or directory
kbuild kompile llvm
/private/tmp/nix-build-kmir-dirty.drv-0/kmir/kdist/v6.1.58/llvm
kbuild kompile llvmc
/private/tmp/nix-build-kmir-dirty.drv-0/kmir/kdist/v6.1.58/llvmc
kbuild kompile haskell
/private/tmp/nix-build-kmir-dirty.drv-0/kmir/kdist/v6.1.58/haskell
INFO 2023-12-15 07:18:40,698 kmir.__main__ - Generating GLR parser
INFO 2023-12-15 07:18:40,699 pyk.ktool.kprint - Running: kast /private/tmp/nix-build-kmir-dirty.drv-0/kmir/kdist/v6.1.5>
[Error] Internal: bison returned nonzero exit code: 141
INFO 2023-12-15 07:18:48,317 pyk.ktool.kprint - Completed in 7.617s with status 113: kast /private/tmp/nix-build-kmir-d>
Traceback (most recent call last):
  File "/nix/store/6i75pxvw1lg010y7lnmcadvzbq5l8lf6-python3.10-pyk-0.1.546/lib/python3.10/site-packages/pyk/ktool/kprin>
    return run_process(args, logger=_LOGGER, check=check)
  File "/nix/store/6i75pxvw1lg010y7lnmcadvzbq5l8lf6-python3.10-pyk-0.1.546/lib/python3.10/site-packages/pyk/utils.py", >
    res.check_returncode()
  File "/nix/store/c6bvvf2n4njczix12gimwpi4hx0rnk1l-python3-3.10.13/lib/python3.10/subprocess.py", line 457, in check_r>
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '('kast', '/private/tmp/nix-build-kmir-dirty.drv-0/kmir/kdist/v6.1.58/llvm/parse>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/nix/store/m1nlgyhq4c6ailka0742mkdmlc1g0d86-python3.10-kmir-0.2.11/bin/.kmir-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/m1nlgyhq4c6ailka0742mkdmlc1g0d86-python3.10-kmir-0.2.11/lib/python3.10/site-packages/kmir/__main__.p>
    execute(**vars(args))
  File "/nix/store/m1nlgyhq4c6ailka0742mkdmlc1g0d86-python3.10-kmir-0.2.11/lib/python3.10/site-packages/kmir/__main__.p>
    gen_glr_parser(mir_parser, definition_dir=llvm_dir, module='MIR-SYNTAX', sort='Mir')
  File "/nix/store/6i75pxvw1lg010y7lnmcadvzbq5l8lf6-python3.10-pyk-0.1.546/lib/python3.10/site-packages/pyk/ktool/kprin>
    _kast(
  File "/nix/store/6i75pxvw1lg010y7lnmcadvzbq5l8lf6-python3.10-pyk-0.1.546/lib/python3.10/site-packages/pyk/ktool/kprin>
    raise RuntimeError(
RuntimeError: ('Command kast exited with code 113 for: /private/tmp/nix-build-kmir-dirty.drv-0/kmir/kdist/v6.1.58/llvm/>
lin

Expected Results

A sucessful build with a parser generated in llvm definition directory.

Baltoli commented 9 months ago

@yanliu18 Sorry this took so long for me to get around to looking at; the make-glr branch doesn't seem to exist on your repo and so I haven't been able to reproduce the issue. If you recall what the context / initial change to cause the issue was, I can take another look at this for you.

Baltoli commented 7 months ago

Closing as no reproduction; feel free to reopen if necessary!