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

compiletest: improve robustness of LLVM version handling #132315

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Oct 29, 2024

Previously, extract_llvm_versions did some gymnastics for llvm versions by combining (major, minor, patch) into a combined version integer, but that is not very robust and made it difficult to add max-llvm-major-version. This PR tries to:

  • Improve llvm version handling robustness by parsing and representing the version as a semver. We intentionally deviate from strict semver standards by allowing omission of minor and patch versions. They default to 0 when absent. This is for convenience to allow the user to write e.g. //@ min-llvm-version: 18 instead of having to spell out the full major.minor.patch semver string //@ min-llvm-verison: 18.0.0.
  • Adjust some panic messages to include a bit more context about why the version string was rejected.

Prerequisite for #132310.

r? bootstrap (or compiler)

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 29, 2024
Comment on lines -1126 to -1131
let version = match *components {
[a] => a * 10_000,
[a, b] => a * 10_000 + b * 100,
[a, b, c] => a * 10_000 + b * 100 + c,
_ => panic!("Malformed version"),
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Specifically, this

@jieyouxu
Copy link
Member Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 29, 2024
@jieyouxu jieyouxu added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 29, 2024
@jieyouxu jieyouxu force-pushed the extract-llvm-version branch from a7b20ef to 8b92efb Compare October 29, 2024 13:55
@jieyouxu
Copy link
Member Author

(Brought back a few specific test cases, no functional changes)

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu closed this Oct 29, 2024
@jieyouxu jieyouxu reopened this Oct 29, 2024
@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2024
@jieyouxu jieyouxu force-pushed the extract-llvm-version branch from 8b92efb to e419b3d Compare October 30, 2024 04:56
@rustbot
Copy link
Collaborator

rustbot commented Oct 30, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@jieyouxu
Copy link
Member Author

jieyouxu commented Oct 30, 2024

Changes since last review:

  • Use semver as suggested for handling the version, dropping hand-rolled LlvmVersion-related logic. The extraction logic facades over semver::Version parsing to permit omitting minor and patch version components.
  • Obviously, this means that adding semver as a dependency to compiletest, but semver was already in workspace deps anyway.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 30, 2024
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

LGTM - Waiting for CI.

@onur-ozkan
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 30, 2024

📌 Commit e419b3d has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 30, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#130098 (Reject generic self types.)
 - rust-lang#131096 (rustdoc: Remove usage of `allow(unused)` attribute on `no_run` merged doctests)
 - rust-lang#132315 (compiletest: improve robustness of LLVM version handling)
 - rust-lang#132346 (Some graphviz tweaks)
 - rust-lang#132359 (Fix AIX libc call char type from i8 to u8)
 - rust-lang#132360 (Un-vacation myself)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c22832f into rust-lang:master Oct 30, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 30, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 30, 2024
Rollup merge of rust-lang#132315 - jieyouxu:extract-llvm-version, r=onur-ozkan

compiletest: improve robustness of LLVM version handling

Previously, `extract_llvm_versions` did some gymnastics for llvm versions by combining `(major, minor, patch)` into a combined version integer, but that is not very robust and made it difficult to add `max-llvm-major-version`. This PR tries to:

- Improve llvm version handling robustness by parsing and representing the version as a semver. We intentionally deviate from strict semver standards by allowing omission of minor and patch versions. They default to `0` when absent. This is for convenience to allow the user to write e.g. `//@ min-llvm-version: 18` instead of having to spell out the full `major.minor.patch` semver string `//@ min-llvm-verison: 18.0.0`.
- Adjust some panic messages to include a bit more context about *why* the version string was rejected.

Prerequisite for rust-lang#132310.

r? bootstrap (or compiler)
@jieyouxu jieyouxu deleted the extract-llvm-version branch October 31, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants