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

Old-style [provides] depname=variable in wrap file overrides both cross and native dependencies #11189

Open
Akaricchi opened this issue Dec 17, 2022 · 2 comments

Comments

@Akaricchi
Copy link
Contributor

Describe the bug

Suppose you have a project that contains both host-machine (i.e. 'cross') and build-machine (i.e. 'native') build targets. Both of them depend on libfoo. You are ok with using the system-provided libfoo for the native targets, and you also bundle a libfoo subproject for the cross targets.

The libfoo subproject does not call meson.override_dependency. You want to use the implicit dependency fallback, so you add the following to the wrap file:

[provide]
libfoo=libfoo_dep

In the main project you have:

libfoo = dependency('libfoo')
libfoo_native = dependency('libfoo', native : true)

exe = executable('mwtf', 'mwtf.c',
  dependencies : libfoo)

exe_native = executable('mwtf-native', 'mwtf.c',
  native : true,
  dependencies : libfoo_native)

Then you try to set up a cross build and get:

meson.build:12:0: ERROR: Tried to mix libraries for machines 0 and 1 in target 'mwtf-native' This is not possible in a cross build.

Line 12 here is where exe_native is defined. This happens because apparently both dependency() calls returned the same object, the cross version of libfoo.

To Reproduce

Download mwtf.tar.gz and try to build it in any cross environment.

Expected behavior

Removing the provides section and adding an explicit fallback to the first dependency call makes this example work as expected:

meson.build:7:0: ERROR: Dependency 'libfoo' is required but not found.

The first dependency() call returns the cross-libfoo from the subproject, while the second errors out because I obviously do not have a libfoo actually installed on my system.

I don't think it's ever reasonable to override both cross and native dependencies with the same object; that will just never work. Sadly it's not possible to specify which type of dependency to override inside the wrap file. Most of the time, you probably want the cross dependency overriden, although theoretically it is possible that some weird project expects to override native dependencies there. It is probably possible (although not trivial) to inspect the dependency object and figure out whether a cross or a native override was intended, but I don't know if we want to go that far.

system parameters

  • Cross build
  • openSUSE Tumbleweed
  • Python 3.10.8
  • Meson 1.0.0.rc1 (git dd25b88)
  • Ninja 1.11.1
@Akaricchi
Copy link
Contributor Author

It should be noted that calling meson.override_dependency() from libfoo does not support this use-case either, sadly. It doesn't override the native dependency, but it does not allow a system fallback, either:

Dependency libfoo found: YES 0.1 (overridden)
WARNING: Subproject 'libfoo' did not override 'libfoo' dependency and no variable name specified
Dependency libfoo from subproject subprojects/libfoo found: NO

meson.build:7:0: ERROR: Dependency 'libfoo' is required but not found.

@dcbaker
Copy link
Member

dcbaker commented Dec 17, 2022

This is probably related to #11121, but this should be fixable before that.

Akaricchi added a commit to taisei-project/taisei that referenced this issue Dec 24, 2022
Implicit fallback causes conflicts in the basis_universal subproject

mesonbuild/meson#11189
Akaricchi added a commit to taisei-project/taisei that referenced this issue Dec 28, 2022
Squashed commit of the following:

commit 9ab0197
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 28 23:05:58 2022 +0100

    build: add dummy descriptions for deprecated options

commit b0c41d4
Author: Alice D <alice@starwitch.productions>
Date:   Mon Dec 26 15:18:09 2022 -0500

    update docker containers with ones containing meson 0.63.3

commit a2dd417
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:20:44 2022 +0100

    build: featurize audio options

commit 7c59e2a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:20:35 2022 +0100

    build: remove dead code

commit cf500af
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:07:37 2022 +0100

    doc: update BUILD.rst

commit 9764ac7
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 17:12:37 2022 +0100

    ci: disable WGI joystick backend for SDL

    Fails to build with latest llvm-mingw

commit 2d4f310
Author: p-sam <p-sam@d3vs.net>
Date:   Sun Dec 25 17:03:47 2022 +0100

    switch: fix missing include

commit 9264f16
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 24 14:36:41 2022 +0100

    ci: update meson to 0.63.3 due to a bug

commit 3e37be3
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 24 13:42:34 2022 +0100

    ci: update build options

commit 281a39a
Author: Alice D <alice@starwitch.productions>
Date:   Sun Dec 18 00:17:07 2022 -0500

    ci: change when apt is cleaned up for switch image

commit 2f2100a
Author: Alice D <alice@starwitch.productions>
Date:   Sun Dec 18 00:11:08 2022 -0500

    ci: bump switch homebrew container version

commit ebaff59
Author: Alice D <alice@starwitch.productions>
Date:   Sat Dec 17 22:55:39 2022 -0500

    ci: bump windows container version

commit 7ce6f23
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 07:36:28 2022 +0100

    build: featurize renderer options

commit a345f21
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 07:33:30 2022 +0100

    build: revert to explicit fallback for libzstd

    Implicit fallback causes conflicts in the basis_universal subproject

    mesonbuild/meson#11189

commit b2de61f
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 05:29:29 2022 +0100

    build: remove debug_opengl

    This option was always misdocumented, as it only controlled whether GL
    debugging is on by default. You can still control it with the
    TAISEI_GL_DEBUG environment variable, which is set to 1 in meson devenv.

commit 4c659ba
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Fri Dec 16 08:03:37 2022 +0100

    build: set up useful env vars for meson devenv

    Makes Taisei load resources from the source tree, making live reload
    work; enables OpenGL debugging by default; works around ASan stack use
    after return false positives.

commit 1ddc58b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 08:06:32 2022 +0100

    build: featurize docs; always install licenses

commit c3a94d7
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:46:28 2022 +0100

    build: featurize shader_transpiler

commit 619d82a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:38:30 2022 +0100

    build: allow libzip fallback by default

commit 79ab722
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:35:51 2022 +0100

    build: featurize use_libcrypto

commit b393077
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 05:03:20 2022 +0100

    build: featurize validate_glsl

commit 7d76484
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 04:34:31 2022 +0100

    build: featurize some more installation options

commit 17c0bda
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 03:24:46 2022 +0100

    build: deprecate enable_zip for vfs_zip; convert package_data into feature

commit 9a4ef8c
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 02:37:55 2022 +0100

    build: deprecate developer=auto; default to false

commit 807240e
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 02:24:04 2022 +0100

    build: move subproject fallback info into wraps

commit 08c953f
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:57:33 2022 +0100

    build: deprecate 'static' option

    Meson has a built-in `prefer_static` now

commit c575601
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:49:31 2022 +0100

    build: remove complicated shaderc detection logic

    Meson does all of this internally since 0.51.0

commit cd2d460
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:45:17 2022 +0100

    build: Require meson >=0.63.0

commit 10abd79
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 05:16:47 2022 +0100

    ci: remove meson dist version workaround from release workflow

    Meson should know the correct version now

commit 31a07d8
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 03:46:28 2022 +0100

    build: use built-in summary() function

commit 0c47f6d
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 04:33:01 2022 +0100

    build: remove -Dversion_fallback and introduce .VERSION file

    The version script will now first try to read the version from a
    .VERSION file in the source root. If that file does not exist, it will
    query git. The .VERSION file is not included in the git repository, it
    is generated for inclusion in source tarballs.

    Package maintainers who had any use for -Dversion_fallback may want to
    create the .VERSION file themselves.

    Additionally, some git-specific files have been removed from source
    tarballs.

commit d32332a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 03:00:07 2022 +0100

    build: set the "real" version in project()

commit f9a3fbc
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 01:50:08 2022 +0100

    build: raise meson_version and remove some legacy workarounds

    Effectively 0.56.0 was already required since we started using some of
    its features at some point.

    This also fixes all current meson warnings.
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

2 participants