Skip to content

Commit 707d49d

Browse files
nickdesaulniersgregkh
authored andcommitted
Makefile.compiler: replace cc-ifversion with compiler-specific macros
commit 88b61e3 upstream. cc-ifversion is GCC specific. Replace it with compiler specific variants. Update the users of cc-ifversion to use these new macros. Link: ClangBuiltLinux/linux#350 Link: https://lore.kernel.org/llvm/CAGG=3QWSAUakO42kubrCap8fp-gm1ERJJAYXTnP1iHk_wrH=BQ@mail.gmail.com/ Suggested-by: Bill Wendling <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> [nathan: Backport to 5.15 and eliminate instances of cc-ifversion that did not exist upstream when this change was original created] Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4c019e9 commit 707d49d

File tree

13 files changed

+37
-30
lines changed

13 files changed

+37
-30
lines changed

Documentation/kbuild/makefiles.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -682,22 +682,27 @@ more details, with real examples.
682682
In the above example, -Wno-unused-but-set-variable will be added to
683683
KBUILD_CFLAGS only if gcc really accepts it.
684684

685-
cc-ifversion
686-
cc-ifversion tests the version of $(CC) and equals the fourth parameter
687-
if version expression is true, or the fifth (if given) if the version
688-
expression is false.
685+
gcc-min-version
686+
gcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than
687+
or equal to the provided value and evaluates to y if so.
689688

690689
Example::
691690

692-
#fs/reiserfs/Makefile
693-
ccflags-y := $(call cc-ifversion, -lt, 0402, -O1)
691+
cflags-$(call gcc-min-version, 70100) := -foo
694692

695-
In this example, ccflags-y will be assigned the value -O1 if the
696-
$(CC) version is less than 4.2.
697-
cc-ifversion takes all the shell operators:
698-
-eq, -ne, -lt, -le, -gt, and -ge
699-
The third parameter may be a text as in this example, but it may also
700-
be an expanded variable or a macro.
693+
In this example, cflags-y will be assigned the value -foo if $(CC) is gcc and
694+
$(CONFIG_GCC_VERSION) is >= 7.1.
695+
696+
clang-min-version
697+
clang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater
698+
than or equal to the provided value and evaluates to y if so.
699+
700+
Example::
701+
702+
cflags-$(call clang-min-version, 110000) := -foo
703+
704+
In this example, cflags-y will be assigned the value -foo if $(CC) is clang
705+
and $(CONFIG_CLANG_VERSION) is >= 11.0.0.
701706

702707
cc-cross-prefix
703708
cc-cross-prefix is used to check if there exists a $(CC) in path with

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
804804
KBUILD_CFLAGS += $(stackp-flags-y)
805805

806806
KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
807-
KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
808807

809808
ifdef CONFIG_CC_IS_CLANG
810809
KBUILD_CPPFLAGS += -Qunused-arguments
@@ -1043,7 +1042,6 @@ ifdef CONFIG_CC_IS_GCC
10431042
KBUILD_CFLAGS += -Wno-maybe-uninitialized
10441043
endif
10451044

1046-
ifdef CONFIG_CC_IS_GCC
10471045
# The allocators already balk at large sizes, so silence the compiler
10481046
# warnings for bounds checks involving those possible values. While
10491047
# -Wno-alloc-size-larger-than would normally be used here, earlier versions
@@ -1055,8 +1053,8 @@ ifdef CONFIG_CC_IS_GCC
10551053
# ignored, continuing to default to PTRDIFF_MAX. So, left with no other
10561054
# choice, we must perform a versioned check to disable this warning.
10571055
# https://lore.kernel.org/lkml/[email protected]
1058-
KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0901, -Wno-alloc-size-larger-than)
1059-
endif
1056+
KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
1057+
KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
10601058

10611059
# disable invalid "can't wrap" optimizations for signed / pointers
10621060
KBUILD_CFLAGS += -fno-strict-overflow

arch/mips/loongson64/Platform

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap
1212
# by GAS. The cc-option can't probe for this behaviour so -march=loongson3a
1313
# can't easily be used safely within the kbuild framework.
1414
#
15-
ifeq ($(call cc-ifversion, -ge, 0409, y), y)
15+
ifeq ($(call gcc-min-version, 40900), y)
1616
ifeq ($(call ld-ifversion, -ge, 22500, y), y)
1717
cflags-$(CONFIG_CPU_LOONGSON64) += \
1818
$(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64)

arch/s390/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
3535
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
3636

3737
ifdef CONFIG_CC_IS_GCC
38-
ifeq ($(call cc-ifversion, -ge, 1200, y), y)
39-
ifeq ($(call cc-ifversion, -lt, 1300, y), y)
38+
ifeq ($(call gcc-min-version, 120000), y)
39+
ifneq ($(call gcc-min-version, 130000), y)
4040
KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
4141
KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, array-bounds)
4242
endif

drivers/gpu/drm/amd/display/dc/dcn20/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -maltivec
1818
endif
1919

2020
ifdef CONFIG_CC_IS_GCC
21-
ifeq ($(call cc-ifversion, -lt, 0701, y), y)
21+
ifneq ($(call gcc-min-version, 70100), y)
2222
IS_OLD_GCC = 1
2323
endif
2424
endif

drivers/gpu/drm/amd/display/dc/dcn21/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -maltivec
1414
endif
1515

1616
ifdef CONFIG_CC_IS_GCC
17-
ifeq ($(call cc-ifversion, -lt, 0701, y), y)
17+
ifneq ($(call gcc-min-version, 70100), y)
1818
IS_OLD_GCC = 1
1919
endif
2020
endif

drivers/gpu/drm/amd/display/dc/dcn30/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ CFLAGS_$(AMDDALPATH)/dc/dcn30/dcn30_optc.o := -mhard-float -maltivec
4242
endif
4343

4444
ifdef CONFIG_CC_IS_GCC
45-
ifeq ($(call cc-ifversion, -lt, 0701, y), y)
45+
ifneq ($(call gcc-min-version, 70100), y)
4646
IS_OLD_GCC = 1
4747
endif
4848
CFLAGS_$(AMDDALPATH)/dc/dcn30/dcn30_resource.o += -mhard-float

drivers/gpu/drm/amd/display/dc/dcn301/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o := -mhard-float -maltivec
2222
endif
2323

2424
ifdef CONFIG_CC_IS_GCC
25-
ifeq ($(call cc-ifversion, -lt, 0701, y), y)
25+
ifneq ($(call gcc-min-version, 70100), y)
2626
IS_OLD_GCC = 1
2727
endif
2828
CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o += -mhard-float

drivers/gpu/drm/amd/display/dc/dcn302/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o := -mhard-float -maltivec
2121
endif
2222

2323
ifdef CONFIG_CC_IS_GCC
24-
ifeq ($(call cc-ifversion, -lt, 0701, y), y)
24+
ifneq ($(call gcc-min-version, 70100), y)
2525
IS_OLD_GCC = 1
2626
endif
2727
CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -mhard-float

drivers/gpu/drm/amd/display/dc/dcn303/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CFLAGS_$(AMDDALPATH)/dc/dcn303/dcn303_resource.o := -mhard-float -maltivec
1717
endif
1818

1919
ifdef CONFIG_CC_IS_GCC
20-
ifeq ($(call cc-ifversion, -lt, 0701, y), y)
20+
ifneq ($(call gcc-min-version, 70100), y)
2121
IS_OLD_GCC = 1
2222
endif
2323
CFLAGS_$(AMDDALPATH)/dc/dcn303/dcn303_resource.o += -mhard-float

0 commit comments

Comments
 (0)