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

Better experience when kdist reports compiler error from kompile #4564

Open
dwightguth opened this issue Jul 31, 2024 · 0 comments
Open

Better experience when kdist reports compiler error from kompile #4564

dwightguth opened this issue Jul 31, 2024 · 0 comments

Comments

@dwightguth
Copy link
Collaborator

This is the command line output I get when I run kdist and kompile reports a compiler error:

INFO 2024-07-31 12:21:39,414 pyk.kdist._cache - Loading target cache
INFO 2024-07-31 12:21:39,428 pyk.kdist._cache - Loading plugin: wasm-semantics
INFO 2024-07-31 12:21:39,428 pyk.kdist._cache - Importing module: pykwasm.kdist.plugin
INFO 2024-07-31 12:21:39,439 pyk.kdist._cache - Target cache loaded in 0.025s
INFO 2024-07-31 12:21:39,439 pyk.kdist._kdist - Building targets: wasm-semantics.llvm, wasm-semantics.source
/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source
INFO 2024-07-31 12:21:39,448 pyk.utils - Running: kompile --version
INFO 2024-07-31 12:21:39,525 pyk.utils - Completed in 0.077s with status 0: kompile --version
INFO 2024-07-31 12:21:39,528 pyk.ktool.kompile - Running: kompile /home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md --main-module WASM-TEST --syntax-module WASM-TEST-SYNTAX --md-selector k --emit-json --gen-glr-bison-parser --backend llvm -O3 -ccopt -g --iterated-threshold 1 --output-definition /home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/llvm --warnings-to-errors --verbose
[Error] Compiler: Could not find sorts: [Int]
        Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm-text.md)
        Location(50,29,50,79)
        50 |        syntax WasmIntToken ::= Int
[token]
           .
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INFO 2024-07-31 12:21:41,369 pyk.ktool.kompile - Completed in 1.841s with status 113: kompile /home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md --main-module WASM-TEST --syntax-module WASM-TEST-SYNTAX --md-selector k --emit-json --gen-glr-bison-parser --backend llvm -O3 -ccopt -g --iterated-threshold 1 --output-definition /home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/llvm --warnings-to-errors --verbose
concurrent.futures.process._RemoteTraceback:
"""
Traceback (most recent call last):
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/ktool/kompile.py", line 335, in __call__
    proc_res = run_process(args, logger=_LOGGER, cwd=cwd, check=check)
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/utils.py", line 451, in run_process
    res.check_returncode()
  File "/usr/lib/python3.10/subprocess.py", line 457, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '('kompile', '/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md', '--main-module', 'WASM-TEST', '--syntax-module', 'WASM-TEST-SYNTAX', '--md-selector', 'k', '--emit-json', '--gen-glr-bison-parser', '--backend', 'llvm', '-O3', '-ccopt', '-g', '--iterated-threshold', '1', '--output-definition', '/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/llvm', '--warnings-to-errors', '--verbose')' returned non-zero exit status 113.

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

Traceback (most recent call last):
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/_kdist.py", line 157, in _build_target
    target.target.build(output_dir, deps=self._deps(target), args=args, verbose=verbose)
  File "/home/dwightguth/wasm-semantics/pykwasm/src/pykwasm/kdist/plugin.py", line 35, in build
    kompile(output_dir=output_dir, verbose=verbose, **kompile_args)
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/ktool/kompile.py", line 94, in kompile
    return kompiler(
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/ktool/kompile.py", line 337, in __call__
    raise RuntimeError(
RuntimeError: ('Command kompile exited with code 113 for: /home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md', 'Parse command line options                                   =  0.036s\nImporting: Source(Auto imported prelude)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/prelude.md)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/kast.md)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/domains.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm-text.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/sparse-bytes.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-int.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/int-type.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-ref.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/tools.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/numeric.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/auxil.md)\n', None, 113, CalledProcessError(113, ('kompile', '/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md', '--main-module', 'WASM-TEST', '--syntax-module', 'WASM-TEST-SYNTAX', '--md-selector', 'k', '--emit-json', '--gen-glr-bison-parser', '--backend', 'llvm', '-O3', '-ccopt', '-g', '--iterated-threshold', '1', '--output-definition', '/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/llvm', '--warnings-to-errors', '--verbose'), 'Parse command line options                                   =  0.036s\nImporting: Source(Auto imported prelude)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/prelude.md)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/kast.md)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/domains.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm-text.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/sparse-bytes.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-int.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/int-type.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-ref.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/tools.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/numeric.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/auxil.md)\n', None))

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

Traceback (most recent call last):
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/_kdist.py", line 160, in _build_target
    raise RuntimeError(f'Build failed: {target_id.full_name}') from err
RuntimeError: Build failed: wasm-semantics.llvm
"""

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

Traceback (most recent call last):
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/bin/kdist", line 8, in <module>
    sys.exit(main())
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/__main__.py", line 28, in main
    _exec_build(**vars(args))
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/__main__.py", line 52, in _exec_build
    kdist.build(
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/_kdist.py", line 120, in build
    result = future.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
RuntimeError: Build failed: wasm-semantics.llvm

This is what I actually care to see in the result of all this text:

[Error] Compiler: Could not find sorts: [Int]
        Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm-text.md)
        Location(50,29,50,79)
        50 |        syntax WasmIntToken ::= Int
[token]
           .
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is what is actually visible in my terminal window without scrolling up:

/wasm-semantics/data/list-int.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/int-type.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-ref.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/tools.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/numeric.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/auxil.md)\n', None, 113, CalledProcessError(113, ('kompile', '/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md', '--main-module', 'WASM-TEST', '--syntax-module', 'WASM-TEST-SYNTAX', '--md-selector', 'k', '--emit-json', '--gen-glr-bison-parser', '--backend', 'llvm', '-O3', '-ccopt', '-g', '--iterated-threshold', '1', '--output-definition', '/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/llvm', '--warnings-to-errors', '--verbose'), 'Parse command line options                                   =  0.036s\nImporting: Source(Auto imported prelude)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/prelude.md)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/kast.md)\nImporting: Source(/home/dwightguth/kframework/k-distribution/target/release/k/include/kframework/builtin/domains.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/test.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm-text.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/wasm.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/sparse-bytes.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-int.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/int-type.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/list-ref.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/data/tools.k)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/numeric.md)\nImporting: Source(/home/dwightguth/.cache/kdist-162ab5d/wasm-semantics/source/wasm-semantics/auxil.md)\n', None))

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

Traceback (most recent call last):
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/_kdist.py", line 160, in _build_target
    raise RuntimeError(f'Build failed: {target_id.full_name}') from err
RuntimeError: Build failed: wasm-semantics.llvm
"""

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

Traceback (most recent call last):
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/bin/kdist", line 8, in <module>
    sys.exit(main())
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/__main__.py", line 28, in main
    _exec_build(**vars(args))
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/__main__.py", line 52, in _exec_build
    kdist.build(
  File "/home/dwightguth/.cache/pypoetry/virtualenvs/pykwasm-so-WyID9-py3.10/lib/python3.10/site-packages/pyk/kdist/_kdist.py", line 120, in build
    result = future.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
RuntimeError: Build failed: wasm-semantics.llvm

Printing the entire python stack trace when the python code worked exactly correctly, and there was just a compiler error in the semantics, is not helpful. In this case, the traceback should not be printed at all unless you specifically ask for it.

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

1 participant