Skip to content

Conversation

bonzini
Copy link
Collaborator

@bonzini bonzini commented Aug 28, 2025

If a dependency includes object files, they have to be added to the doctest. However, NinjaBackend was not running flatten_object_list on the doctest.

@bonzini bonzini requested a review from jpakkane as a code owner August 28, 2025 10:19
@bonzini bonzini added this to the 1.9.1 milestone Aug 28, 2025
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 8, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 11, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 12, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
@bonzini bonzini force-pushed the rust-doctest-objects branch from 206cac8 to 9e06656 Compare September 13, 2025 07:16
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 13, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 13, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Sep 16, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me, just one small nit.

@eli-schwartz asked whether this was a bug fix or a feature new... it's a good question. I think this works correctly for rust targets that are not doctests? If that's the case then I'd consider this a bug fix, if this doesn't work at all it's probably a new feature.

@bonzini bonzini force-pushed the rust-doctest-objects branch from 9e06656 to e82f314 Compare September 16, 2025 16:11
@bonzini
Copy link
Collaborator Author

bonzini commented Sep 16, 2025

If that's the case then I'd consider this a bug fix, if this doesn't work at all it's probably a new feature.

objects are a new feature in 1.9.0, but it only worked outside doctests. There are a bunch of existing testcases in rust/27 objects.

backends.py has an interesting idiom for keeping the unique
elements of a list.  This is much faster than OrderedSet:

* dict.fromkeys() vs. OrderedSet.__init__(): 35% faster on Python
  3.13, 50-60% faster on Python 3.10

* list(d) (d is a dict) vs. list(os) (os is an OrderedSet): up to
  25% faster on Python 3.13, up to 15% faster on Python 3.10
  though it tapers out after a few hundred elements.

Add a function to mesonlib to encapsulate this idiom.

Signed-off-by: Paolo Bonzini <[email protected]>
If a depedency includes object files, they have to be added to the doctest.
However, NinjaBackend was not running flatten_object_list on the doctest.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini force-pushed the rust-doctest-objects branch from e82f314 to d8633f6 Compare September 16, 2025 16:34
@dcbaker
Copy link
Member

dcbaker commented Sep 16, 2025

Then for posterity, I would consider this a bug fix rather than a new feature.

stsquad pushed a commit to qemu/qemu that referenced this pull request Sep 17, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
stsquad pushed a commit to qemu/qemu that referenced this pull request Sep 18, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
abaire pushed a commit to abaire/xemu that referenced this pull request Sep 19, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>

xemu: Update minimum Meson requirement to 1.8.4 to facilitate building on
macOS with Clang 17.
Fixes xemu-project#2442
mborgerson pushed a commit to xemu-project/xemu that referenced this pull request Sep 19, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>

xemu: Update minimum Meson requirement to 1.8.4 to facilitate building on
macOS with Clang 17.
Fixes #2442
@bonzini bonzini requested a review from dcbaker September 20, 2025 14:15
@eli-schwartz eli-schwartz modified the milestones: 1.9.1, 1.9.2 Sep 22, 2025
pbo-linaro pushed a commit to pbo-linaro/qemu-ci that referenced this pull request Sep 22, 2025
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see mesonbuild/meson#14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
@dcbaker dcbaker merged commit bc039fa into mesonbuild:master Sep 22, 2025
30 of 32 checks passed
@bonzini bonzini deleted the rust-doctest-objects branch September 22, 2025 17:39
@bonzini bonzini modified the milestones: 1.9.2, 1.9.1 Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants