MIPS: Loongson64: Clean up use of cc-ifversion
Subsystems (3)
PATCH 1/2 MIPS: Loongson64: Clean up use of cc-ifversion
This Makefile checks that GCC is 4.9 or newer, which is redundant after commit 76ae847497bc ("Documentation: raise minimum supported version of GCC to 5.1"), so cc-option can be removed.
Clang does not support -march=loongson3a so it needs to continue to use -march=mips64r2, along with binutils less than 2.25, so check that both GCC and binutils 2.25 or newer are being used before using -march=loongson3a. These flags do not need to be checked with cc-option anymore because all GCC versions support -march=loongson3a and -march=mips64r2 and all clang versions support -march=mips64r2.
--- arch/mips/loongson64/Platform | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
arch/mips/loongson64/Platform +3 -10
@@ -12,17 +12,10 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # by GAS. The cc-option can't probe for this behaviour so -march=loongson3a # can't easily be used safely within the kbuild framework. # -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif +ifeq ($(CONFIG_CC_IS_GCC)$(call ld-ifversion, -ge, 22500, y), yy) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64 else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=mips64r2 endif # Some -march= flags enable MMI instructions, and GCC complains about that
base-commit: 2c271fe77d52a0555161926c232cd5bc07178b39
Signature · 1 line
2.34.1
PATCH 2/2 MIPS: Loongson64: Wrap -mno-branch-likely with cc-option
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported. Wrap the flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy.
--- arch/mips/loongson64/Platform | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/loongson64/Platform +2 -1
@@ -26,5 +26,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_MACH_LOONGSON64) += $(call cc-option,-mno-branch-likely) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000
Signature · 1 line
2.34.1
Quoted 5 lines · Nathan Chancellor
This
Makefilechecks that GCC is 4.9 or newer, which is redundant after commit76ae847497bc("Documentation: raise minimum supported version of GCC to 5.1"), so cc-option can be removed.
Quoted 8 lines
Clang does not support -march=loongson3a so it needs to continue to use -march=mips64r2, along with binutils less than 2.25, so check that both GCC and binutils 2.25 or newer are being used before using -march=loongson3a. These flags do not need to be checked with cc-option anymore because all GCC versions support -march=loongson3a and -march=mips64r2 and all clang versions support -march=mips64r2.
Signed-off-by Nathan Chancellor <[email protected]>
Thanks for the patch. I wonder why _MIPS_ISA only seems to be set at all for -march=loongson3a AFAICT, though that question is orthogonal to this patch. Perhaps the Loongson or MIPS maintainers know more? Otherwise seems like most uses of _MIPS_ISA can either be deleted or simplified now.
Quoted 34 lines
--- arch/mips/loongson64/Platform | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)arch/mips/loongson64/Platform +3
-10@@ -12,17 +12,10 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # by GAS. The cc-option can't probe for this behaviour so -march=loongson3a # can't easily be used safely within the kbuild framework. # -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif +ifeq ($(CONFIG_CC_IS_GCC)$(call ld-ifversion, -ge, 22500, y), yy) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64 else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=mips64r2 endif # Some -march= flags enable MMI instructions, and GCC complains about thatbase-commit:
2c271fe77d52a0555161926c232cd5bc07178b39--
2.34.1
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 2/2] MIPS: Loongson64: Wrap -mno-branch-likely with cc-option
In reply to Nathan ChancellorQuoted 11 lines · Nathan Chancellor
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported. Wrap the flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy.
Signed-off-by Nathan Chancellor <[email protected]>
We should convert more of these tests to Kconfig checks that run once per configuration, rather than multiple times for a build. IIRC Linus mentioned this somewhere...yeah, the -Wimplicit-fallthrough patches. Seedee2b702bcf06 ("kconfig: Add support for -Wimplicit-fallthrough")
I wonder if we can check ARCH or SUBARCH in Kconfig to limit invoking the tool under test for certain arch specific command line flags?
I'll take this patch over such a larger change, but I think towards the goal of speeding up already configured builds, we eventually want to be migrating cc-option and ld-option checks to Kconfig.
Quoted 20 lines
--- arch/mips/loongson64/Platform | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/mips/loongson64/Platform +2
-2@@ -26,5 +26,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_MACH_LOONGSON64) += $(call cc-option,-mno-branch-likely) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000 --2.34.1
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 2/2] MIPS: Loongson64: Wrap -mno-branch-likely with cc-option
Quoted 19 lines · Nick Desaulniers
Quoted 11 lines · Nathan Chancellor
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported. Wrap the flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy.
Signed-off-by Nathan Chancellor <[email protected]>We should convert more of these tests to
Kconfigchecks that run once per configuration, rather than multiple times for a build. IIRC Linus mentioned this somewhere...yeah, the -Wimplicit-fallthrough patches. Seedee2b702bcf06("kconfig: Add support for -Wimplicit-fallthrough")
Quoted 8 lines
I wonder if we can check ARCH or SUBARCH in
Kconfigto limit invoking the tool under test for certain arch specific command line flags?I'll take this patch over such a larger change, but I think towards the goal of speeding up already configured builds, we eventually want to be migrating cc-option and ld-option checks to
Kconfig.Reviewed-by Nick Desaulniers <[email protected]>
Something like this appears to work, if that is more preferrable?
arch/mips/Kconfig +6 -0
@@ -3232,3 +3232,9 @@ endmenu source "arch/mips/kvm/Kconfig" source "arch/mips/vdso/Kconfig" + +config CC_MNO_BRANCH_LIKELY + string + default "-mno-branch-likely" + depends on MACH_LOONGSON64 || MACH_LOONGSON2EF + depends on $(cc-option,-mno-branch-likely)
arch/mips/loongson2ef/Platform +1 -1
@@ -41,6 +41,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef $(CONFIG_CC_MNO_BRANCH_LIKELY) load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
arch/mips/loongson64/Platform +1 -1
@@ -33,5 +33,5 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 $(CONFIG_CC_MNO_BRANCH_LIKELY) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000
Quoted 25 lines
Quoted 20 lines
--- arch/mips/loongson64/Platform | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/mips/loongson64/Platform +2
-2@@ -26,5 +26,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_MACH_LOONGSON64) += $(call cc-option,-mno-branch-likely) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000 --2.34.1
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 2/2] MIPS: Loongson64: Wrap -mno-branch-likely with cc-option
Quoted 51 lines · Nathan Chancellor
Quoted 19 lines · Nick Desaulniers
Quoted 11 lines · Nathan Chancellor
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported. Wrap the flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy.
Signed-off-by Nathan Chancellor <[email protected]>We should convert more of these tests to
Kconfigchecks that run once per configuration, rather than multiple times for a build. IIRC Linus mentioned this somewhere...yeah, the -Wimplicit-fallthrough patches. Seedee2b702bcf06("kconfig: Add support for -Wimplicit-fallthrough")Quoted 8 lines
I wonder if we can check ARCH or SUBARCH in
Kconfigto limit invoking the tool under test for certain arch specific command line flags?I'll take this patch over such a larger change, but I think towards the goal of speeding up already configured builds, we eventually want to be migrating cc-option and ld-option checks to
Kconfig.Reviewed-by Nick Desaulniers <[email protected]>Something like this appears to work, if that is more preferrable?
arch/mips/Kconfig +6
-0@@ -3232,3 +3232,9 @@ endmenu source "arch/mips/kvm/Kconfig" source "arch/mips/vdso/Kconfig" + +config CC_MNO_BRANCH_LIKELY + string + default "-mno-branch-likely" + depends on MACH_LOONGSON64 || MACH_LOONGSON2EF + depends on $(cc-option,-mno-branch-likely)arch/mips/loongson2ef/Platform +0
-0
arch/mips/loongson2ef/Platform cflags-y += $(call cc-option,-mno-loongson-mmi) · line 44
Quoted 5 lines
arch/mips/loongson2ef/Platform +1
-1@@ -41,6 +41,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef $(CONFIG_CC_MNO_BRANCH_LIKELY)
Does that allow someone to modify the value for CC_MNO_BRANCH_LIKELY in menuconfig?
If so, I'd rather the Makefiles have:
cflags-$(CONFIG_CC_MNO_BRANCH_LIKELY) += -mno-branch-likely
and CONFIG_CC_MNO_BRANCH_LIKELY be a bool rather than an editable string. I think that makes the Makefile more readable; you don't have to see what CONFIG_CC_MNO_BRANCH_LIKELY expands to in a different file.
See also CC_HAS_ASM_GOTO and CC_HAS_ASM_GOTO_OUTPUT in init/Kconfig.
Quoted 40 lines
arch/mips/loongson2ef/Platform +0
-0load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000arch/mips/loongson64/Platform +1
-1@@ -33,5 +33,5 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 $(CONFIG_CC_MNO_BRANCH_LIKELY) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000Quoted 26 lines
Quoted 18 lines
--- arch/mips/loongson64/Platform | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/mips/loongson64/Platform +2
-2@@ -26,5 +26,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_MACH_LOONGSON64) += $(call cc-option,-mno-branch-likely) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000 --Quoted 3 lines
2.34.1
--
Thanks,
~Nick Desaulniers
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 2/2] MIPS: Loongson64: Wrap -mno-branch-likely with cc-option
Quoted 55 lines · Nick Desaulniers
Quoted 54 lines · Nathan Chancellor
Quoted 19 lines · Nick Desaulniers
Quoted 11 lines · Nathan Chancellor
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported. Wrap the flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy.
Signed-off-by Nathan Chancellor <[email protected]>We should convert more of these tests to
Kconfigchecks that run once per configuration, rather than multiple times for a build. IIRC Linus mentioned this somewhere...yeah, the -Wimplicit-fallthrough patches. Seedee2b702bcf06("kconfig: Add support for -Wimplicit-fallthrough")Quoted 8 lines
I wonder if we can check ARCH or SUBARCH in
Kconfigto limit invoking the tool under test for certain arch specific command line flags?I'll take this patch over such a larger change, but I think towards the goal of speeding up already configured builds, we eventually want to be migrating cc-option and ld-option checks to
Kconfig.Reviewed-by Nick Desaulniers <[email protected]>Something like this appears to work, if that is more preferrable?
arch/mips/Kconfig +6
-0@@ -3232,3 +3232,9 @@ endmenu source "arch/mips/kvm/Kconfig" source "arch/mips/vdso/Kconfig" + +config CC_MNO_BRANCH_LIKELY + string + default "-mno-branch-likely" + depends on MACH_LOONGSON64 || MACH_LOONGSON2EF + depends on $(cc-option,-mno-branch-likely)arch/mips/loongson2ef/Platform +0
-0@@ -41,6 +41,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support #
Quoted 5 lines
arch/mips/loongson2ef/Platform cflags-y += $(call cc-option,-mno-loongson-mmi) · line 44
Quoted 2 lines
arch/mips/loongson2ef/Platform +1
-1-cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef $(CONFIG_CC_MNO_BRANCH_LIKELY)Does that allow someone to modify the value for
CC_MNO_BRANCH_LIKELYin menuconfig?
No because it is a hidden symbol; in other words:
config ...
string
rather than
config ...
string "..."
Quoted 10 lines
If so, I'd rather the Makefiles have:
cflags-$(CONFIG_CC_MNO_BRANCH_LIKELY) += -mno-branch-likely
and
CONFIG_CC_MNO_BRANCH_LIKELYbe a bool rather than an editable string. I think that makes theMakefilemore readable; you don't have to see whatCONFIG_CC_MNO_BRANCH_LIKELYexpands to in a different file.See also
CC_HAS_ASM_GOTOandCC_HAS_ASM_GOTO_OUTPUTin init/Kconfig.
Regardless, your suggestion is simpler. I can send that as v2 if this is preferrable.
arch/mips/Kconfig +4 -0
@@ -3232,3 +3232,7 @@ endmenu source "arch/mips/kvm/Kconfig" source "arch/mips/vdso/Kconfig" + +config CC_HAS_MNO_BRANCH_LIKELY + def_bool y + depends on $(cc-option,-mno-branch-likely)
arch/mips/loongson2ef/Platform +2 -1
@@ -41,6 +41,7 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef +cflags-$(CONFIG_CC_HAS_MNO_BRANCH_LIKELY) += -mno-branch-likely load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
arch/mips/loongson64/Platform +2 -1
@@ -33,5 +33,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_CC_HAS_MNO_BRANCH_LIKELY) += -mno-branch-likely load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000
Quoted 45 lines
Quoted 40 lines
arch/mips/loongson2ef/Platform +0
-0load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000arch/mips/loongson64/Platform +1
-1@@ -33,5 +33,5 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 $(CONFIG_CC_MNO_BRANCH_LIKELY) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000Quoted 26 lines
Quoted 18 lines
--- arch/mips/loongson64/Platform | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/mips/loongson64/Platform +2
-2@@ -26,5 +26,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_MACH_LOONGSON64) += $(call cc-option,-mno-branch-likely) load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000 --Quoted 3 lines
2.34.1
--
Thanks,
~Nick DesaulniersSignature · 2 lines
Thanks, ~Nick Desaulniers
Jiaxun Yang
maintainerQuoted 13 lines · 在2022年1月24日一月 下午8:31,Nick Desaulniers写道:
Quoted 12 lines · Nathan Chancellor
This
Makefilechecks that GCC is 4.9 or newer, which is redundant after commit76ae847497bc("Documentation: raise minimum supported version of GCC to 5.1"), so cc-option can be removed.Clang does not support -march=loongson3a so it needs to continue to use -march=mips64r2, along with binutils less than 2.25, so check that both GCC and binutils 2.25 or newer are being used before using -march=loongson3a. These flags do not need to be checked with cc-option anymore because all GCC versions support -march=loongson3a and -march=mips64r2 and all clang versions support -march=mips64r2.
Quoted 7 lines
Quoted 1 line
Signed-off-by Nathan Chancellor <[email protected]>Thanks for the patch. I wonder why
_MIPS_ISAonly seems to be set at all for-march=loongson3aAFAICT, though that question is orthogonal to this patch. Perhaps the Loongson or MIPS maintainers know more? Otherwise seems like most uses of_MIPS_ISAcan either be deleted or simplified now.
This is because earlier GCC mistakenly set loongson3a to MIPS64 not MIPS64R2.
But given that it's earlier than the minimal requirement GCC of kernel today, I think it should be safe to just move the whole logic.
Thanks.
Quoted 42 lines
Reviewed-by Nick Desaulniers <[email protected]>Quoted 34 lines
--- arch/mips/loongson64/Platform | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)arch/mips/loongson64/Platform +3
-10@@ -12,17 +12,10 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # by GAS. The cc-option can't probe for this behaviour so -march=loongson3a # can't easily be used safely within the kbuild framework. # -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif +ifeq ($(CONFIG_CC_IS_GCC)$(call ld-ifversion, -ge, 22500, y), yy) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64 else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=mips64r2 endif # Some -march= flags enable MMI instructions, and GCC complains about thatbase-commit:
2c271fe77d52a0555161926c232cd5bc07178b39--
2.34.1Signature · 2 lines
Thanks, ~Nick Desaulniers
Signature · 1 line
- Jiaxun
Quoted 24 lines · Jiaxun Yang
Quoted 13 lines · 在2022年1月24日一月 下午8:31,Nick Desaulniers写道:
Quoted 12 lines · Nathan Chancellor
This
Makefilechecks that GCC is 4.9 or newer, which is redundant after commit76ae847497bc("Documentation: raise minimum supported version of GCC to 5.1"), so cc-option can be removed.Clang does not support -march=loongson3a so it needs to continue to use -march=mips64r2, along with binutils less than 2.25, so check that both GCC and binutils 2.25 or newer are being used before using -march=loongson3a. These flags do not need to be checked with cc-option anymore because all GCC versions support -march=loongson3a and -march=mips64r2 and all clang versions support -march=mips64r2.
Quoted 7 lines
Quoted 1 line
Signed-off-by Nathan Chancellor <[email protected]>Thanks for the patch. I wonder why
_MIPS_ISAonly seems to be set at all for-march=loongson3aAFAICT, though that question is orthogonal to this patch. Perhaps the Loongson or MIPS maintainers know more? Otherwise seems like most uses of_MIPS_ISAcan either be deleted or simplified now.
Quoted 5 lines
This is because earlier GCC mistakenly set loongson3a to MIPS64 not MIPS64R2.
But given that it's earlier than the minimal requirement GCC of kernel today, I think it should be safe to just move the whole logic.
Thanks.
So something like this (completely untested)?
arch/mips/loongson64/Platform +3 -18
@@ -5,24 +5,9 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap -# -# binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a -# as MIPS64 R2; older versions as just R1. This leaves the possibility open -# that GCC might generate R2 code for -march=loongson3a which then is rejected -# by GAS. The cc-option can't probe for this behaviour so -march=loongson3a -# can't easily be used safely within the kbuild framework. -# -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif -else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) +ifdef CONFIG_CPU_LOONGSON64 +cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2 +cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a endif # Some -march= flags enable MMI instructions, and GCC complains about that
Quoted 45 lines
Quoted 42 lines
Reviewed-by Nick Desaulniers <[email protected]>Quoted 34 lines
--- arch/mips/loongson64/Platform | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)arch/mips/loongson64/Platform +3
-10@@ -12,17 +12,10 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # by GAS. The cc-option can't probe for this behaviour so -march=loongson3a # can't easily be used safely within the kbuild framework. # -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif +ifeq ($(CONFIG_CC_IS_GCC)$(call ld-ifversion, -ge, 22500, y), yy) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64 else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=mips64r2 endif # Some -march= flags enable MMI instructions, and GCC complains about thatbase-commit:
2c271fe77d52a0555161926c232cd5bc07178b39--
2.34.1Signature · 2 lines
Thanks, ~Nick DesaulniersSignature · 1 line
- Jiaxun
Jiaxun Yang
maintainer在2022年1月25日一月 上午1:25,Nathan Chancellor写道:
[...]
Quoted 2 lines
So something like this (completely untested)?
Yep, tested with multiple GCC toolchains and it works :-)
Thanks.
Quoted 86 lines
arch/mips/loongson64/Platform +0
-4@@ -5,24 +5,9 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap -# -# binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a -# as MIPS64 R2; older versions as just R1. This leaves thepossibility open
-# that GCC might generate R2 code for -march=loongson3a which then is rejectedarch/mips/loongson64/Platform +3
-18-# by GAS. The cc-option can't probe for this behaviour so -march=loongson3a -# can't easily be used safely within the kbuild framework. -# -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif -else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) +ifdef CONFIG_CPU_LOONGSON64 +cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2 +cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a endif # Some -march= flags enable MMI instructions, and GCC complains about thatQuoted 46 lines
Quoted 43 lines
Reviewed-by Nick Desaulniers <[email protected]>Quoted 34 lines
--- arch/mips/loongson64/Platform | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)arch/mips/loongson64/Platform +3
-10@@ -12,17 +12,10 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # by GAS. The cc-option can't probe for this behaviour so -march=loongson3a # can't easily be used safely within the kbuild framework. # -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif +ifeq ($(CONFIG_CC_IS_GCC)$(call ld-ifversion, -ge, 22500, y), yy) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64 else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) + cflags-$(CONFIG_CPU_LOONGSON64) += -march=mips64r2 endif # Some -march= flags enable MMI instructions, and GCC complains about thatbase-commit:
2c271fe77d52a0555161926c232cd5bc07178b39--
2.34.1Signature · 2 lines
Thanks, ~Nick DesaulniersSignature · 1 line
- Jiaxun
Signature · 1 line
- Jiaxun