From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 2068FA05FE
	for <public@inbox.dpdk.org>; Mon, 18 Mar 2019 17:56:07 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id D3C0F4C9D;
	Mon, 18 Mar 2019 17:56:06 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com
 [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id C5D8A4C96
 for <dev@dpdk.org>; Mon, 18 Mar 2019 17:56:05 +0100 (CET)
Received: from pps.filterd (m0045851.ppops.net [127.0.0.1])
 by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id
 x2IGtHgI003928; Mon, 18 Mar 2019 09:56:02 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : references : in-reply-to : content-type :
 content-transfer-encoding : mime-version; s=pfpt0818;
 bh=OUt21dt6f8ucETMQTDezclsHvFqwA8Uod+8BH4iNfIs=;
 b=HLrldVI6wR+PJZcK58ZyfltqJ3onTtjt1bHeLWqCS5E/YxVh1SQMzOb2GwRccIOh3PhR
 CmERqUCXeveq3OafOBUd/uqbNa4JGVZmWxhiuisFWy8owzEnYOxmCpzuIzcyJFAWLqZe
 p6AD7JH9VnMsv7qKj1zpDyxR7VtgN+pS5cGxhTmHcakaFNMr4rk0Oaklry1LynZXG4jY
 Hz28nerrRm1QKY0oE5okCkUMSEPB25bNpjhshgZqOy7GB+j0toV3N342rtSgrC+fKQt9
 yCMTFuyuA8UuAu7Qvlr+rnl9OmEBRJhJ0IxuO4c38ZiA9e/8RrBydSDUf4LCGqihDzLL mw== 
Received: from sc-exch01.marvell.com ([199.233.58.181])
 by mx0b-0016f401.pphosted.com with ESMTP id 2raapr8vux-2
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Mon, 18 Mar 2019 09:56:02 -0700
Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com
 (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 18 Mar
 2019 09:55:15 -0700
Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.55) by
 SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server
 (TLS) id
 15.0.1367.3 via Frontend Transport; Mon, 18 Mar 2019 09:55:15 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=marvell.onmicrosoft.com; s=selector1-marvell-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=OUt21dt6f8ucETMQTDezclsHvFqwA8Uod+8BH4iNfIs=;
 b=E1cXv0ibeLift7N4feR0j8lFnGmIBpMzxajcnRuIMbXTxKoZUqHkIZ3WtBQBMyBPSUuWB0zhbcsS1HYTVzzEswnz7hSnNGZ1vVCuNvbL7EDkLxHPgGitC//ii1xEs7BIxAwiWxv8KgX39yhToO9fV6d685cSIJHE5jg6Ic7MXqo=
Received: from BYAPR18MB2424.namprd18.prod.outlook.com (20.179.91.149) by
 BYAPR18MB2853.namprd18.prod.outlook.com (20.179.58.79) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1709.13; Mon, 18 Mar 2019 16:50:11 +0000
Received: from BYAPR18MB2424.namprd18.prod.outlook.com
 ([fe80::2cce:b981:61da:f92b]) by BYAPR18MB2424.namprd18.prod.outlook.com
 ([fe80::2cce:b981:61da:f92b%2]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019
 16:50:11 +0000
From: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
To: Thomas Monjalon <thomas@monjalon.net>
CC: "dev@dpdk.org" <dev@dpdk.org>, "gavin.hu@arm.com" <gavin.hu@arm.com>,
 Jerin Jacob Kollanukkaran <jerinj@marvell.com>, Pavan Nikhilesh Bhagavatula
 <pbhagavatula@marvell.com>
Thread-Topic: [dpdk-dev] [PATCH v6 1/4] mk: introduce helper to check valid
 compiler argument
Thread-Index: AQHU3aqmuIBOxg0KGUex+QnVhjHP6Q==
Date: Mon, 18 Mar 2019 16:50:10 +0000
Message-ID: <20190318164949.2357-1-jerinj@marvell.com>
References: <20190224181041.27127-1-jerinj@marvell.com>
In-Reply-To: <20190224181041.27127-1-jerinj@marvell.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-clientproxiedby: BM1PR01CA0142.INDPRD01.PROD.OUTLOOK.COM
 (2603:1096:b00:40::36) To BYAPR18MB2424.namprd18.prod.outlook.com
 (2603:10b6:a03:130::21)
x-ms-exchange-messagesentrepresentingtype: 1
x-mailer: git-send-email 2.21.0
x-originating-ip: [111.93.218.67]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 080b2033-0cf3-44af-a61b-08d6abc1c8d1
x-microsoft-antispam: BCL:0; PCL:0;
 RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);
 SRVR:BYAPR18MB2853; 
x-ms-traffictypediagnostic: BYAPR18MB2853:
x-microsoft-antispam-prvs: <BYAPR18MB2853806984FABA8CF012B7C0C8470@BYAPR18MB2853.namprd18.prod.outlook.com>
x-forefront-prvs: 098076C36C
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(136003)(376002)(396003)(366004)(346002)(39860400002)(199004)(189003)(6916009)(52116002)(386003)(68736007)(6506007)(66066001)(71200400001)(71190400001)(2906002)(76176011)(99286004)(1076003)(256004)(5660300002)(14444005)(53936002)(86362001)(78486014)(25786009)(316002)(3846002)(305945005)(8936002)(478600001)(54906003)(8676002)(50226002)(6486002)(6512007)(6436002)(81166006)(97736004)(36756003)(81156014)(7736002)(11346002)(2616005)(446003)(186003)(486006)(476003)(4326008)(26005)(14454004)(6116002)(105586002)(102836004)(106356001)(107886003);
 DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR18MB2853;
 H:BYAPR18MB2424.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en;
 PTR:InfoNoRecords; A:1; MX:1; 
received-spf: None (protection.outlook.com: marvell.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: rYeYLk6PN/UMAg+J5fZRzmWS3Zf0rItsH4go25BOuAXDLfLtQmsSU70Ei5gZx/myPk3zQjyBywn4P/5m36jXZKjnXF8YqLvkPMrxm1yNbKOy3N7CO6SKFMpqRvr49g/JpvYTnM94Zwgq5YGWmVU+Gq/8VOLGPHLDDX+Orwj6oErIMvHIBxTbk0oE5b+Yb6HQ4tHGrZNFebSvrDcEm3Sm+znOll05YZeFEfuM/I3Ll167GpUXKzejeFNTv9i04msY8votE1RbuqMg1DlHopSzxWAF9vnJFFQUdphPBd1OAPqmeqgoCXPcbhjcNDV/LzRCJXdV2qlGnLBwmd6BSbxYMbjyJ1Nak2xuPZMDQCk40CPdQSbtPHYTvDFkxz8vJvWlX68Znma4JH3BRhNM4Ip0SUHLGMaqok5JwPAqhfSmXSQ=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-Network-Message-Id: 080b2033-0cf3-44af-a61b-08d6abc1c8d1
X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 16:50:10.9246 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2853
X-OriginatorOrg: marvell.com
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, ,
 definitions=2019-03-18_11:, , signatures=0
Subject: [dpdk-dev] [PATCH v6 1/4] mk: introduce helper to check valid
 compiler argument
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Message-ID: <20190318165010.cbzJkzANU3d2EhqfkOw0afEOP3NPOKUfKZiMNgD50Pk@z>

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 +=3D $(call rte_cc_has_argument, -mcpu=3Docteontx2)

This would allow adding -mcpu=3Docteontx2 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:

v2 Changes:
 - Add meson build support.

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

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

v5 Changes:
 - Fix incorrect meson flag parsing(Phil Yang)
 - Squash meson cross build patch(5/5) into configuration update patches fo=
r
 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)

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

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

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 +=3D $(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.
 #
=20
+#
+# 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
=20
-#
-# 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:
 #
--=20
2.21.0