]> git.droids-corp.org - dpdk.git/commitdiff
mk: introduce helper to check compiler argument
authorJerin Jacob <jerinj@marvell.com>
Sat, 13 Apr 2019 20:19:43 +0000 (01:49 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 15 Apr 2019 20:55:56 +0000 (22:55 +0200)
Introduce rte_cc_has_argument() Makefile helper to
check a given argument is support by the compiler.

Example Usage:

include $(RTE_SDK)/mk/rte.helper.mk
MACHINE_CFLAGS += $(call rte_cc_has_argument, -mcpu=octeontx2)

This would allow adding -mcpu=octeontx2 in MACHINE_CFLAGS
if it is only supported by the compiler. The use case for such
scheme is to enable the mcpu optimization if the compiler
supports else it needs to compile the source code without
any errors.

This patch also moves inclusion of toolchain's rte.vars.mk
to before the machine's rte.vars.mk inclusion to make
correct CC available for the cross compile case.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
mk/rte.helper.mk [new file with mode: 0644]
mk/target/generic/rte.vars.mk

diff --git a/mk/rte.helper.mk b/mk/rte.helper.mk
new file mode 100644 (file)
index 0000000..6e7fd03
--- /dev/null
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Marvell International Ltd
+
+# rte_cc_has_argument
+# Usage: MACHINE_CFLAGS += $(call rte_cc_has_argument, -mno-avx512f)
+# Return the argument if the argument is supported by the compiler.
+#
+define rte_cc_has_argument
+       $(shell $(CC) -E $(1) -xc /dev/null 1>/dev/null 2>/dev/null && echo $(1))
+endef
index dd149acc9cee67fb75e649a059d914496a84018d..25a578ad7aa5afa0c88f283c7fd7fb7a942c9bd8 100644 (file)
@@ -7,6 +7,17 @@
 # executive environment.
 #
 
+#
+# toolchain:
+#
+#   - define CC, LD, AR, AS, ...
+#   - define TOOLCHAIN_CFLAGS variable (overridden by cmdline value)
+#   - define TOOLCHAIN_LDFLAGS variable (overridden by cmdline value)
+#   - define TOOLCHAIN_ASFLAGS variable (overridden by cmdline value)
+#   - may override any previously defined variable
+#
+include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.vars.mk
+
 #
 # machine:
 #
@@ -45,17 +56,6 @@ endif
 #
 include $(RTE_SDK)/mk/arch/$(RTE_ARCH)/rte.vars.mk
 
-#
-# toolchain:
-#
-#   - define CC, LD, AR, AS, ...
-#   - define TOOLCHAIN_CFLAGS variable (overridden by cmdline value)
-#   - define TOOLCHAIN_LDFLAGS variable (overridden by cmdline value)
-#   - define TOOLCHAIN_ASFLAGS variable (overridden by cmdline value)
-#   - may override any previously defined variable
-#
-include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.vars.mk
-
 #
 # exec-env:
 #