[PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0

Paolo Bonzini posted 14 patches 1 year, 3 months ago
There is a newer version of this series
[PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0
Posted by Paolo Bonzini 1 year, 3 months ago
Replay the configuration that would be computed by build.rs when compiling
on a 1.63.0 compiler.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/subprojects/packagefiles/proc-macro2-1-rs/meson.build b/subprojects/packagefiles/proc-macro2-1-rs/meson.build
index 818ec59336b..8e601b50ccc 100644
--- a/subprojects/packagefiles/proc-macro2-1-rs/meson.build
+++ b/subprojects/packagefiles/proc-macro2-1-rs/meson.build
@@ -15,7 +15,9 @@ _proc_macro2_rs = static_library(
   rust_abi: 'rust',
   rust_args: [
     '--cfg', 'feature="proc-macro"',
-    '--cfg', 'span_locations',
+    '--cfg', 'no_literal_byte_character',
+    '--cfg', 'no_literal_c_string',
+    '--cfg', 'no_source_text',
     '--cfg', 'wrap_proc_macro',
   ],
   dependencies: [
-- 
2.46.2
Re: [PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0
Posted by Junjie Mao 1 year, 3 months ago
Paolo Bonzini <pbonzini@redhat.com> writes:

> Replay the configuration that would be computed by build.rs when compiling
> on a 1.63.0 compiler.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Junjie Mao <junjie.mao@hotmail.com>

One question below.

> ---
>  subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/subprojects/packagefiles/proc-macro2-1-rs/meson.build b/subprojects/packagefiles/proc-macro2-1-rs/meson.build
> index 818ec59336b..8e601b50ccc 100644
> --- a/subprojects/packagefiles/proc-macro2-1-rs/meson.build
> +++ b/subprojects/packagefiles/proc-macro2-1-rs/meson.build
> @@ -15,7 +15,9 @@ _proc_macro2_rs = static_library(
>    rust_abi: 'rust',
>    rust_args: [
>      '--cfg', 'feature="proc-macro"',
> -    '--cfg', 'span_locations',

'span_locations' is not subject to any version check in build.rs. Is it
removed because of its performance penalty and the fact that we are not
using it anywhere?

--
Best Regards
Junjie Mao
Re: [PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0
Posted by Paolo Bonzini 1 year, 3 months ago
On Thu, Oct 24, 2024 at 4:35 AM Junjie Mao <junjie.mao@hotmail.com> wrote:
>
>
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
> > Replay the configuration that would be computed by build.rs when compiling
> > on a 1.63.0 compiler.
> >
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
> Reviewed-by: Junjie Mao <junjie.mao@hotmail.com>
>
> One question below.
>
> > ---
> >  subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/subprojects/packagefiles/proc-macro2-1-rs/meson.build b/subprojects/packagefiles/proc-macro2-1-rs/meson.build
> > index 818ec59336b..8e601b50ccc 100644
> > --- a/subprojects/packagefiles/proc-macro2-1-rs/meson.build
> > +++ b/subprojects/packagefiles/proc-macro2-1-rs/meson.build
> > @@ -15,7 +15,9 @@ _proc_macro2_rs = static_library(
> >    rust_abi: 'rust',
> >    rust_args: [
> >      '--cfg', 'feature="proc-macro"',
> > -    '--cfg', 'span_locations',
>
> 'span_locations' is not subject to any version check in build.rs. Is it
> removed because of its performance penalty and the fact that we are not
> using it anywhere?

The docs say "When executing in a procedural macro context, the
returned line/column are only meaningful if compiled with a nightly
toolchain. The stable toolchain does not have this information
available. When executing outside of a procedural macro, such as
main.rs or build.rs, the line/column are always meaningful regardless
of toolchain". So for our case it seems useless.

Paolo
Re: [PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0
Posted by Paolo Bonzini 1 year, 3 months ago
On Thu, Oct 24, 2024 at 11:02 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
> > 'span_locations' is not subject to any version check in build.rs. Is it
> > removed because of its performance penalty and the fact that we are not
> > using it anywhere?
>
> The docs say "When executing in a procedural macro context, the
> returned line/column are only meaningful if compiled with a nightly
> toolchain. The stable toolchain does not have this information
> available. When executing outside of a procedural macro, such as
> main.rs or build.rs, the line/column are always meaningful regardless
> of toolchain". So for our case it seems useless.

Ah, it's also removed because we don't specify it the feature in
qemu-api-macros/Cargo.toml, and therefore the build script does not
emit the corresponding cargo:rustc-cfg line.

$ OUT_DIR=$PWD/proc-macro2-0b9b0b4e3b86e043 \
   RUSTC=$(rustup +1.63.0 which  rustc) \
   proc-macro2-0b9b0b4e3b86e043/build-script-build
cargo:rustc-cfg=no_source_text
cargo:rustc-cfg=no_literal_byte_character
cargo:rustc-cfg=no_literal_c_string
cargo:rerun-if-changed=build/probe.rs
cargo:rustc-cfg=wrap_proc_macro
cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP

Paolo