| ... | @@ -326,11 +326,33 @@ pub const NativeTargetInfo = struct { | ... | @@ -326,11 +326,33 @@ pub const NativeTargetInfo = struct { |
| 326 | cpu_detection_unimplemented = true; | 326 | cpu_detection_unimplemented = true; |
| 327 | break :backup_cpu_detection Target.Cpu.baseline(cpu_arch); | 327 | break :backup_cpu_detection Target.Cpu.baseline(cpu_arch); |
| 328 | }; | 328 | }; |
| 329 | cross_target.updateCpuFeatures(&cpu.features); | 329 | var result = try detectAbiAndDynamicLinker(allocator, cpu, os, cross_target); |
| 330 | | 330 | // For x86, we need to populate some CPU feature flags depending on architecture |
| 331 | var target = try detectAbiAndDynamicLinker(allocator, cpu, os, cross_target); | 331 | // and mode: |
| 332 | target.cpu_detection_unimplemented = cpu_detection_unimplemented; | 332 | // * 16bit_mode => if the abi is code16 |
| 333 | return target; | 333 | // * 32bit_mode => if the arch is i386 |
| | 334 | // However, the "mode" flags can be used as overrides, so if the user explicitly |
| | 335 | // sets one of them, that takes precedence. |
| | 336 | switch (cpu_arch) { |
| | 337 | .i386 => { |
| | 338 | if (!std.Target.x86.featureSetHasAny(cross_target.cpu_features_add, .{ |
| | 339 | .@"16bit_mode", .@"32bit_mode", |
| | 340 | })) { |
| | 341 | switch (result.target.abi) { |
| | 342 | .code16 => result.target.cpu.features.addFeature( |
| | 343 | @enumToInt(std.Target.x86.Feature.@"16bit_mode"), |
| | 344 | ), |
| | 345 | else => result.target.cpu.features.addFeature( |
| | 346 | @enumToInt(std.Target.x86.Feature.@"32bit_mode"), |
| | 347 | ), |
| | 348 | } |
| | 349 | } |
| | 350 | }, |
| | 351 | else => {}, |
| | 352 | } |
| | 353 | cross_target.updateCpuFeatures(&result.target.cpu.features); |
| | 354 | result.cpu_detection_unimplemented = cpu_detection_unimplemented; |
| | 355 | return result; |
| 334 | } | 356 | } |
| 335 | | 357 | |
| 336 | /// First we attempt to use the executable's own binary. If it is dynamically | 358 | /// First we attempt to use the executable's own binary. If it is dynamically |