diff mbox series

[12/16] rust: allow version 1.63.0 of rustc

Message ID 20241015131735.518771-13-pbonzini@redhat.com (mailing list archive)
State New
Headers show
Series rust: allow older versions of rustc and bindgen | expand

Commit Message

Paolo Bonzini Oct. 15, 2024, 1:17 p.m. UTC
All constructs introduced by newer versions of Rust have been removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Junjie Mao Oct. 16, 2024, 6:01 a.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> All constructs introduced by newer versions of Rust have been removed.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  meson.build | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 175b8d82228..0e279d245b4 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -76,11 +76,11 @@ if not get_option('rust').disabled() and add_languages('rust', required: get_opt
>      and add_languages('rust', required: get_option('rust'), native: true)
>    rustc = meson.get_compiler('rust')
>    have_rust = true
> -  if rustc.version().version_compare('<1.80.0')
> +  if rustc.version().version_compare('<1.63.0')

In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from
apt) the feature `proc_macro_byte_character` is not yet stablized but
used in proc-macro2. Downgrading proc-macro2 to 1.0.79 [1] and syn to
2.0.58 fixes that issue for me.

[1] https://github.com/drmingdrmer/openraft/commit/d496b6db4c6128d33f0f211165c08a7925cf20f7

Here're my changes:

diff --git a/subprojects/proc-macro2-1-rs.wrap b/subprojects/proc-macro2-1-rs.wrap
index 7053e2c013..d5713b45d7 100644
--- a/subprojects/proc-macro2-1-rs.wrap
+++ b/subprojects/proc-macro2-1-rs.wrap
@@ -1,7 +1,7 @@
 [wrap-file]
-directory = proc-macro2-1.0.84
-source_url = https://crates.io/api/v1/crates/proc-macro2/1.0.84/download
-source_filename = proc-macro2-1.0.84.0.tar.gz
-source_hash = ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6
+directory = proc-macro2-1.0.79
+source_url = https://crates.io/api/v1/crates/proc-macro2/1.0.79/download
+source_filename = proc-macro2-1.0.79.0.tar.gz
+source_hash = e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e
 #method = cargo
 patch_directory = proc-macro2-1-rs
diff --git a/subprojects/syn-2-rs.wrap b/subprojects/syn-2-rs.wrap
index 13ffdac3c3..9d413a0c57 100644
--- a/subprojects/syn-2-rs.wrap
+++ b/subprojects/syn-2-rs.wrap
@@ -1,7 +1,7 @@
 [wrap-file]
-directory = syn-2.0.66
-source_url = https://crates.io/api/v1/crates/syn/2.0.66/download
-source_filename = syn-2.0.66.0.tar.gz
-source_hash = c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5
+directory = syn-2.0.58
+source_url = https://crates.io/api/v1/crates/syn/2.0.58/download
+source_filename = syn-2.0.58.0.tar.gz
+source_hash = 44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687
 #method = cargo
 patch_directory = syn-2-rs

--
Best Regards
Junjie Mao

>      if get_option('rust').enabled()
> -      error('rustc version ' + rustc.version() + ' is unsupported: Please upgrade to at least 1.80.0')
> +      error('rustc version ' + rustc.version() + ' is unsupported: Please upgrade to at least 1.63.0')
>      else
> -      warning('rustc version ' + rustc.version() + ' is unsupported: Disabling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.')
> +      warning('rustc version ' + rustc.version() + ' is unsupported: Disabling Rust compilation. Please upgrade to at least 1.63.0 to use Rust.')
>        have_rust = false
>      endif
>    endif
Paolo Bonzini Oct. 16, 2024, 7:51 a.m. UTC | #2
Il mer 16 ott 2024, 08:10 Junjie Mao <junjie.mao@hotmail.com> ha scritto:

> In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from
> apt) the feature `proc_macro_byte_character` is not yet stablized but
> used in proc-macro2. Downgrading proc-macro2 to 1.0.79 [1] and syn to
> 2.0.58 fixes that issue for me.
>

This is handled by patch 5. Try "meson subprojects update --reset".

Paolo

[1]
> https://github.com/drmingdrmer/openraft/commit/d496b6db4c6128d33f0f211165c08a7925cf20f7
>
> Here're my changes:
>
> diff --git a/subprojects/proc-macro2-1-rs.wrap
> b/subprojects/proc-macro2-1-rs.wrap
> index 7053e2c013..d5713b45d7 100644
> --- a/subprojects/proc-macro2-1-rs.wrap
> +++ b/subprojects/proc-macro2-1-rs.wrap
> @@ -1,7 +1,7 @@
>  [wrap-file]
> -directory = proc-macro2-1.0.84
> -source_url = https://crates.io/api/v1/crates/proc-macro2/1.0.84/download
> -source_filename
> <https://crates.io/api/v1/crates/proc-macro2/1.0.84/download-source_filename>
> = proc-macro2-1.0.84.0.tar.gz
> -source_hash =
> ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6
> +directory = proc-macro2-1.0.79
> +source_url = https://crates.io/api/v1/crates/proc-macro2/1.0.79/download
> +source_filename = proc-macro2-1.0.79.0.tar.gz
> +source_hash =
> e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e
>  #method = cargo
>  patch_directory = proc-macro2-1-rs
> diff --git a/subprojects/syn-2-rs.wrap b/subprojects/syn-2-rs.wrap
> index 13ffdac3c3..9d413a0c57 100644
> --- a/subprojects/syn-2-rs.wrap
> +++ b/subprojects/syn-2-rs.wrap
> @@ -1,7 +1,7 @@
>  [wrap-file]
> -directory = syn-2.0.66
> -source_url = https://crates.io/api/v1/crates/syn/2.0.66/download
> -source_filename
> <https://crates.io/api/v1/crates/syn/2.0.66/download-source_filename> =
> syn-2.0.66.0.tar.gz
> -source_hash =
> c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5
> +directory = syn-2.0.58
> +source_url = https://crates.io/api/v1/crates/syn/2.0.58/download
> +source_filename = syn-2.0.58.0.tar.gz
> +source_hash =
> 44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687
>  #method = cargo
>  patch_directory = syn-2-rs
>
> --
> Best Regards
> Junjie Mao
>
> >      if get_option('rust').enabled()
> > -      error('rustc version ' + rustc.version() + ' is unsupported:
> Please upgrade to at least 1.80.0')
> > +      error('rustc version ' + rustc.version() + ' is unsupported:
> Please upgrade to at least 1.63.0')
> >      else
> > -      warning('rustc version ' + rustc.version() + ' is unsupported:
> Disabling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.')
> > +      warning('rustc version ' + rustc.version() + ' is unsupported:
> Disabling Rust compilation. Please upgrade to at least 1.63.0 to use Rust.')
> >        have_rust = false
> >      endif
> >    endif
>
>
Junjie Mao Oct. 16, 2024, 9:53 a.m. UTC | #3
Paolo Bonzini <pbonzini@redhat.com> writes:

> Il mer 16 ott 2024, 08:10 Junjie Mao <junjie.mao@hotmail.com> ha scritto:
>
>  In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from
>  apt) the feature `proc_macro_byte_character` is not yet stablized but
>  used in proc-macro2. Downgrading proc-macro2 to 1.0.79 [1] and syn to
>  2.0.58 fixes that issue for me.
>
> This is handled by patch 5. Try "meson subprojects update --reset".
>

Yes, that works. Thanks for the info!

--
Best Regards
Junjie Mao
Junjie Mao Oct. 18, 2024, 2:44 a.m. UTC | #4
Junjie Mao <junjie.mao@hotmail.com> writes:

> Paolo Bonzini <pbonzini@redhat.com> writes:
>
>> Il mer 16 ott 2024, 08:10 Junjie Mao <junjie.mao@hotmail.com> ha scritto:
>>
>>  In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from
>>  apt) the feature `proc_macro_byte_character` is not yet stablized but
>>  used in proc-macro2. Downgrading proc-macro2 to 1.0.79 [1] and syn to
>>  2.0.58 fixes that issue for me.
>>
>> This is handled by patch 5. Try "meson subprojects update --reset".
>>
>
> Yes, that works. Thanks for the info!

After cleaning everything to build from scratch, I met another issue:

  bilge-0.2-rs| Downloading bilge-impl-0.2-rs source from https://crates.io/api/v1/crates/bilge-impl/0.2.0/download
  Download size: 24524
  Downloading: ..........
  bilge-0.2-rs| Applying diff file "bilge-impl-1.63.0.patch"
  bilge-0.2-rs| patching file src/shared/discriminant_assigner.rs
  bilge-0.2-rs| Hunk #1 FAILED at 26 (different line endings).
  bilge-0.2-rs| 1 out of 1 hunk FAILED -- saving rejects to file src/shared/discriminant_assigner.rs.rej
  bilge-0.2-rs| patching file src/shared/fallback.rs
  bilge-0.2-rs| Hunk #1 FAILED at 22 (different line endings).
  bilge-0.2-rs| 1 out of 1 hunk FAILED -- saving rejects to file src/shared/fallback.rs.rej

  ../subprojects/bilge-0.2.0/meson.build:9:0: ERROR: Failed to apply diff file "bilge-impl-1.63.0.patch"

It turns out that the sources in bilge-impl have CRLF line endings and
`patch` does not ignore that even with the `-l` option:

  ~/Projects/qemu/subprojects$ tar xf packagecache/bilge-impl-0.2.0.tar.gz
  ~/Projects/qemu/subprojects$ cd bilge-impl-0.2.0/
  ~/Projects/qemu/subprojects/bilge-impl-0.2.0$ patch -l -f -p1 -i ../packagefiles/bilge-impl-1.63.0.patch
  patching file src/shared/discriminant_assigner.rs
  Hunk #1 FAILED at 26 (different line endings).
  1 out of 1 hunk FAILED -- saving rejects to file src/shared/discriminant_assigner.rs.rej
  patching file src/shared/fallback.rs
  Hunk #1 FAILED at 22 (different line endings).
  1 out of 1 hunk FAILED -- saving rejects to file src/shared/fallback.rs.rej
  ~/Projects/qemu/subprojects/bilge-impl-0.2.0$ file src/shared/discriminant_assigner.rs
  src/shared/discriminant_assigner.rs: ASCII text, with CRLF line terminators

Meson uses patch with the command above as the first preference to apply
diffs. That command is not yet customizable.

--
Best Regards
Junjie Mao
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index 175b8d82228..0e279d245b4 100644
--- a/meson.build
+++ b/meson.build
@@ -76,11 +76,11 @@  if not get_option('rust').disabled() and add_languages('rust', required: get_opt
     and add_languages('rust', required: get_option('rust'), native: true)
   rustc = meson.get_compiler('rust')
   have_rust = true
-  if rustc.version().version_compare('<1.80.0')
+  if rustc.version().version_compare('<1.63.0')
     if get_option('rust').enabled()
-      error('rustc version ' + rustc.version() + ' is unsupported: Please upgrade to at least 1.80.0')
+      error('rustc version ' + rustc.version() + ' is unsupported: Please upgrade to at least 1.63.0')
     else
-      warning('rustc version ' + rustc.version() + ' is unsupported: Disabling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.')
+      warning('rustc version ' + rustc.version() + ' is unsupported: Disabling Rust compilation. Please upgrade to at least 1.63.0 to use Rust.')
       have_rust = false
     endif
   endif