From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2043EA0559; Mon, 16 Mar 2020 13:05:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1614625D9; Mon, 16 Mar 2020 13:05:06 +0100 (CET) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id BC4AC1AFF for ; Mon, 16 Mar 2020 13:05:03 +0100 (CET) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 5A7135C0228; Mon, 16 Mar 2020 08:05:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 16 Mar 2020 08:05:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=8CBRFWNq8qNri8Ew+uOaIOL zYQ0jS7FkclauN6NiZBQ=; b=QXwUdBrIWdrMWZpOppc3CcURUQltemZu6QciNI3 hNeD7t+9CdbDpvGJBN0NUNZLm/+xDgoRTpT9HnAmOXGl9Q5G01th+HSKBL91KUiS bSgO59tgEbJY0JZNaZRC7foIIYuK76eE2up2Zaf4YfLEVnJCW02iuGME9fmyz73Y jb+E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=8CBRFWNq8qNri8Ew+ uOaIOLzYQ0jS7FkclauN6NiZBQ=; b=EhmmZZ2WJWyX7aBmvMiVqnsSlXtwZwyw4 FKwnmvMVNnPpf673NcGtlsX5olQQQBe2p1csWfYpL2MSRQqVp4qACTqp+hVxU9Tn 2GpZymgD/q270eQwc8+nUKgTO9mTi7+B+hSLh69p2Y0jIS/5nYCzrCzi0ZnYGgX0 daGnL0JiVs1SdRCggDNODhPhpZ4OZQL/cPnb408w15gVZxmtukQJtgVxiz9+E5SK 8GX1W+z6jF1AxzhjFlpefhV+w5sbIBW+lBAuz7dSNLhhPvWb5KmyCYtS7f/VgXU0 21eTLA5vt2ltjE9U4a5y0eGLAI374vpXF3im/7OAfSzrw/qIGH3sQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudeffedgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgrshcu ofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecuffhomh grihhnpeguphgukhdrohhrghenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghsse hmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A944E3280060; Mon, 16 Mar 2020 08:05:01 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: bruce.richardson@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, Jerin Jacob , Gavin Hu , Jan Viktorin , Cristian Dumitrescu Date: Mon, 16 Mar 2020 13:04:53 +0100 Message-Id: <20200316120454.933575-1-thomas@monjalon.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal: fix compiler detection in public headers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" RTE_TOOLCHAIN_* macros are defining the target compiler. Some API may be used in a host application like pmdinfogen. That's why the the public headers should check the effective compiler in use instead of the target compiler. Detecting the compiler with macros is easy, except for __GNUC__ which is defined in all compilers supporting some GNU compatibility. It is improved by defining RTE_CC_CLANG, RTE_CC_ICC and RTE_CC_GCC. The extra macro RTE_CC_IS_GNU is defined to 0 or 1 in GCC case, so it can be used simply with #if. Signed-off-by: Thomas Monjalon --- This patch is probably useless. The first intent was fixing pmdinfogen compilation with clang while compiling the target with GCC, with MinGW support patch. This case is now better fixed with a patch removing EAL dependencies from the PCI library, which drops rte_common.h inclusion from pmdinfogen: http://patches.dpdk.org/patch/66701/ As a consequence, I send this EAL patch just in case we need it in future. We can decide to apply or leave it. --- .../common/include/arch/arm/rte_memcpy_64.h | 2 +- .../common/include/arch/arm/rte_vect.h | 4 ++-- lib/librte_eal/common/include/rte_common.h | 19 +++++++++++++++++-- lib/librte_table/rte_lru_x86.h | 4 ++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h b/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h index beb97a71ef..85ad587bd3 100644 --- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h +++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h @@ -89,7 +89,7 @@ n <= (size_t)RTE_ARM64_MEMCPY_UNALIGNED_THRESHOLD) **************************************/ -#if defined(RTE_TOOLCHAIN_GCC) && !defined(RTE_ARM64_MEMCPY_SKIP_GCC_VER_CHECK) +#if RTE_CC_IS_GNU && !defined RTE_ARM64_MEMCPY_SKIP_GCC_VER_CHECK #if (GCC_VERSION < 50400) #warning "The GCC version is quite old, which may result in sub-optimal \ performance of the compiled code. It is suggested that at least GCC 5.4.0 \ diff --git a/lib/librte_eal/common/include/arch/arm/rte_vect.h b/lib/librte_eal/common/include/arch/arm/rte_vect.h index 2a18a68546..454ac7e578 100644 --- a/lib/librte_eal/common/include/arch/arm/rte_vect.h +++ b/lib/librte_eal/common/include/arch/arm/rte_vect.h @@ -62,7 +62,7 @@ vaddvq_u16(uint16x8_t a) #endif -#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION < 70000) +#if RTE_CC_IS_GNU && (GCC_VERSION < 70000) static inline uint32x4_t vcopyq_laneq_u32(uint32x4_t a, const int lane_a, uint32x4_t b, const int lane_b) @@ -72,7 +72,7 @@ vcopyq_laneq_u32(uint32x4_t a, const int lane_a, #endif #if defined(RTE_ARCH_ARM64) -#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION < 70000) +#if RTE_CC_IS_GNU && (GCC_VERSION < 70000) #if (GCC_VERSION < 40900) typedef uint64_t poly64_t; diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 4ced4d6fa1..7f0253a782 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -42,8 +42,23 @@ extern "C" { #define RTE_STD_C11 #endif -/** Define GCC_VERSION **/ -#ifdef RTE_TOOLCHAIN_GCC +/* + * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC, + * while a host application (like pmdinfogen) may have another compiler. + * RTE_CC_IS_GNU is true if the file is compiled with GCC, + * no matter it is a target or host application. + */ +#define RTE_CC_IS_GNU 0 +#if defined __clang__ +#define RTE_CC_CLANG +#elif defined __INTEL_COMPILER +#define RTE_CC_ICC +#elif defined __GNUC__ +#define RTE_CC_GCC +#undef RTE_CC_IS_GNU +#define RTE_CC_IS_GNU 1 +#endif +#if RTE_CC_IS_GNU #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + \ __GNUC_PATCHLEVEL__) #endif diff --git a/lib/librte_table/rte_lru_x86.h b/lib/librte_table/rte_lru_x86.h index 7a67ee8bd5..0e24906c2c 100644 --- a/lib/librte_table/rte_lru_x86.h +++ b/lib/librte_table/rte_lru_x86.h @@ -19,7 +19,7 @@ extern "C" { #if RTE_TABLE_HASH_LRU_STRATEGY == 2 -#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION > 40306) +#if RTE_CC_IS_GNU && (GCC_VERSION > 40306) #include #else #include @@ -63,7 +63,7 @@ do { \ #elif RTE_TABLE_HASH_LRU_STRATEGY == 3 -#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION > 40306) +#if RTE_CC_IS_GNU && (GCC_VERSION > 40306) #include #else #include -- 2.25.1