Skip to content

Conversation

TibboddiT
Copy link
Contributor

Some utsname.release values might not be fully semver compliant. For example, on one of my old android phones, uname returns this release version: 3.18.120-perf+ (see https://github.com/torvalds/linux/blob/8f5ae30d69d7543eee0d70083daf4de8fe15d585/scripts/setlocalversion#L197-L210).

This PR adds the SemanticVersion.parseUtsnameRelease function which handles versions ending with a '+' without a build version, adds / updates related tests, and updates system.zig.resolveTargetQuery to use the specialized function when populating os.version_range for relevant operating systems.

@@ -292,9 +317,18 @@ test "precedence" {

test "zig_version" {
// An approximate Zig build that predates this test.
const older_version: Version = .{ .major = 0, .minor = 8, .patch = 0, .pre = "dev.874" };
const older_version: std.SemanticVersion = .{ .major = 0, .minor = 8, .patch = 0, .pre = "dev.874" };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this change, I was getting this error while trying to run zig test lib/std/SemanticVersion.zig:

lib/std/SemanticVersion.zig:323:70: error: expected type 'SemanticVersion', found 'SemanticVersion'
    const compatible = comptime @import("builtin").zig_version.order(older_version) == .gt;
                                                                     ^~~~~~~~~~~~~
lib/std/SemanticVersion.zig:1:1: note: struct declared here
//! A software version formatted according to the Semantic Versioning 2.0.0 specification.
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tibbo/Builds/Zig/zig-x86_64-linux-0.16.0-dev.27+83f773fc6/lib/std/SemanticVersion.zig:1:1: note: struct declared here
/home/tibbo/Builds/Zig/zig-x86_64-linux-0.16.0-dev.27+83f773fc6/lib/std/SemanticVersion.zig:33:33: note: parameter type declared here
pub fn order(lhs: Version, rhs: Version) std.math.Order {
                                ^~~~~~~

Copy link
Member

Choose a reason for hiding this comment

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

Looks like you didn't use --zig-lib-dir to test and ended up with two standard libraries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, messed up zig lib dir on my side. I will revert this change if the PR is accepted to avoid wasting CI resources.

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.

2 participants