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 CF07DA04A5; Wed, 17 Jun 2020 12:40:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ED76A1150; Wed, 17 Jun 2020 12:40:22 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 6E30AFFA for ; Wed, 17 Jun 2020 12:40:21 +0200 (CEST) IronPort-SDR: KeukWDF6U2uS/+nEiUM02hBNCn2vDEKEZRUJWCEuAdJVY3lb0MiVMH4OnnTKr51vkN4mEBYEj1 PobcgEFvyz7w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2020 03:40:20 -0700 IronPort-SDR: 17V+wlirf5NpponReOaTj3DvmVxpSxM+91/Q+BfbthnQ7lhDEYw5EDl09jSvAdIKGC8BZo4/hk lJOW8yf31EsQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,522,1583222400"; d="scan'208";a="476782819" Received: from silpixa00399126.ir.intel.com ([10.237.222.84]) by fmsmga006.fm.intel.com with ESMTP; 17 Jun 2020 03:40:19 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ferruh.yigit@intel.com, thomas@monjalon.net, Bruce Richardson Date: Wed, 17 Jun 2020 11:40:12 +0100 Message-Id: <20200617104012.470617-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] build: check functionality rather than binutils version 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" Rather than checking the binutils version number, which can lead to unnecessary disabling of AVX512 if fixes have been backported to distro versions, we can instead check the output of "as" from binutils to see if it is correct. These checks use the minimal assembly reproduction code posted to the public bug tracker for gcc/binutils for those issues [1][2]. If the binutils bug is present, the instruction parameters - specifically the displacement parameter - will be different in the disassembled output compared to the input. Therefore each check involves assembling a single instruction and disassembling it again, checking that the two match. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028 [2] https://sourceware.org/bugzilla/show_bug.cgi?id=23465 Signed-off-by: Bruce Richardson --- buildtools/binutils-avx512-check.sh | 26 ++++++++++++++++++++++++++ buildtools/meson.build | 3 +-- config/x86/meson.build | 10 +++------- meson.build | 5 ++++- 4 files changed, 34 insertions(+), 10 deletions(-) create mode 100755 buildtools/binutils-avx512-check.sh diff --git a/buildtools/binutils-avx512-check.sh b/buildtools/binutils-avx512-check.sh new file mode 100755 index 000000000..1e894d84d --- /dev/null +++ b/buildtools/binutils-avx512-check.sh @@ -0,0 +1,26 @@ +#! /bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +AS=${AS:-as} +MESON_BUILD_ROOT=${MESON_BUILD_ROOT:-/tmp} +OBJFILE=$MESON_BUILD_ROOT/binutils-avx512-check.o +# from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028 +GATHER_PARAMS='0x8(,%ymm1,1),%ymm0{%k2}' +# from https://sourceware.org/bugzilla/show_bug.cgi?id=23465 +MOVAPS_PARAMS='0x40(,%rax,1),%zmm0' + +# assemble vmovaps statement to file +echo "vmovaps $MOVAPS_PARAMS" | $AS --64 -o $OBJFILE - +# check the parameters are correct in the output, using objdump +objdump -d --no-show-raw-insn $OBJFILE | grep -q $MOVAPS_PARAMS || { + echo "vmovaps displacement error with as" + exit 1 +} + +# assemble vpgather to file and similarly check +echo "vpgatherqq $GATHER_PARAMS" | $AS --64 -o $OBJFILE - +objdump -d --no-show-raw-insn $OBJFILE | grep -q $GATHER_PARAMS || { + echo "vpgatherqq displacement error with as" + exit 1 +} diff --git a/buildtools/meson.build b/buildtools/meson.build index d5f8291be..73a847c52 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -1,13 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -subdir('pmdinfogen') - pkgconf = find_program('pkg-config', 'pkgconf', required: false) pmdinfo = find_program('gen-pmdinfo-cfile.sh') list_dir_globs = find_program('list-dir-globs.py') check_symbols = find_program('check-symbols.sh') ldflags_ibverbs_static = find_program('options-ibverbs-static.sh') +binutils_avx512_check = find_program('binutils-avx512-check.sh') # set up map-to-def script using python, either built-in or external python3 = import('python').find_installation(required: false) diff --git a/config/x86/meson.build b/config/x86/meson.build index adc857ba2..fbcd8e455 100644 --- a/config/x86/meson.build +++ b/config/x86/meson.build @@ -3,14 +3,10 @@ # get binutils version for the workaround of Bug 97 if not is_windows - ldver = run_command('ld', '-v').stdout().strip() - if ldver.contains('2.30') and cc.has_argument('-mno-avx512f') + as_ok = run_command(binutils_avx512_check) + if as_ok.returncode() != 0 and cc.has_argument('-mno-avx512f') machine_args += '-mno-avx512f' - message('Binutils 2.30 detected, disabling AVX512 support as workaround for bug #97') - endif - if ldver.contains('2.31') and cc.has_argument('-mno-avx512f') - machine_args += '-mno-avx512f' - message('Binutils 2.31 detected, disabling AVX512 support as workaround for bug #249') + message('Binutils error with AVX512 assembly, disabling AVX512 support') endif endif diff --git a/meson.build b/meson.build index 750fdeab1..ab4d60cfa 100644 --- a/meson.build +++ b/meson.build @@ -41,10 +41,13 @@ global_inc = include_directories('.', 'config', 'lib/librte_eal/@0@/include'.format(host_machine.system()), 'lib/librte_eal/@0@/include'.format(arch_subdir), ) + +# do configuration and get tool paths +subdir('buildtools') subdir('config') # build libs and drivers -subdir('buildtools') +subdir('buildtools/pmdinfogen') subdir('lib') subdir('drivers') -- 2.25.1