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

Failure in detect_rust_compiler when C compiler is ccache wrapper #11586

Open
theHamsta opened this issue Mar 24, 2023 · 0 comments · May be fixed by #11587
Open

Failure in detect_rust_compiler when C compiler is ccache wrapper #11586

theHamsta opened this issue Mar 24, 2023 · 0 comments · May be fixed by #11587
Assignees

Comments

@theHamsta
Copy link

theHamsta commented Mar 24, 2023

Describe the bug
I tried to build https://gitlab.gnome.org/YaLTeR/identity.

The only command I executed was meson setup --buildtype=release build. This resulted in the following error

❯ meson setup --buildtype=release build              
The Meson build system
Version: 1.0.1
Source dir: /home/stephan/projects/identity
Build dir: /home/stephan/projects/identity/build
Build type: native build
Project name: identity
Project version: 0.5.0
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mesonbuild/mesonmain.py", line 194, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 310, in run
    app.generate()
  File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 187, in generate
    self._generate(env)
  File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 209, in _generate
    intr = interpreter.Interpreter(b, user_defined_options=user_defined_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreter/interpreter.py", line 328, in __init__
    self.parse_project()
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 117, in parse_project
    self.evaluate_codeblock(self.ast, end=1)
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 172, in evaluate_codeblock
    raise e
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 165, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 178, in evaluate_statement
    return self.function_call(cur)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 460, in function_call
    res = func(node, func_args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper
    return f(*nargs, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreterbase/decorators.py", line 590, in wrapper
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreter/interpreter.py", line 1245, in func_project
    self.add_languages(proj_langs, True, MachineChoice.HOST)
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreter/interpreter.py", line 1381, in add_languages
    success = self.add_languages_for(args, required, for_machine)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/interpreter/interpreter.py", line 1421, in add_languages_for
    comp = compilers.detect_compiler_for(self.environment, lang, for_machine)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/compilers/detect.py", line 115, in detect_compiler_for
    comp = compiler_from_language(env, lang, for_machine)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/compilers/detect.py", line 112, in compiler_from_language
    return lang_map[lang](env, for_machine) if lang in lang_map else None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mesonbuild/compilers/detect.py", line 985, in detect_rust_compiler
    c = exelist.pop(0)
        ^^^^^^^^^^^^^^
IndexError: pop from empty list

meson.build:1:0: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!

To Reproduce

git clone https://gitlab.gnome.org/YaLTeR/identity.git`
cd identity
meson setup --buildtype=release build

Maybe useful context...

❯ echo $CC
/usr/lib/ccache/clang-17

❯ which cc
/usr/lib/ccache/cc

❯ rustc --version
rustc 1.70.0-nightly (4a04d086c 2023-03-18)

❯ which rustc
/home/stephan/.cargo/bin/rustc

Rust is installed via rustup.

It might be possible to get a similar environment by executing the following on Ubuntu

apt install ccache
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
export PATH=PATH:/usr/lib/ccache/
export CC=/usr/lib/ccache/clang-17
export PATH=/usr/lib/ccache:$PATH
export PATH=~/.cargo/bin:$PATH
export PATH=$PATH:~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin

Usually, all other Rust projects that I built via meson worked.

Expected behavior
have no Python stacktrace.

I can fix the error by out-commenting the following lines https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/detect.py#L986-L987, rest of the build would then behave normal. ccache should maybe not removed if it is the only entry in exelist or an error returned reported what went wrong.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    Ubuntu 23.04
  • what Python version are you using e.g. 3.8.0
    3.11.2
  • what meson --version
    1.0.1
  • what ninja --version if it's a Ninja build
    1.11.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants