Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the rustup toolchain channel regex #1148

Closed
wants to merge 1 commit into from

Conversation

xal-0
Copy link

@xal-0 xal-0 commented May 30, 2024

The regex used to extract the channel from the output of rustup show active-toolchain misidentifies aarch64 as part of the channel on Linux:

$ vargo build
error: rustup is using a toolchain with channel 1.76.0-aarch64, we expect 1.76.0
do you have a rustup override set?
$ rustup show active-toolchain
1.76.0-aarch64-unknown-linux-gnu (overridden by '/verus/rust-toolchain.toml')

This is the result of a regex that consumes - as part of the channel name: ^(([A-Za-z0-9.-]+)-[A-Za-z0-9_]+-[A-Za-z0-9]+-[A-Za-z0-9-]+)

The first capture group can't contain _, so it works on x86_64. According to the toolchain spec
grammar
, we'll need to use a less liberal regex to avoid capturing too much as the channel/date.

<channel>[-<date>][-<host>]

<channel>       = stable|beta|nightly|<major.minor>|<major.minor.patch>
<date>          = YYYY-MM-DD
<host>          = <target-triple>

The regex also causes problems on platforms that use a target "triple" that isn't a triple, like 1.76.0-aarch64-apple-darwin, so we make no assumptions about the number of --separated words in the target triple.

The regex used to extract the channel from the output of `rustup show
active-toolchain` misidentifies `aarch64` as part of the channel on Linux:

```
$ vargo build
error: rustup is using a toolchain with channel 1.76.0-aarch64, we expect 1.76.0
do you have a rustup override set?
$ rustup show active-toolchain
1.76.0-aarch64-unknown-linux-gnu (overridden by '/verus/rust-toolchain.toml')
```

This is the result of a regex that consumes `-` as part of the channel name:
`^(([A-Za-z0-9.-]+)-[A-Za-z0-9_]+-[A-Za-z0-9]+-[A-Za-z0-9-]+)`

The first capture group can't contain `_`, so it works on `x86_64`.  According
to the [toolchain spec
grammar](https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification),
we'll need to use a less liberal regex to avoid capturing too much as the
channel/date.

```
<channel>[-<date>][-<host>]

<channel>       = stable|beta|nightly|<major.minor>|<major.minor.patch>
<date>          = YYYY-MM-DD
<host>          = <target-triple>
```

The regex also causes problems on platforms that use a target "triple" that
isn't a triple, like `1.76.0-aarch64-apple-darwin`, so we make no assumptions
about the number of `-`-separated words in the target triple.
@parno
Copy link
Collaborator

parno commented May 30, 2024

I ran into this issue too. With help from @jaybosamiya, we came up with this alternate approach 592ad9b (ignore the accidental removal of the raw string annotation).

utaal added a commit that referenced this pull request Jul 12, 2024
* try and fix the channel regex for vstd build, similarly to #1148
@utaal
Copy link
Collaborator

utaal commented Jul 12, 2024

Sorry for the delay on this, and thanks @parno for the alternate approach.

I think the combination of 592ad9b and 560a538 should address the same issue. Both are now in main, so I'll close this. If a similar problem comes up again, please reopen, or open an issue.

@utaal utaal closed this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants