| ... | ... | @@ -138,17 +138,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 138 | 138 | try addSrcFile(arena, &source_table, src_file); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | | const time32_compat_arch_list = [_][]const u8{ |
| 142 | | "arm", |
| 143 | | "i386", |
| 144 | | "m68k", |
| 145 | | "microblaze", |
| 146 | | "mips", |
| 147 | | "mipsn32", |
| 148 | | "or1k", |
| 149 | | "powerpc", |
| 150 | | "sh", |
| 151 | | }; |
| 152 | 141 | for (time32_compat_arch_list) |time32_compat_arch| { |
| 153 | 142 | if (mem.eql(u8, arch_name, time32_compat_arch)) { |
| 154 | 143 | for (compat_time32_files) |compat_time32_file| { |
| ... | ... | @@ -239,13 +228,29 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 239 | 228 | }); |
| 240 | 229 | |
| 241 | 230 | const target = comp.root_mod.resolved_target.result; |
| 242 | | const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{ |
| 243 | | @tagName(target.cpu.arch), |
| 244 | | }); |
| 231 | const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi); |
| 232 | const time32 = for (time32_compat_arch_list) |time32_compat_arch| { |
| 233 | if (mem.eql(u8, arch_name, time32_compat_arch)) break true; |
| 234 | } else false; |
| 235 | const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{arch_name}); |
| 236 | const family_define = switch (target.cpu.arch) { |
| 237 | .arm, .armeb, .thumb, .thumbeb => "-DFAMILY_arm", |
| 238 | .aarch64, .aarch64_be => "-DFAMILY_aarch64", |
| 239 | .loongarch64 => "-DFAMILY_loongarch", |
| 240 | .m68k => "-DFAMILY_m68k", |
| 241 | .mips, .mipsel, .mips64, .mips64el => "-DFAMILY_mips", |
| 242 | .powerpc, .powerpc64, .powerpc64le => "-DFAMILY_powerpc", |
| 243 | .riscv32, .riscv64 => "-DFAMILY_riscv", |
| 244 | .s390x => "-DFAMILY_s390x", |
| 245 | .x86, .x86_64 => "-DFAMILY_x86", |
| 246 | else => unreachable, |
| 247 | }; |
| 245 | 248 | const cc_argv: []const []const u8 = if (target.ptrBitWidth() == 64) |
| 246 | | &.{ "-DPTR64", arch_define } |
| 249 | &.{ "-DPTR64", arch_define, family_define } |
| 250 | else if (time32) |
| 251 | &.{ "-DTIME32", arch_define, family_define } |
| 247 | 252 | else |
| 248 | | &.{arch_define}; |
| 253 | &.{ arch_define, family_define }; |
| 249 | 254 | |
| 250 | 255 | const root_mod = try Module.create(arena, .{ |
| 251 | 256 | .global_cache_directory = comp.global_cache_directory, |
| ... | ... | @@ -347,6 +352,18 @@ pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.Lin |
| 347 | 352 | }; |
| 348 | 353 | } |
| 349 | 354 | |
| 355 | const time32_compat_arch_list = [_][]const u8{ |
| 356 | "arm", |
| 357 | "i386", |
| 358 | "m68k", |
| 359 | "microblaze", |
| 360 | "mips", |
| 361 | "mipsn32", |
| 362 | "or1k", |
| 363 | "powerpc", |
| 364 | "sh", |
| 365 | }; |
| 366 | |
| 350 | 367 | fn isArchName(name: []const u8) bool { |
| 351 | 368 | const musl_arch_names = [_][]const u8{ |
| 352 | 369 | "aarch64", |