mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 08:33:06 +00:00
Merge pull request #18498 from castholm/cpu-cortex-m-optional-deps
Don't enable optional ARM Cortex-M series CPU features by default
This commit is contained in:
commit
157cdaee0e
@ -2204,9 +2204,7 @@ pub const cpu = struct {
|
||||
.name = "cortex_m33",
|
||||
.llvm_name = "cortex-m33",
|
||||
.features = featureSet(&[_]Feature{
|
||||
.dsp,
|
||||
.fix_cmse_cve_2021_35465,
|
||||
.fp_armv8d16sp,
|
||||
.loop_align,
|
||||
.no_branch_predictor,
|
||||
.slowfpvfmx,
|
||||
@ -2219,9 +2217,7 @@ pub const cpu = struct {
|
||||
.name = "cortex_m35p",
|
||||
.llvm_name = "cortex-m35p",
|
||||
.features = featureSet(&[_]Feature{
|
||||
.dsp,
|
||||
.fix_cmse_cve_2021_35465,
|
||||
.fp_armv8d16sp,
|
||||
.loop_align,
|
||||
.no_branch_predictor,
|
||||
.slowfpvfmx,
|
||||
@ -2240,17 +2236,15 @@ pub const cpu = struct {
|
||||
.slowfpvmlx,
|
||||
.use_misched,
|
||||
.v7em,
|
||||
.vfp4d16sp,
|
||||
}),
|
||||
};
|
||||
pub const cortex_m55 = CpuModel{
|
||||
.name = "cortex_m55",
|
||||
.llvm_name = "cortex-m55",
|
||||
.features = featureSet(&[_]Feature{
|
||||
.dsp,
|
||||
.fix_cmse_cve_2021_35465,
|
||||
.fp_armv8d16,
|
||||
.loop_align,
|
||||
.mve_fp,
|
||||
.no_branch_predictor,
|
||||
.slowfpvmlx,
|
||||
.use_misched,
|
||||
@ -2261,7 +2255,6 @@ pub const cpu = struct {
|
||||
.name = "cortex_m7",
|
||||
.llvm_name = "cortex-m7",
|
||||
.features = featureSet(&[_]Feature{
|
||||
.fp_armv8d16,
|
||||
.use_mipipeliner,
|
||||
.use_misched,
|
||||
.v7em,
|
||||
@ -2271,9 +2264,8 @@ pub const cpu = struct {
|
||||
.name = "cortex_m85",
|
||||
.llvm_name = "cortex-m85",
|
||||
.features = featureSet(&[_]Feature{
|
||||
.fp_armv8d16,
|
||||
.mve_fp,
|
||||
.pacbti,
|
||||
.dsp,
|
||||
.trustzone,
|
||||
.use_misched,
|
||||
.v8_1m_main,
|
||||
}),
|
||||
|
@ -16,6 +16,7 @@ const FeatureOverride = struct {
|
||||
flatten: bool = false,
|
||||
zig_name: ?[]const u8 = null,
|
||||
desc: ?[]const u8 = null,
|
||||
omit_deps: []const []const u8 = &.{},
|
||||
extra_deps: []const []const u8 = &.{},
|
||||
};
|
||||
|
||||
@ -378,6 +379,31 @@ const llvm_targets = [_]LlvmTarget{
|
||||
.llvm_name = "cortex-a710",
|
||||
.flatten = true,
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-m4",
|
||||
.omit_deps = &.{"vfp4d16sp"},
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-m7",
|
||||
.omit_deps = &.{"fp_armv8d16"},
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-m33",
|
||||
.omit_deps = &.{ "fp_armv8d16sp", "dsp" },
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-m35p",
|
||||
.omit_deps = &.{ "fp_armv8d16sp", "dsp" },
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-m55",
|
||||
.omit_deps = &.{ "mve_fp", "fp_armv8d16" },
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-m85",
|
||||
.omit_deps = &.{ "mve_fp", "pacbti", "fp_armv8d16" },
|
||||
.extra_deps = &.{"trustzone"},
|
||||
},
|
||||
.{
|
||||
.llvm_name = "cortex-x1c",
|
||||
.flatten = true,
|
||||
@ -1114,18 +1140,8 @@ fn processOneTarget(job: Job) anyerror!void {
|
||||
var deps = std.ArrayList([]const u8).init(arena);
|
||||
var omit = false;
|
||||
var flatten = false;
|
||||
const implies = kv.value_ptr.object.get("Implies").?.array;
|
||||
for (implies.items) |imply| {
|
||||
const other_key = imply.object.get("def").?.string;
|
||||
const other_obj = &root_map.getPtr(other_key).?.object;
|
||||
const other_llvm_name = other_obj.get("Name").?.string;
|
||||
const other_zig_name = (try llvmNameToZigNameOmit(
|
||||
arena,
|
||||
llvm_target,
|
||||
other_llvm_name,
|
||||
)) orelse continue;
|
||||
try deps.append(other_zig_name);
|
||||
}
|
||||
var omit_deps: []const []const u8 = &.{};
|
||||
var extra_deps: []const []const u8 = &.{};
|
||||
for (llvm_target.feature_overrides) |feature_override| {
|
||||
if (mem.eql(u8, llvm_name, feature_override.llvm_name)) {
|
||||
if (feature_override.omit) {
|
||||
@ -1142,12 +1158,30 @@ fn processOneTarget(job: Job) anyerror!void {
|
||||
if (feature_override.desc) |override_desc| {
|
||||
desc = override_desc;
|
||||
}
|
||||
for (feature_override.extra_deps) |extra_dep| {
|
||||
try deps.append(extra_dep);
|
||||
}
|
||||
omit_deps = feature_override.omit_deps;
|
||||
extra_deps = feature_override.extra_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const implies = kv.value_ptr.object.get("Implies").?.array;
|
||||
for (implies.items) |imply| {
|
||||
const other_key = imply.object.get("def").?.string;
|
||||
const other_obj = &root_map.getPtr(other_key).?.object;
|
||||
const other_llvm_name = other_obj.get("Name").?.string;
|
||||
const other_zig_name = (try llvmNameToZigNameOmit(
|
||||
arena,
|
||||
llvm_target,
|
||||
other_llvm_name,
|
||||
)) orelse continue;
|
||||
for (omit_deps) |omit_dep| {
|
||||
if (mem.eql(u8, other_zig_name, omit_dep)) break;
|
||||
} else {
|
||||
try deps.append(other_zig_name);
|
||||
}
|
||||
}
|
||||
for (extra_deps) |extra_dep| {
|
||||
try deps.append(extra_dep);
|
||||
}
|
||||
const feature: Feature = .{
|
||||
.llvm_name = llvm_name,
|
||||
.zig_name = zig_name,
|
||||
@ -1170,6 +1204,21 @@ fn processOneTarget(job: Job) anyerror!void {
|
||||
|
||||
var zig_name = try llvmNameToZigName(arena, llvm_name);
|
||||
var deps = std.ArrayList([]const u8).init(arena);
|
||||
var omit_deps: []const []const u8 = &.{};
|
||||
var extra_deps: []const []const u8 = &.{};
|
||||
for (llvm_target.feature_overrides) |feature_override| {
|
||||
if (mem.eql(u8, llvm_name, feature_override.llvm_name)) {
|
||||
if (feature_override.omit) {
|
||||
continue :root_it;
|
||||
}
|
||||
if (feature_override.zig_name) |override_name| {
|
||||
zig_name = override_name;
|
||||
}
|
||||
omit_deps = feature_override.omit_deps;
|
||||
extra_deps = feature_override.extra_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const features = kv.value_ptr.object.get("Features").?.array;
|
||||
for (features.items) |feature| {
|
||||
const feature_key = feature.object.get("def").?.string;
|
||||
@ -1181,7 +1230,14 @@ fn processOneTarget(job: Job) anyerror!void {
|
||||
llvm_target,
|
||||
feature_llvm_name,
|
||||
)) orelse continue;
|
||||
try deps.append(feature_zig_name);
|
||||
for (omit_deps) |omit_dep| {
|
||||
if (mem.eql(u8, feature_zig_name, omit_dep)) break;
|
||||
} else {
|
||||
try deps.append(feature_zig_name);
|
||||
}
|
||||
}
|
||||
for (extra_deps) |extra_dep| {
|
||||
try deps.append(extra_dep);
|
||||
}
|
||||
const tune_features = kv.value_ptr.object.get("TuneFeatures").?.array;
|
||||
for (tune_features.items) |feature| {
|
||||
@ -1228,7 +1284,7 @@ fn processOneTarget(job: Job) anyerror!void {
|
||||
mem.sort(Feature, all_features.items, {}, featureLessThan);
|
||||
mem.sort(Cpu, all_cpus.items, {}, cpuLessThan);
|
||||
|
||||
const target_sub_path = try fs.path.join(arena, &.{ "lib", "std", "target" });
|
||||
const target_sub_path = try fs.path.join(arena, &.{ "lib", "std", "Target" });
|
||||
var target_dir = try job.zig_src_dir.makeOpenPath(target_sub_path, .{});
|
||||
defer target_dir.close();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user