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

glib fails to configure with KeyError: Tried to access nonexistant project parent option b_vscrt. #14255

Closed
tp-m opened this issue Feb 15, 2025 · 15 comments · Fixed by #14305
Closed
Labels
exception Major bug that raises a python-level exception options Meson configuration options

Comments

@tp-m
Copy link
Member

tp-m commented Feb 15, 2025

Option refactor regression I presume.

$ git clone https://gitlab.gnome.org/GNOME/glib.git

$ cd glib

$ ~/Devel/meson/meson.py setup b
The Meson build system
Version: 1.7.99
Source dir: /tmp/glib
Build dir: /tmp/glib/b
Build type: native build
Project name: glib
Project version: 2.83.3
C compiler for the host machine: ccache cc (gcc 14.2.0 "cc (Debian 14.2.0-14) 14.2.0")
C linker for the host machine: cc ld.bfd 2.43.90.20250122
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -std=c89: YES 
Compiler for C supports arguments -std=c99: YES 
Compiler for C supports arguments -std=c11: YES 
Compiler for C supports arguments -std=c17: YES 
C++ compiler for the host machine: ccache c++ (gcc 14.2.0 "c++ (Debian 14.2.0-14) 14.2.0")
C++ linker for the host machine: c++ ld.bfd 2.43.90.20250122
Compiler for C++ supports arguments -std=c++98: YES 
Compiler for C++ supports arguments -std=c++03: YES 
Compiler for C++ supports arguments -std=c++11: YES 
Compiler for C++ supports arguments -std=c++14: YES 
Compiler for C++ supports arguments -std=c++17: YES 
Compiler for C++ supports arguments -std=c++20: YES 
Compiler for C++ supports arguments -std=c++2b: YES 
Compiler for C++ supports arguments -std=c++latest: NO 
Checking if "building for musl libc" compiles: NO 
Program ./.gitlab-ci/thorough-test-wrapper.sh found: YES (/bin/bash /tmp/glib/./.gitlab-ci/thorough-test-wrapper.sh)
Program valgrind found: YES (/usr/bin/valgrind)
Compiler for C supports arguments -fno-strict-aliasing: YES 
Traceback (most recent call last):
  File "/home/tpm/Devel/meson/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
           ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/msetup.py", line 407, in run
    app.generate()
    ~~~~~~~~~~~~^^
  File "/home/tpm/Devel/meson/mesonbuild/msetup.py", line 189, in generate
    return self._generate(env, capture, vslite_ctx)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/msetup.py", line 266, in _generate
    intr.run()
    ~~~~~~~~^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreter/interpreter.py", line 3061, in run
    super().run()
    ~~~~~~~~~~~^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 169, in run
    self.evaluate_codeblock(self.ast, start=1)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 194, in evaluate_codeblock
    raise e
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 186, in evaluate_codeblock
    self.evaluate_statement(cur)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 204, in evaluate_statement
    self.assignment(cur)
    ~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 641, in assignment
    value = self.evaluate_statement(node.value)
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement
    return self.function_call(cur)
           ~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 527, in function_call
    res = func(node, func_args, kwargs)
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/decorators.py", line 237, in wrapper
    return f(*nargs, **wrapped_kwargs)
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/decorators.py", line 62, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/home/tpm/Devel/meson/mesonbuild/interpreter/interpreter.py", line 1083, in func_get_option
    value_object, value = self.coredata.optstore.get_option_from_meson_file(options.OptionKey(optname, self.subproject))
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 1101, in get_option_from_meson_file
    (value_object, value) = self.get_value_object_and_value_for(key)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 832, in get_value_object_and_value_for
    vobject = self.get_value_object_for(key)
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 826, in get_value_object_for
    raise KeyError(f'Tried to access nonexistant project parent option {parent_key}.')
KeyError: 'Tried to access nonexistant project parent option b_vscrt.'

meson.build:365:13: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!
@tp-m tp-m added the options Meson configuration options label Feb 15, 2025
@tp-m tp-m added this to the optionrefactor milestone Feb 15, 2025
@bonzini bonzini added the exception Major bug that raises a python-level exception label Feb 15, 2025
@jpakkane
Copy link
Member

That is caused by this line in the main meson.build

vs_crt_opt = get_option('b_vscrt')

It is unconditionally asking for that option, even though it is only defined on Windows platforms. I checked version 1.7.0 and meson configure does not list b_vscrt at all. To be fair I have no idea how this could possibly have worked before.

@tp-m
Copy link
Member Author

tp-m commented Feb 17, 2025

That is caused by this line in the main meson.build

vs_crt_opt = get_option('b_vscrt')

It is unconditionally asking for that option, even though it is only defined on Windows platforms. I checked version 1.7.0 and meson configure does not list b_vscrt at all. To be fair I have no idea how this could possibly have worked before.

In 1.6.1 it returns from_buildtype which is documented as the default value.

The documentation says

The following options are available. Note that they may not be available on all platforms or with all compilers:

but does not say for each option on which platforms and with which compilers they might be available.

I am not sure if it's really reasonable to expect Meson users to just "know" what's what in this case, especially if a reasonable default value is available that was returned on Linux/with gcc before.

If it's not too much hassle we should probably add a column to the documentation with more info for each option and make this work with a warning for another release or three?

@dcbaker
Copy link
Member

dcbaker commented Feb 18, 2025

Checking for this would be so tedious, it’s not just a question of “what is my platform”, but what are both my host and build compilers, since either of them could be msvc and enable this.

@dcbaker
Copy link
Member

dcbaker commented Feb 18, 2025

If we really want to not populate these in meson 2.0 we could move to a fallback parameter, and of the fallback isn’t provided then it errors, but that’s still a breaking change and would have to go through a proper deprecation cycle

@xclaesse
Copy link
Member

@jpakkane It was intentional to allow getting b_* regardless of the platform/compiler, to make it easier to deal in meson.build.

@xclaesse
Copy link
Member

The code we used to have:

    def get_option_internal(self, optname: str) -> options.UserOption:
        key = OptionKey.from_string(optname).evolve(subproject=self.subproject)

        if not self.environment.coredata.optstore.is_project_option(key):
            for opts in [self.coredata.optstore, compilers.base_options]:
                v = opts.get(key)
                if v is None or v.yielding:
                    v = opts.get(key.as_root())
                if v is not None:
                    assert isinstance(v, options.UserOption), 'for mypy'
                    return v

Notice that it lookup into compilers.base_options that defines ALL b_ options.

@bonzini
Copy link
Collaborator

bonzini commented Feb 22, 2025

Fixed

@bonzini bonzini closed this as completed Feb 22, 2025
@tp-m
Copy link
Member Author

tp-m commented Feb 23, 2025

Fixed

Now it fails with

meson.build:365:13: ERROR: Option b_vscrt does not exist.

(without the python exception trace)

Is that really the expected/agreed-upon resolution?

@bonzini bonzini reopened this Feb 23, 2025
@jpakkane
Copy link
Member

There were two different bugs here. The one that would fix this one is #14272 but it's not merged yet due to disagreements on how the issue should be fixed.

@KamathForAIX
Copy link
Contributor

I see this issue in AIX as well. Our glib2 CI is down. Alright. Will wait. Just want to inform. Thanks. @jpakkane

@tp-m
Copy link
Member Author

tp-m commented Feb 27, 2025

Now (commit 8546e40, optstore: remove num_options) I'm getting

raceback (most recent call last):
  File "/home/tpm/Devel/meson/mesonbuild/interpreter/interpreter.py", line 1084, in func_get_option
    value_object, value = self.coredata.optstore.get_option_from_meson_file(options.OptionKey(optname, self.subproject))
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 1100, in get_option_from_meson_file
    (value_object, value) = self.get_value_object_and_value_for(key)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 836, in get_value_object_and_value_for
    vobject = self.get_value_object_for(key)
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 830, in get_value_object_for
    raise KeyError(f'Tried to access nonexistant project parent option {parent_key}.')
KeyError: 'Tried to access nonexistant project parent option b_vscrt.'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tpm/Devel/meson/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
           ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/msetup.py", line 408, in run
    app.generate()
    ~~~~~~~~~~~~^^
  File "/home/tpm/Devel/meson/mesonbuild/msetup.py", line 189, in generate
    return self._generate(env, capture, vslite_ctx)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/msetup.py", line 267, in _generate
    intr.run()
    ~~~~~~~~^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreter/interpreter.py", line 3071, in run
    super().run()
    ~~~~~~~~~~~^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 169, in run
    self.evaluate_codeblock(self.ast, start=1)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 194, in evaluate_codeblock
    raise e
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 186, in evaluate_codeblock
    self.evaluate_statement(cur)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 204, in evaluate_statement
    self.assignment(cur)
    ~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 641, in assignment
    value = self.evaluate_statement(node.value)
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement
    return self.function_call(cur)
           ~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/interpreterbase.py", line 527, in function_call
    res = func(node, func_args, kwargs)
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/decorators.py", line 237, in wrapper
    return f(*nargs, **wrapped_kwargs)
  File "/home/tpm/Devel/meson/mesonbuild/interpreterbase/decorators.py", line 62, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/home/tpm/Devel/meson/mesonbuild/interpreter/interpreter.py", line 1086, in func_get_option
    if self.coredata.optstore.is_base_option(optname):
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/tpm/Devel/meson/mesonbuild/options.py", line 1169, in is_base_option
    return key.name.startswith('b_')
           ^^^^^^^^
AttributeError: 'str' object has no attribute 'name'

meson.build:365:13: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!

fwiw.

@dcbaker
Copy link
Member

dcbaker commented Feb 27, 2025

@tp-m: I have a feeling that 25f7e33 is the culprit, can you confirm?

@dcbaker
Copy link
Member

dcbaker commented Feb 27, 2025

We clearly have a testing gap here...

@tp-m
Copy link
Member Author

tp-m commented Feb 27, 2025

@tp-m: I have a feeling that 25f7e33 is the culprit, can you confirm?

Yes, with that commit reverted we're back to ERROR: Option b_vscrt does not exist.

@dcbaker
Copy link
Member

dcbaker commented Feb 27, 2025

I have a patch, hold on I'll open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exception Major bug that raises a python-level exception options Meson configuration options
Projects
None yet
6 participants