Skip to content

Target.Cpu.Feature.isEnabled() does not check dependencies #11999

@TwoClocks

Description

@TwoClocks

Zig Version

0.10.0-dev.2836+2360f8c49

Steps to Reproduce

This could be a misunderstanding on my part, but I think this should work.

The following test fails the last two asserts.

test "feature deps" {
    const arm = std.Target.arm;
    const cpu = arm.cpu.arm1020e;
    const v5te = @enumToInt(arm.Feature.v5te);
    const v5t = @enumToInt(arm.Feature.has_v5t);
    const v4t = @enumToInt(arm.Feature.has_v4t);
    std.debug.assert( cpu.features.isEnabled( v5te ) == true );
    std.debug.assert( cpu.features.isEnabled( v5t ) == true );
    std.debug.assert( cpu.features.isEnabled( v4t ) == true );
}

arm1020e is defined as

pub const arm1020e = CpuModel{
    .name = "arm1020e",
    .llvm_name = "arm1020e",
    .features = featureSet(&[_]Feature{
        .v5te,
    }),
};

.v5te is defined as

result[@enumToInt(Feature.v5te)] = .{
    .llvm_name = "armv5te",
    .description = "ARMv5te architecture",
    .dependencies = featureSet(&[_]Feature{
        .has_v5te,
        .strict_align,
    }),
};

.has_v5te is defined as

result[@enumToInt(Feature.has_v5te)] = .{
    .llvm_name = "v5te",
    .description = "Support ARM v5TE, v5TEj, and v5TExp instructions",
    .dependencies = featureSet(&[_]Feature{
        .has_v5t,
    }),
};

.has_v5t is defined as

result[@enumToInt(Feature.has_v5t)] = .{
    .llvm_name = "v5t",
    .description = "Support ARM v5T instructions",
    .dependencies = featureSet(&[_]Feature{
        .has_v4t,
    }),
};

So I think that test should work. Unless there is another pattern to use?

Expected Behavior

All the asserts should pass

Actual Behavior

The last two asserts fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions