No way to disable default-features on rust dependencies?
Describe the bug
Seemingly meson sorta follows the Cargo lock file or so with its feature definitions when adding new features, but it doesn't heed default-features completely, which leads to evaluation errors?
I can't actually find the generated meson file for tracing-subscriber which contains the bad dependency in question (which is a problem for debugging). EDIT: yeah it exists but it's not printed out if setup fails, unfortunate
See also, the other issue I found here in the same setup: https://github.com/mesonbuild/meson/issues/14289
Suspicious code: https://github.com/mesonbuild/meson/blob/211f1cae3a9b398073695fd8da6be9dae9566579/mesonbuild/cargo/interpreter.py#L487-L490
To Reproduce
https://gist.github.com/lf-/00ea95184017a3e7a9ab92f0a3eef432
[package]
name = "meowmeow"
edition = "2021"
[lib]
path = "lib.rs"
[dependencies]
tracing = "0.1.41"
# just don't need log
tracing-subscriber = { version = "0.3.19", default-features = false, features = ["std", "fmt", "ansi", "smallvec", "env-filter"] }
project('meowmeow', 'rust')
tracing = dependency('tracing-0.1-rs')
tracing_subscriber = dependency('tracing-subscriber-0.3-rs')
meson.override_dependency('tracing-subscriber-0.3-rs', tracing_subscriber)
static_library(
sources : [ './lib.rs' ],
language : 'rust',
dependencies : [tracing, tracing_subscriber],
)
Do this:
git clone https://gist.github.com/lf-/00ea95184017a3e7a9ab92f0a3eef432 bug && cd bug && meson setup build
The Meson build system
Version: 1.7.99
Source dir: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs
Build dir: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build
Build type: native build
Project name: meowmeow
Project version: undefined
Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
Host machine cpu family: aarch64
Host machine cpu: aarch64
Did not find pkg-config by name 'pkg-config'
Found pkg-config: NO
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency tracing-0.1-rs found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency tracing-0.1-rs
Executing subproject tracing-0.1-rs method cargo
meson.build:3: WARNING: Project does not target a minimum version but uses feature introduced in '1.3.0': Cargo subproje
ct.
meson.build:3: WARNING: Cargo subproject is an experimental feature and has no backwards compatibility guarantees.
<snip> warnings
tracing-0.1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/tracing-0.1.41/m
eson.build
tracing-0.1-rs| Project name: tracing
tracing-0.1-rs| Project version: 0.1.41
tracing-0.1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
tracing-0.1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
tracing-0.1-rs| Message: Enabled features: ['default', 'attributes', 'tracing-attributes', 'std']
tracing-0.1-rs| Run-time dependency pin-project-lite-0.2-rs found: NO (tried pkgconfig and cmake)
tracing-0.1-rs| Looking for a fallback subproject for the dependency pin-project-lite-0.2-rs
Executing subproject tracing-0.1-rs:pin-project-lite-0.2-rs method cargo
pin-project-lite-0.2-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/pin-pro
ject-lite-0.2.16/meson.build
pin-project-lite-0.2-rs| Project name: pin-project-lite
pin-project-lite-0.2-rs| Project version: 0.2.16
pin-project-lite-0.2-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
pin-project-lite-0.2-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
pin-project-lite-0.2-rs| Message: Enabled features: ['default']
pin-project-lite-0.2-rs| Build targets in project: 1
pin-project-lite-0.2-rs| Subproject pin-project-lite-0.2-rs finished.
tracing-0.1-rs| Dependency pin-project-lite-0.2-rs found: YES 0.2.16 (overridden)
tracing-0.1-rs| Run-time dependency tracing-attributes-0.1-rs found: NO (tried pkgconfig and cmake)
tracing-0.1-rs| Looking for a fallback subproject for the dependency tracing-attributes-0.1-rs
Executing subproject tracing-0.1-rs:tracing-attributes-0.1-rs method cargo
tracing-attributes-0.1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/traci
ng-attributes-0.1.28/meson.build
tracing-attributes-0.1-rs| Project name: tracing-attributes
tracing-attributes-0.1-rs| Project version: 0.1.28
tracing-attributes-0.1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
tracing-attributes-0.1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
tracing-attributes-0.1-rs| Message: Enabled features: ['default']
tracing-attributes-0.1-rs| Run-time dependency syn-2-rs found: NO (tried pkgconfig and cmake)
tracing-attributes-0.1-rs| Looking for a fallback subproject for the dependency syn-2-rs
Executing subproject tracing-0.1-rs:tracing-attributes-0.1-rs:syn-2-rs method cargo
syn-2-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/syn-2.0.98/meson.build
syn-2-rs| Project name: syn
syn-2-rs| Project version: 2.0.98
syn-2-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
syn-2-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
syn-2-rs| Message: Enabled features: ['parsing', 'proc-macro', 'visit-mut', 'printing', 'clone-impls', 'extra-traits', '
full']
syn-2-rs| Run-time dependency quote-1-rs found: NO (tried pkgconfig and cmake)
syn-2-rs| Looking for a fallback subproject for the dependency quote-1-rs
Executing subproject tracing-0.1-rs:tracing-attributes-0.1-rs:syn-2-rs:quote-1-rs method cargo
quote-1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/quote-1.0.38/meson.b
uild
quote-1-rs| Project name: quote
quote-1-rs| Project version: 1.0.38
quote-1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
quote-1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
quote-1-rs| Message: Enabled features: ['default', 'proc-macro']
quote-1-rs| Run-time dependency proc-macro2-1-rs found: NO (tried pkgconfig and cmake)
quote-1-rs| Looking for a fallback subproject for the dependency proc-macro2-1-rs
Executing subproject tracing-0.1-rs:tracing-attributes-0.1-rs:syn-2-rs:quote-1-rs:proc-macro2-1-rs method cargo
proc-macro2-1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/proc-macro2-1.
0.93/meson.build
proc-macro2-1-rs| Project name: proc-macro2
proc-macro2-1-rs| Project version: 1.0.93
proc-macro2-1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
proc-macro2-1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
proc-macro2-1-rs| Message: Enabled features: ['default', 'proc-macro']
proc-macro2-1-rs| Run-time dependency unicode-ident-1-rs found: NO (tried pkgconfig and cmake)
proc-macro2-1-rs| Looking for a fallback subproject for the dependency unicode-ident-1-rs
Executing subproject tracing-0.1-rs:tracing-attributes-0.1-rs:syn-2-rs:quote-1-rs:proc-macro2-1-rs:unicode-ident-1-rs me
thod cargo
unicode-ident-1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/unicode-iden
t-1.0.17/meson.build
unicode-ident-1-rs| Project name: unicode-ident
unicode-ident-1-rs| Project version: 1.0.17
unicode-ident-1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
unicode-ident-1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
unicode-ident-1-rs| Message: Enabled features: ['default']
unicode-ident-1-rs| Build targets in project: 2
unicode-ident-1-rs| Subproject unicode-ident-1-rs finished.
proc-macro2-1-rs| Dependency unicode-ident-1-rs found: YES 1.0.17 (overridden)
proc-macro2-1-rs| Build targets in project: 3
proc-macro2-1-rs| Subproject proc-macro2-1-rs finished.
quote-1-rs| Dependency proc-macro2-1-rs found: YES 1.0.93 (overridden)
quote-1-rs| Build targets in project: 4
quote-1-rs| Subproject quote-1-rs finished.
syn-2-rs| Dependency quote-1-rs found: YES 1.0.38 (overridden)
syn-2-rs| Dependency unicode-ident-1-rs found: YES 1.0.17 (overridden)
syn-2-rs| Dependency proc-macro2-1-rs found: YES 1.0.93 (overridden)
syn-2-rs| Build targets in project: 5
syn-2-rs| Subproject syn-2-rs finished.
tracing-attributes-0.1-rs| Dependency syn-2-rs found: YES 2.0.98 (overridden)
tracing-attributes-0.1-rs| Dependency quote-1-rs found: YES 1.0.38 (overridden)
tracing-attributes-0.1-rs| Dependency proc-macro2-1-rs found: YES 1.0.93 (overridden)
tracing-attributes-0.1-rs| WARNING: Tried to mix a host machine library ("syn") with a build machine target "tracing_att
ributes" This will fail in cross build.
tracing-attributes-0.1-rs| WARNING: Tried to mix a host machine library ("quote") with a build machine target "tracing_a
ttributes" This will fail in cross build.
tracing-attributes-0.1-rs| WARNING: Tried to mix a host machine library ("proc_macro2") with a build machine target "tra
cing_attributes" This will fail in cross build.
tracing-attributes-0.1-rs| Build targets in project: 6
tracing-attributes-0.1-rs| Subproject tracing-attributes-0.1-rs finished.
tracing-0.1-rs| Dependency tracing-attributes-0.1-rs found: YES 0.1.28 (overridden)
tracing-0.1-rs| Run-time dependency tracing-core-0.1-rs found: NO (tried pkgconfig and cmake)
tracing-0.1-rs| Looking for a fallback subproject for the dependency tracing-core-0.1-rs
Executing subproject tracing-0.1-rs:tracing-core-0.1-rs method cargo
tracing-core-0.1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/tracing-cor
e-0.1.33/meson.build
tracing-core-0.1-rs| Project name: tracing-core
tracing-core-0.1-rs| Project version: 0.1.33
tracing-core-0.1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
tracing-core-0.1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
tracing-core-0.1-rs| Message: Enabled features: ['once_cell', 'std']
tracing-core-0.1-rs| Run-time dependency once_cell-1-rs found: NO (tried pkgconfig and cmake)
tracing-core-0.1-rs| Looking for a fallback subproject for the dependency once_cell-1-rs
Executing subproject tracing-0.1-rs:tracing-core-0.1-rs:once_cell-1-rs method cargo
once_cell-1-rs| Generated Meson AST: /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/subprojects/once_cell-1.20.3
/meson.build
once_cell-1-rs| Project name: once_cell
once_cell-1-rs| Project version: 1.20.3
once_cell-1-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.1)
once_cell-1-rs| Rust linker for the host machine: rustc -C linker=cc ld64 1115.7.3
once_cell-1-rs| Message: Enabled features: ['default', 'alloc', 'race', 'std']
once_cell-1-rs| Build targets in project: 7
once_cell-1-rs| Subproject once_cell-1-rs finished.
tracing-core-0.1-rs| Dependency once_cell-1-rs found: YES 1.20.3 (overridden)
tracing-core-0.1-rs| Build targets in project: 8
tracing-core-0.1-rs| Subproject tracing-core-0.1-rs finished.
tracing-0.1-rs| Dependency tracing-core-0.1-rs found: YES 0.1.33 (overridden)
tracing-0.1-rs| Build targets in project: 9
tracing-0.1-rs| Subproject tracing-0.1-rs finished.
Dependency tracing-0.1-rs found: YES 0.1.41 (overridden)
Run-time dependency tracing-subscriber-0.3-rs found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency tracing-subscriber-0.3-rs
Executing subproject tracing-subscriber-0.3-rs method cargo
meson.build:4: WARNING: Project does not target a minimum version but uses feature introduced in '1.3.0': Cargo subproje
ct.
tracing-subscriber-0.3-rs| WARNING: Binary entry cached_layer_filters_dont_break_other_layers has unexpected keys "path"
. This may (unlikely) be an error in the cargo manifest, or may be a missing implementation in Meson. If this issue can
be reproduced with the latest version of Meson, please help us by opening an issue at https://github.com/mesonbuild/meso
n/issues. Please include the crate and version that is generating this warning if possible.
tracing-subscriber-0.3-rs| WARNING: Binary entry duplicate_spans has unexpected keys "path". This may (unlikely) be an e
rror in the cargo manifest, or may be a missing implementation in Meson. If this issue can be reproduced with the latest
version of Meson, please help us by opening an issue at https://github.com/mesonbuild/meson/issues. Please include the
crate and version that is generating this warning if possible.
<SNIP> more of them
meson.build:4:21: ERROR: Neither a subproject directory nor a tracing-log-0.2-rs.wrap file was found.
A full log can be found at /Users/jade/dev/repro/2025-02-21-meson-rust-bugs/build/meson-logs/meson-log.txt
Expected behavior
Should build or at least be debuggable failing that; default-features should be heeded.
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.) macOS 15.3.1
- what Python version are you using: 3.12.8
- what
meson --version:1.7.99(commit d995cbce0f1e9454fdfe467e47c2423aa5217fd3) - what
ninja --versionif it's a Ninja build: doesn't pass configure.
By the way if you enable default-features in the manifest, this error happens:
subprojects/tracing-subscriber-0.3.19/meson.build:106:-1: ERROR: Problem encountered: Dependency tracing-core-0.1-rs pre
viously configured with features ['std', 'once_cell'] but need ['std', 'once_cell', 'default']
But I actually don't want them enabled. So. Yeah...
Design wise, I think this probably is supposed to be an option or a wrap file entry? Probably closer to a subproject option (and arguably the wrap settings for rustc options are kinda wrong for the same reason) since you can have a cargo subproject without it being a wrap.