authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 12:44:52+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 12:59:38+01:00
log97583714191588347210fa2426a6eb8d757089a2
tree3e844acc2d6ddb656d632a6ed271ea59b6df2f82
parentf38d7a92cc1ca8059ba909a82f2f944966b52296
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.zig.system: Move CPU feature hacks after ABI detection.

This was accidentally broken in #22434.

1 files changed, 18 insertions(+), 14 deletions(-)

lib/std/zig/system.zig+18-14
......@@ -399,22 +399,26 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {
399399 query.cpu_features_sub,
400400 );
401401
402 if (cpu.arch == .hexagon) {
403 // Both LLVM and LLD have broken support for the small data area. Yet LLVM has the feature
404 // on by default for all Hexagon CPUs. Clang sort of solves this by defaulting the `-gpsize`
405 // command line parameter for the Hexagon backend to 0, so that no constants get placed in
406 // the SDA. (This of course breaks down if the user passes `-G <n>` to Clang...) We can't do
407 // the `-gpsize` hack because we can have multiple concurrent LLVM emit jobs, and command
408 // line options in LLVM are shared globally. So just force this feature off. Lovely stuff.
409 cpu.features.removeFeature(@intFromEnum(Target.hexagon.Feature.small_data));
410 }
402 var result = try detectAbiAndDynamicLinker(cpu, os, query);
411403
412 // https://github.com/llvm/llvm-project/issues/105978
413 if (cpu.arch.isArm() and query_abi.floatAbi() == .soft) {
414 cpu.features.removeFeature(@intFromEnum(Target.arm.Feature.vfp2));
415 }
404 // These CPU feature hacks have to come after ABI detection.
405 {
406 if (result.cpu.arch == .hexagon) {
407 // Both LLVM and LLD have broken support for the small data area. Yet LLVM has the
408 // feature on by default for all Hexagon CPUs. Clang sort of solves this by defaulting
409 // the `-gpsize` command line parameter for the Hexagon backend to 0, so that no
410 // constants get placed in the SDA. (This of course breaks down if the user passes
411 // `-G <n>` to Clang...) We can't do the `-gpsize` hack because we can have multiple
412 // concurrent LLVM emit jobs, and command line options in LLVM are shared globally. So
413 // just force this feature off. Lovely stuff.
414 result.cpu.features.removeFeature(@intFromEnum(Target.hexagon.Feature.small_data));
415 }
416416
417 var result = try detectAbiAndDynamicLinker(cpu, os, query);
417 // https://github.com/llvm/llvm-project/issues/105978
418 if (result.cpu.arch.isArm() and result.abi.floatAbi() == .soft) {
419 result.cpu.features.removeFeature(@intFromEnum(Target.arm.Feature.vfp2));
420 }
421 }
418422
419423 // It's possible that we detect the native ABI, but fail to detect the OS version or were told
420424 // to use the default OS version range. In that case, while we can't determine the exact native