| ... | @@ -6798,6 +6798,43 @@ pub fn addCCArgs( | ... | @@ -6798,6 +6798,43 @@ pub fn addCCArgs( |
| 6798 | else => {}, | 6798 | else => {}, |
| 6799 | } | 6799 | } |
| 6800 | | 6800 | |
| | 6801 | const xclang_flag = switch (ext) { |
| | 6802 | .assembly, .assembly_with_cpp => "-Xclangas", |
| | 6803 | else => "-Xclang", |
| | 6804 | }; |
| | 6805 | |
| | 6806 | if (target_util.clangSupportsTargetCpuArg(target)) { |
| | 6807 | if (target.cpu.model.llvm_name) |llvm_name| { |
| | 6808 | try argv.appendSlice(&[_][]const u8{ |
| | 6809 | xclang_flag, "-target-cpu", xclang_flag, llvm_name, |
| | 6810 | }); |
| | 6811 | } |
| | 6812 | } |
| | 6813 | |
| | 6814 | // It would be really nice if there was a more compact way to communicate this info to Clang. |
| | 6815 | const all_features_list = target.cpu.arch.allFeaturesList(); |
| | 6816 | try argv.ensureUnusedCapacity(all_features_list.len * 4); |
| | 6817 | for (all_features_list, 0..) |feature, index_usize| { |
| | 6818 | const index = @as(std.Target.Cpu.Feature.Set.Index, @intCast(index_usize)); |
| | 6819 | const is_enabled = target.cpu.features.isEnabled(index); |
| | 6820 | |
| | 6821 | if (feature.llvm_name) |llvm_name| { |
| | 6822 | // We communicate float ABI to Clang through the dedicated options. |
| | 6823 | if (std.mem.startsWith(u8, llvm_name, "soft-float") or |
| | 6824 | std.mem.startsWith(u8, llvm_name, "hard-float")) |
| | 6825 | continue; |
| | 6826 | |
| | 6827 | // Ignore these until we figure out how to handle the concept of omitting features. |
| | 6828 | // See https://github.com/ziglang/zig/issues/23539 |
| | 6829 | if (target_util.isDynamicAMDGCNFeature(target, feature)) continue; |
| | 6830 | |
| | 6831 | argv.appendSliceAssumeCapacity(&[_][]const u8{ xclang_flag, "-target-feature", xclang_flag }); |
| | 6832 | const plus_or_minus = "-+"[@intFromBool(is_enabled)]; |
| | 6833 | const arg = try std.fmt.allocPrint(arena, "{c}{s}", .{ plus_or_minus, llvm_name }); |
| | 6834 | argv.appendAssumeCapacity(arg); |
| | 6835 | } |
| | 6836 | } |
| | 6837 | |
| 6801 | if (target.cpu.arch.isArm()) { | 6838 | if (target.cpu.arch.isArm()) { |
| 6802 | try argv.append(if (target.cpu.arch.isThumb()) "-mthumb" else "-mno-thumb"); | 6839 | try argv.append(if (target.cpu.arch.isThumb()) "-mthumb" else "-mno-thumb"); |
| 6803 | } | 6840 | } |
| ... | @@ -7134,38 +7171,6 @@ pub fn addCCArgs( | ... | @@ -7134,38 +7171,6 @@ pub fn addCCArgs( |
| 7134 | try argv.append(try std.fmt.allocPrint(arena, "-mcmodel={s}", .{@tagName(mod.code_model)})); | 7171 | try argv.append(try std.fmt.allocPrint(arena, "-mcmodel={s}", .{@tagName(mod.code_model)})); |
| 7135 | } | 7172 | } |
| 7136 | | 7173 | |
| 7137 | if (target_util.clangSupportsTargetCpuArg(target)) { | | |
| 7138 | if (target.cpu.model.llvm_name) |llvm_name| { | | |
| 7139 | try argv.appendSlice(&[_][]const u8{ | | |
| 7140 | "-Xclang", "-target-cpu", "-Xclang", llvm_name, | | |
| 7141 | }); | | |
| 7142 | } | | |
| 7143 | } | | |
| 7144 | | | |
| 7145 | // It would be really nice if there was a more compact way to communicate this info to Clang. | | |
| 7146 | const all_features_list = target.cpu.arch.allFeaturesList(); | | |
| 7147 | try argv.ensureUnusedCapacity(all_features_list.len * 4); | | |
| 7148 | for (all_features_list, 0..) |feature, index_usize| { | | |
| 7149 | const index = @as(std.Target.Cpu.Feature.Set.Index, @intCast(index_usize)); | | |
| 7150 | const is_enabled = target.cpu.features.isEnabled(index); | | |
| 7151 | | | |
| 7152 | if (feature.llvm_name) |llvm_name| { | | |
| 7153 | // We communicate float ABI to Clang through the dedicated options. | | |
| 7154 | if (std.mem.startsWith(u8, llvm_name, "soft-float") or | | |
| 7155 | std.mem.startsWith(u8, llvm_name, "hard-float")) | | |
| 7156 | continue; | | |
| 7157 | | | |
| 7158 | // Ignore these until we figure out how to handle the concept of omitting features. | | |
| 7159 | // See https://github.com/ziglang/zig/issues/23539 | | |
| 7160 | if (target_util.isDynamicAMDGCNFeature(target, feature)) continue; | | |
| 7161 | | | |
| 7162 | argv.appendSliceAssumeCapacity(&[_][]const u8{ "-Xclang", "-target-feature", "-Xclang" }); | | |
| 7163 | const plus_or_minus = "-+"[@intFromBool(is_enabled)]; | | |
| 7164 | const arg = try std.fmt.allocPrint(arena, "{c}{s}", .{ plus_or_minus, llvm_name }); | | |
| 7165 | argv.appendAssumeCapacity(arg); | | |
| 7166 | } | | |
| 7167 | } | | |
| 7168 | | | |
| 7169 | { | 7174 | { |
| 7170 | var san_arg: std.ArrayListUnmanaged(u8) = .empty; | 7175 | var san_arg: std.ArrayListUnmanaged(u8) = .empty; |
| 7171 | const prefix = "-fsanitize="; | 7176 | const prefix = "-fsanitize="; |