Source
pub fn fromTarget(target: Target) Query {
var result: Query = .{
.cpu_arch = target.cpu.arch,
.cpu_model = .{ .explicit = target.cpu.model },
.os_tag = target.os.tag,
.os_version_min = undefined,
.os_version_max = undefined,
.abi = target.abi,
.glibc_version = if (target.abi.isGnu()) target.os.versionRange().gnuLibCVersion() else null,
.android_api_level = if (target.abi.isAndroid()) target.os.version_range.linux.android else null,
};
result.updateOsVersionRange(target.os);
const all_features = target.cpu.arch.allFeaturesList();
var cpu_model_set = target.cpu.model.features;
cpu_model_set.populateDependencies(all_features);
{
// The "add" set is the full set with the CPU Model set removed.
const add_set = &result.cpu_features_add;
add_set.* = target.cpu.features;
add_set.removeFeatureSet(cpu_model_set);
}
{
// The "sub" set is the features that are on in CPU Model set and off in the full set.
const sub_set = &result.cpu_features_sub;
sub_set.* = cpu_model_set;
sub_set.removeFeatureSet(target.cpu.features);
}
return result;
}