Skip to content

Cargo Wrap - meson.build has clashing target names when multiple crate types are present #15028

@MKuranowski

Description

@MKuranowski

Describe the bug
Meson fails to setup a basic project with a Cargo/Rust library wrap with ERROR: Neither a subproject directory nor a lib-0.1-rs.wrap file was found. when following the documentation.

To Reproduce

Rust library, "gizmo": https://github.com/MKuranowski/MesonCargoSubprojectTest-Rust/
Meson project, "thinger": https://github.com/MKuranowski/MesonCargoSubprojectTest-C/

In particular:

  • The Cargo/Rust project builds all lib, staticlib and cdylib crate types
  • meson.build:
project(
  'thinger',
  'c',
  meson_version : '>= 1.3.0',
  version : '0.1',
  default_options : ['warning_level=3'],
)

subproject('gizmo')

dependencies = [
  # TODO
]

executable(
  'thinger',
  'thinger.c',
  dependencies : dependencies,
  install : true,
)
  • subprojects/gizmo.wrap:
[wrap-git]
url = https://github.com/MKuranowski/MesonCargoSubprojectTest-Rust
revision = HEAD
depth = 1
method = cargo

[provide]
dependency_names = gizmo-0.1-rs
  • subprojects/gizmo/Cargo.toml
[package]
name = "gizmo"
version = "0.1.0"
edition = "2024"

[lib]
name = "gizmo"
path = "src/lib.rs"
crate-type = ["lib", "staticlib", "cdylib"]

$ git clone https://github.com/MKuranowski/MesonCargoSubprojectTest-C
$ cd MesonCargoSubprojectTest-C
$ meson setup builddir
The Meson build system
Version: 1.9.0
Source dir: /tmp/MesonCargoSubprojectTest-C
Build dir: /tmp/MesonCargoSubprojectTest-C/builddir
Build type: native build
Project name: thinger
Project version: 0.1
C compiler for the host machine: cc (gcc 15.2.1 "cc (GCC) 15.2.1 20250813")
C linker for the host machine: cc ld.bfd 2.45.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Cloning into 'gizmo'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 0), reused 7 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (7/7), done.

Executing subproject gizmo method cargo 

meson.build:9: WARNING: Cargo subproject is an experimental feature and has no backwards compatibility guarantees.
Rust compiler for the host machine: rustc -C linker=cc (rustc 1.89.0 "1.89.0")
Rust linker for the host machine: rustc -C linker=cc ld.bfd 2.45.0

meson.build:9:0: ERROR: Neither a subproject directory nor a gizmo-0.1-rs.wrap file was found.

A full log can be found at /tmp/MesonCargoSubprojectTest-C/builddir/meson-logs/meson-log.txt
meson-log.txt
Build started at 2025-09-15T00:30:10.462363
Main binary: /usr/bin/python
Build Options: 
Python system: Linux
The Meson build system
Version: 1.9.0
Source dir: /tmp/MesonCargoSubprojectTest-C
Build dir: /tmp/MesonCargoSubprojectTest-C/builddir
Build type: native build
Project name: thinger
Project version: 0.1
-----------
Detecting compiler via: `cc --version` -> 0
stdout:
cc (GCC) 15.2.1 20250813
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------
Running command: -cpp -x c -E -dM -
-----
-----------
Detecting linker via: `cc -Wl,--version` -> 0
stdout:
GNU ld (GNU Binutils) 2.45.0
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
-----------
stderr:
collect2 version 15.2.1 20250813
/usr/bin/ld -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cc7bDm09.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../.. -L/lib -L/usr/lib --version -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crtn.o
-----------
Sanity testing C compiler: cc
Is cross compiler: False.
Sanity check compiler command line: cc sanitycheckc.c -o sanitycheckc.exe -D_FILE_OFFSET_BITS=64
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanitycheckc.exe
-----------
Sanity check: `/tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanitycheckc.exe` -> 0
C compiler for the host machine: cc (gcc 15.2.1 "cc (GCC) 15.2.1 20250813")
C linker for the host machine: cc ld.bfd 2.45.0
-----------
Detecting archiver via: `gcc-ar --version` -> 0
stdout:
GNU ar (GNU Binutils) 2.45.0
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
-----------
-----------
Detecting compiler via: `cc --version` -> 0
stdout:
cc (GCC) 15.2.1 20250813
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------
Running command: -cpp -x c -E -dM -
-----
-----------
Detecting linker via: `cc -Wl,--version` -> 0
stdout:
GNU ld (GNU Binutils) 2.45.0
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
-----------
stderr:
collect2 version 15.2.1 20250813
/usr/bin/ld -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccidNEX5.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../.. -L/lib -L/usr/lib --version -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crtn.o
-----------
Sanity testing C compiler: cc
Is cross compiler: False.
Sanity check compiler command line: cc sanitycheckc.c -o sanitycheckc.exe -D_FILE_OFFSET_BITS=64
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanitycheckc.exe
-----------
Sanity check: `/tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanitycheckc.exe` -> 0
C compiler for the build machine: cc (gcc 15.2.1 "cc (GCC) 15.2.1 20250813")
C linker for the build machine: cc ld.bfd 2.45.0
-----------
Detecting archiver via: `gcc-ar --version` -> 0
stdout:
GNU ar (GNU Binutils) 2.45.0
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
-----------
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64

Executing subproject gizmo method cargo 

meson.build:9: WARNING: Cargo subproject is an experimental feature and has no backwards compatibility guarantees.
-----------
Detecting compiler via: `cc --version` -> 0
stdout:
cc (GCC) 15.2.1 20250813
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------
Running command: -cpp -x c -E -dM -
-----
-----------
Detecting linker via: `cc -Wl,--version` -> 0
stdout:
GNU ld (GNU Binutils) 2.45.0
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
-----------
stderr:
collect2 version 15.2.1 20250813
/usr/bin/ld -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccCld6RL.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../.. -L/lib -L/usr/lib --version -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crtn.o
-----------
-----------
Detecting compiler via: `rustc --version` -> 0
stdout:
rustc 1.89.0 (29483883e 2025-08-04) (Arch Linux rust 1:1.89.0-1)
-----------
-----------
Called: `rustc -C linker=cc -o /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/rusttest.exe /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanity.rs` -> 0
-----------
Called: `rustc -C linker=cc --crate-type staticlib --print native-static-libs /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanity.rs` -> 0
stderr:
warning: function `main` is never used
 --> /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/sanity.rs:1:4
  |
1 | fn main() {
  |    ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.

note: native-static-libs: -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc

warning: 1 warning emitted
-----------
Running test binary command:  /tmp/MesonCargoSubprojectTest-C/builddir/meson-private/rusttest.exe
-----------
Sanity check: `/tmp/MesonCargoSubprojectTest-C/builddir/meson-private/rusttest.exe` -> 0
Rust compiler for the host machine: rustc -C linker=cc (rustc 1.89.0 "1.89.0")
Rust linker for the host machine: rustc -C linker=cc ld.bfd 2.45.0
-----------
Called: `rustc -C linker=cc --print cfg` -> 0
stdout:
debug_assertions
panic="unwind"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_os="linux"
target_pointer_width="64"
target_vendor="unknown"
unix
-----------

meson.build:9:0: ERROR: Neither a subproject directory nor a gizmo-0.1-rs.wrap file was found.

Expected behavior
Meson should be able to setup and compile a project with a basic wrapped staticlib/cdylib Cargo subproject.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? No
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) - Arch Linux
  • what Python version are you using - 3.13.7
  • what meson --version - 1.9.0
  • what ninja --version if it's a Ninja build - n/a (setup fails), but 1.12.1

Metadata

Metadata

Assignees

Labels

dependencies:cargoIssues related to using cargo subprojects

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions