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 inbox.dpdk.org (Postfix) with ESMTP id 963D4A04DD;
	Wed, 28 Oct 2020 15:06:51 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id B54ACCBB4;
	Wed, 28 Oct 2020 15:04:52 +0100 (CET)
Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20])
 by dpdk.org (Postfix) with ESMTP id 9EEE7CB00
 for <dev@dpdk.org>; Wed, 28 Oct 2020 15:04:19 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by lb.pantheon.sk (Postfix) with ESMTP id 4B833B6B56;
 Wed, 28 Oct 2020 15:04:17 +0100 (CET)
X-Virus-Scanned: amavisd-new at siecit.sk
Received: from lb.pantheon.sk ([127.0.0.1])
 by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id l6n_INHaetp6; Wed, 28 Oct 2020 15:04:16 +0100 (CET)
Received: from service-node1.lab.pantheon.local (unknown [46.229.239.141])
 by lb.pantheon.sk (Postfix) with ESMTP id 7D4C0B6B5B;
 Wed, 28 Oct 2020 15:04:10 +0100 (CET)
From: =?UTF-8?q?Juraj=20Linke=C5=A1?= <juraj.linkes@pantheon.tech>
To: bruce.richardson@intel.com, Ruifeng.Wang@arm.com,
 Honnappa.Nagarahalli@arm.com, Phil.Yang@arm.com, vcchunga@amazon.com,
 Dharmik.Thakkar@arm.com, jerinjacobk@gmail.com, hemant.agrawal@nxp.com
Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= <juraj.linkes@pantheon.tech>
Date: Wed, 28 Oct 2020 15:04:01 +0100
Message-Id: <1603893845-5736-8-git-send-email-juraj.linkes@pantheon.tech>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1603893845-5736-1-git-send-email-juraj.linkes@pantheon.tech>
References: <1603464488-25493-1-git-send-email-juraj.linkes@pantheon.tech>
 <1603893845-5736-1-git-send-email-juraj.linkes@pantheon.tech>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v5 07/11] build: Arm generic and native build
	setup
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>

Simplify the code. Define native machine args in one place since they're
the same regardless of which Arm environment we're building on.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 56 +++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 25 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 2f89cb2a8..1866ad961 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -3,7 +3,10 @@
 # Copyright(c) 2017 Cavium, Inc
 # Copyright(c) 2020 PANTHEON.tech s.r.o.
 
+# set arm_force_native_march if you want to use machine args below
+# instead of discovered values in native builds
 arm_force_native_march = false
+native_machine_args = ['-march=native', '-mtune=native']
 
 # common flags to all aarch64 builds, with lowest priority
 flags_common_default = [
@@ -103,7 +106,6 @@ flags_octeontx2_extra = [
 # arm config (implementer 0x41) is the default config
 part_number_config_default = {
 	'generic': [['-march=armv8-a+crc', '-moutline-atomics']],
-	'native': [['-march=native']],
 	'0xd03': [['-mcpu=cortex-a53']],
 	'0xd04': [['-mcpu=cortex-a35']],
 	'0xd07': [['-mcpu=cortex-a57']],
@@ -115,7 +117,6 @@ part_number_config_default = {
 }
 part_number_config_cavium = {
 	'generic': [['-march=armv8-a+crc+crypto', '-mcpu=thunderx']],
-	'native': [['-march=native']],
 	'0xa1': [['-mcpu=thunderxt88'], flags_thunderx_extra],
 	'0xa2': [['-mcpu=thunderxt81'], flags_thunderx_extra],
 	'0xa3': [['-mcpu=thunderxt83'], flags_thunderx_extra],
@@ -123,8 +124,7 @@ part_number_config_cavium = {
 	'0xb2': [['-march=armv8.2-a+crc+crypto+lse','-mcpu=octeontx2'], flags_octeontx2_extra],
 }
 part_number_config_emag = {
-	'generic': [['-march=armv8-a+crc+crypto', '-mtune=emag']],
-	'native': [['-march=native']]
+	'generic': [['-march=armv8-a+crc+crypto', '-mtune=emag']]
 }
 
 ## Arm implementer ID (ARM DDI 0487C.a, Section G7.2.106, Page G7-5321)
@@ -155,32 +155,35 @@ if dpdk_conf.get('RTE_ARCH_32')
 	machine_args += '-mfpu=neon'
 else
 	# aarch64 build
-	implementer_id = 'generic'
 	machine_args = [] # Clear previous machine args
-	if machine == 'generic' and not meson.is_cross_build()
-		implementer_config = implementer_generic
-		part_number = 'generic'
-	elif not meson.is_cross_build()
-		# The script returns ['Implementer', 'Variant', 'Architecture',
-		# 'Primary Part number', 'Revision']
-		detect_vendor = find_program(join_paths(
-				meson.current_source_dir(), 'armv8_machine.py'))
-		cmd = run_command(detect_vendor.path())
-		if cmd.returncode() == 0
-			cmd_output = cmd.stdout().to_lower().strip().split(' ')
-			implementer_id = cmd_output[0]
-			part_number = cmd_output[3]
-		endif
-		# Set to generic if variable is not found
-		implementer_config = get_variable('implementer_' + implementer_id, ['generic'])
-		if implementer_config[0] == 'generic'
+	if not meson.is_cross_build()
+		if machine == 'generic'
+			# generic native build
 			implementer_config = implementer_generic
 			part_number = 'generic'
-		endif
-		if arm_force_native_march == true
-			part_number = 'native'
+		else
+			# native build
+			# The script returns ['Implementer', 'Variant', 'Architecture',
+			# 'Primary Part number', 'Revision']
+			detect_vendor = find_program(join_paths(
+					meson.current_source_dir(), 'armv8_machine.py'))
+			cmd = run_command(detect_vendor.path())
+			if cmd.returncode() == 0
+				cmd_output = cmd.stdout().to_lower().strip().split(' ')
+				implementer_id = cmd_output[0]
+				part_number = cmd_output[3]
+			else
+				implementer_id = 'generic'
+				part_number = 'generic'
+			endif
+			# Set to generic if implementer is not found
+			implementer_config = get_variable('implementer_' + implementer_id, implementer_generic)
+			if arm_force_native_march == true
+				part_number = 'native'
+			endif
 		endif
 	else
+		# cross build
 		implementer_id = meson.get_cross_property('implementer_id', 'generic')
 		part_number = meson.get_cross_property('part_number', 'generic')
 		implementer_config = get_variable('implementer_' + implementer_id)
@@ -193,6 +196,9 @@ else
 	if part_number_config.has_key(part_number)
 		# use the specified part_number machine args if found
 		part_number_config = part_number_config[part_number]
+	elif part_number == 'native'
+		# use native machine args
+		part_number_config = [[native_machine_args]]
 	elif not meson.is_cross_build()
 		# default to generic machine args if part_number is not found
 		# and not forcing native machine args
-- 
2.20.1