| ... | @@ -637,7 +637,7 @@ pub const Builder = struct { | ... | @@ -637,7 +637,7 @@ pub const Builder = struct { |
| 637 | "target", | 637 | "target", |
| 638 | "The CPU architecture, OS, and ABI to build for", | 638 | "The CPU architecture, OS, and ABI to build for", |
| 639 | ); | 639 | ); |
| 640 | const mcpu = self.option([]const u8, "cpu", "Target CPU"); | 640 | const mcpu = self.option([]const u8, "cpu", "Target CPU features to add or subtract"); |
| 641 | | 641 | |
| 642 | const triple = maybe_triple orelse return args.default_target; | 642 | const triple = maybe_triple orelse return args.default_target; |
| 643 | | 643 | |
| ... | @@ -699,20 +699,64 @@ pub const Builder = struct { | ... | @@ -699,20 +699,64 @@ pub const Builder = struct { |
| 699 | | 699 | |
| 700 | if (args.whitelist) |list| whitelist_check: { | 700 | if (args.whitelist) |list| whitelist_check: { |
| 701 | // Make sure it's a match of one of the list. | 701 | // Make sure it's a match of one of the list. |
| | 702 | var mismatch_triple = true; |
| | 703 | var mismatch_cpu_features = true; |
| | 704 | var whitelist_item = CrossTarget{}; |
| 702 | for (list) |t| { | 705 | for (list) |t| { |
| | 706 | mismatch_cpu_features = true; |
| | 707 | mismatch_triple = true; |
| | 708 | |
| 703 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 709 | const t_triple = t.zigTriple(self.allocator) catch unreachable; |
| 704 | if (mem.eql(u8, t_triple, selected_canonicalized_triple)) { | 710 | if (mem.eql(u8, t_triple, selected_canonicalized_triple)) { |
| 705 | break :whitelist_check; | 711 | mismatch_triple = false; |
| | 712 | whitelist_item = t; |
| | 713 | if (t.getCpuFeatures().isSuperSetOf(selected_target.getCpuFeatures())) { |
| | 714 | mismatch_cpu_features = false; |
| | 715 | break :whitelist_check; |
| | 716 | } else { |
| | 717 | break; |
| | 718 | } |
| 706 | } | 719 | } |
| 707 | } | 720 | } |
| 708 | warn("Chosen target '{s}' does not match one of the supported targets:\n", .{ | 721 | if (mismatch_triple) { |
| 709 | selected_canonicalized_triple, | 722 | warn("Chosen target '{s}' does not match one of the supported targets:\n", .{ |
| 710 | }); | 723 | selected_canonicalized_triple, |
| 711 | for (list) |t| { | 724 | }); |
| 712 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 725 | for (list) |t| { |
| 713 | warn(" {s}\n", .{t_triple}); | 726 | const t_triple = t.zigTriple(self.allocator) catch unreachable; |
| | 727 | warn(" {s}\n", .{t_triple}); |
| | 728 | } |
| | 729 | warn("\n", .{}); |
| | 730 | } else { |
| | 731 | assert(mismatch_cpu_features); |
| | 732 | const whitelist_cpu = whitelist_item.getCpu(); |
| | 733 | const selected_cpu = selected_target.getCpu(); |
| | 734 | warn("Chosen CPU model '{s}' does not match one of the supported targets:\n", .{ |
| | 735 | selected_cpu.model.name, |
| | 736 | }); |
| | 737 | warn(" Supported feature Set: ", .{}); |
| | 738 | const all_features = whitelist_cpu.arch.allFeaturesList(); |
| | 739 | var populated_cpu_features = whitelist_cpu.model.features; |
| | 740 | populated_cpu_features.populateDependencies(all_features); |
| | 741 | for (all_features) |feature, i_usize| { |
| | 742 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); |
| | 743 | const in_cpu_set = populated_cpu_features.isEnabled(i); |
| | 744 | if (in_cpu_set) { |
| | 745 | warn("{s} ", .{feature.name}); |
| | 746 | } |
| | 747 | } |
| | 748 | warn("\n", .{}); |
| | 749 | warn(" Remove: ", .{}); |
| | 750 | for (all_features) |feature, i_usize| { |
| | 751 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); |
| | 752 | const in_cpu_set = populated_cpu_features.isEnabled(i); |
| | 753 | const in_actual_set = selected_cpu.features.isEnabled(i); |
| | 754 | if (in_actual_set and !in_cpu_set) { |
| | 755 | warn("{s} ", .{feature.name}); |
| | 756 | } |
| | 757 | } |
| | 758 | warn("\n", .{}); |
| 714 | } | 759 | } |
| 715 | warn("\n", .{}); | | |
| 716 | self.markInvalidUserInput(); | 760 | self.markInvalidUserInput(); |
| 717 | return args.default_target; | 761 | return args.default_target; |
| 718 | } | 762 | } |