[v10,1/4] mk: introduce helper to check valid compiler argument

Message ID 20190413201946.36566-1-jerinj@marvell.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • [v10,1/4] mk: introduce helper to check valid compiler argument
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Jerin Jacob Kollanukkaran April 13, 2019, 8:19 p.m.
From: Jerin Jacob <jerinj@marvell.com>

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>
---

Change history of this series:

v10 Changes:
- Fix the following checkpatch warning
http://mails.dpdk.org/archives/test-report/2019-April/080453.html

v9 Changes:
 - Remove compiler version check as it is now done using
   cc.has_argument().

v8 Changes:
 - Remove redudant lists (rebase aritfacts). (Yongseok Koh)
 
v7 Changes:
 - Updated cross compile config files align with 
 "build: improve pcap dependency handling" changeset to fix build issue with meson
 - Some compiler needs the following depended patch to compile with meson
   http://patches.dpdk.org/patch/52367/

v6 Changes:
 - Rework to change the config files to sync with "mk: use linux and freebsd in config names"
 - Fix the following error with latest gcc by fixing the mcpu type
   cc1: error: switch -mcpu=armv8.2-a conflicts with -march=armv8-a switch 

v5 Changes:
 - Fix incorrect meson flag parsing(Phil Yang)
 - Squash meson cross build patch(5/5) into configuration update patches for
 thunderx2(3/5) and octeontx2(4/5)(Thomas)
 - Changed octeontx2's march as armv8-a and added the extension required
   instead of armv8-2a(Phil Yang)
 - Improved rte_cc_has_argument() implementaion by removing the temp
   file(Thomas)

v4 Changes:
 - Fix incorrect signoff marrvell -> marvell.

v3 Changes:
 - Squash meson build support into config support for thunderx2/octeontx2.

v2 Changes:
 - Add meson build support.

---

 mk/rte.helper.mk              | 10 ++++++++++
 mk/target/generic/rte.vars.mk | 22 +++++++++++-----------
 2 files changed, 21 insertions(+), 11 deletions(-)
 create mode 100644 mk/rte.helper.mk

Comments

Thomas Monjalon April 15, 2019, 9 p.m. | #1
13/04/2019 22:19, jerinj@marvell.com:
> Change history of this series:
> 
> v10 Changes:
> - Fix the following checkpatch warning
> http://mails.dpdk.org/archives/test-report/2019-April/080453.html
> 
> v9 Changes:
>  - Remove compiler version check as it is now done using
>    cc.has_argument().
> 
> v8 Changes:
>  - Remove redudant lists (rebase aritfacts). (Yongseok Koh)
>  
> v7 Changes:
>  - Updated cross compile config files align with 
>  "build: improve pcap dependency handling" changeset to fix build issue with meson
>  - Some compiler needs the following depended patch to compile with meson
>    http://patches.dpdk.org/patch/52367/

Applied, thanks

Patch

diff --git a/mk/rte.helper.mk b/mk/rte.helper.mk
new file mode 100644
index 000000000..6e7fd03d7
--- /dev/null
+++ b/mk/rte.helper.mk
@@ -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
diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk
index dd149acc9..25a578ad7 100644
--- a/mk/target/generic/rte.vars.mk
+++ b/mk/target/generic/rte.vars.mk
@@ -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:
 #