@@ -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
0 commit comments