-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
remove the concept of "sub-architecture" in favor of CPU features #4261
Comments
This sounds like it's mixing cpu's, arches, and features. The way I understand it is a given arm core/cpu, eg the cortex-m7, only has one arch (ex armv7em) but the arch can be backwards compatible with previous arches. Then the features (eg FPU, MPU) depend on options the core and/or arch supports and the actual part number / hw config. See https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures and https://en.wikipedia.org/wiki/ARM_Cortex-M. All the At the end of the day it should be possible to target a specific arch + features or a specific cpu + features as you can already do with gcc https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html |
@frmdstryr everything in your comment here is compatible with this proposal |
Cool, ship it. #4264 is working fine for me (that PR allowed me to enable the FPU) so if anything breaks I'll let you know. |
Here's what it will come down to for Zig programmers: use case 1, specifying a .target = Target{
.Cross = CrossTarget{
+ .cpu = Target.Cpu.baseline(.x86_64),
.os = .linux,
- .arch = .x86_64,
.abi = .none,
- .cpu_features = Target.Arch.x86_64.getBaselineCpuFeatures(),
},
},
.target = Target{
.Cross = CrossTarget{
+ .cpu = Target.Cpu.baseline(.aarch64),
.os = .linux,
- .arch = Target.Arch{ .aarch64 = .v8a },
- .cpu_features = (Target.Arch{ .aarch64 = .v8a }).getBaselineCpuFeatures(),
.abi = .musl,
},
},
- .target = Target{
- .Cross = CrossTarget{
- .os = .linux,
- .arch = Target.Arch{ .arm = .v8a },
- .cpu_features = (Target.Arch{ .arm = .v8a }).getBaselineCpuFeatures(),
- .abi = .none,
- },
- },
+ .target = Target.parse(.{
+ .arch_os_abi = "arm-linux-none",
+ .cpu_features = "generic+v8a",
+ }) catch unreachable,
}, use case 2, specifying targets on the comand line:
|
in favor of CPU features. Also rearrange the `std.Target` data structure. * note: `@import("builtin")` was already deprecated in favor of `@import("std").builtin`. * `std.builtin.arch` is now deprecated in favor of `std.builtin.cpu.arch`. * `std.Target.CpuFeatures.Cpu` is now `std.Target.Cpu.Model`. * `std.Target.CpuFeatures` is now `std.Target.Cpu`. * `std.Target` no longer has an `arch` field. Instead it has a `cpu` field, which has `arch`, `model`, and `features`. * `std.Target` no longer has a `cpu_features` field. * `std.Target.Arch` is moved to `std.Target.Cpu.Arch` and it is an enum instead of a tagged union. * `std.Target.parseOs` is moved to `std.Target.Os.parse`. * `std.Target.parseAbi` is moved to `std.Target.Abi.parse`. * `std.Target.parseArchSub` is only for arch now and moved to `std.Target.Cpu.Arch.parse`. * `std.Target.parse` is improved to accept CPU name and features. * `std.Target.Arch.getBaselineCpuFeatures` is moved to `std.Target.Cpu.baseline`. * `std.Target.allCpus` is renamed to `std.Target.allCpuModels`. * `std.Target.defaultAbi` is moved to `std.Target.Abi.default`. * Significant cleanup of aarch64 and arm CPU features, resulting in the needed bit count for cpu feature set going from 174 to 138. * Add `std.Target.Cpu.Feature.Set.addFeatureSet` for merging feature sets together. `-target-feature` and `-target-cpu` are removed in favor of `-mcpu`, to conform to established conventions, and it gains additional power to support cpu features. The syntax is: -mcpu=name+on1+on2-off1-off2 closes #4261
Looks like a nice cleanup. |
So this const arch = builtin.Arch{ .thumb = .v7em };
const cpu = &builtin.Target.arm.cpu.cortex_m7;
const elf = b.addExecutable("firmware.elf", "startup.zig");
elf.setTheTarget(builtin.Target{
.Cross = .{
.arch = arch,
.os = .freestanding,
.abi = .none,
.cpu_features = builtin.Target.CpuFeatures.initFromCpu(arch, cpu),
},
}); is now: const elf = b.addExecutable("firmware.elf", "startup.zig");
elf.setTheTarget(builtin.Target.parse(.{
.arch_os_abi="thumb-freestanding-none",
.cpu_features="cortex_m7",
}) catch unreachable); and it builds and runs fine (with the fpu), thanks! |
For consistency it would be nice if it worked with either underscores or dashes, as |
|
the "sub-architecture" part of the target overlaps with specifying target CPU features:
arm target features:
I propose to entirely remove "sub-architecture" concept from the language & CLI, and rely instead on the more-powerful ability to specify CPU features. Each "sub-architecture" is represented as a CPU feature that depends on the previous one.
The text was updated successfully, but these errors were encountered: