From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id BC6C1A0C4B
	for <public@inbox.dpdk.org>; Wed, 27 Oct 2021 12:53:26 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id A98574003F;
	Wed, 27 Oct 2021 12:53:26 +0200 (CEST)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by mails.dpdk.org (Postfix) with ESMTP id E8B8A4003F;
 Wed, 27 Oct 2021 12:53:24 +0200 (CEST)
X-IronPort-AV: E=McAfee;i="6200,9189,10149"; a="230081127"
X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="230081127"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 27 Oct 2021 03:53:24 -0700
X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="497812983"
Received: from bricha3-mobl.ger.corp.intel.com ([10.252.16.125])
 by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA;
 27 Oct 2021 03:53:22 -0700
Date: Wed, 27 Oct 2021 11:53:19 +0100
From: Bruce Richardson <bruce.richardson@intel.com>
To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Cc: dev@dpdk.org, stable@dpdk.org, Michal Berger <michallinuxstuff@gmail.com>,
 Neil Horman <nhorman@tuxdriver.com>
Message-ID: <YXkvn0TvlIwwHgwW@bricha3-MOBL.ger.corp.intel.com>
References: <20211026193239.113745-1-dmitry.kozliuk@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20211026193239.113745-1-dmitry.kozliuk@gmail.com>
Subject: Re: [dpdk-stable] [PATCH] buildtools: fix build with meson 0.60
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

On Tue, Oct 26, 2021 at 10:32:39PM +0300, Dmitry Kozlyuk wrote:
> Meson 0.60 switched the format of uninstalled static libraries
> to thin archives, that is, they contain only paths to object files,
> not the files themselves. Files cannot be extracted in this case,
> resulting in build errors:
> 
>     ar: `x' cannot be used on thin archives.
> 
> Handle thin archives when invoking pmdinfogen
> by directly using the files referenced in the archive.
> 
> Bugzilla ID: 836
> Fixes: e6e9730c7066 ("buildtools: support object file extraction for Windows")
> Cc: stable@dpdk.org
> 
> Reported-by: Michal Berger <michallinuxstuff@gmail.com>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

Thanks for looking into this and proposing a fix. Some thoughts inline
below.

/Bruce

> ---
>  buildtools/gen-pmdinfo-cfile.py | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/buildtools/gen-pmdinfo-cfile.py b/buildtools/gen-pmdinfo-cfile.py
> index 58fe3ad152..3453e5b4b9 100644
> --- a/buildtools/gen-pmdinfo-cfile.py
> +++ b/buildtools/gen-pmdinfo-cfile.py
> @@ -8,13 +8,18 @@
>  import tempfile
>  
>  _, tmp_root, ar, archive, output, *pmdinfogen = sys.argv
> -with tempfile.TemporaryDirectory(dir=tmp_root) as temp:
> -    run_ar = lambda command: subprocess.run(
> -        [ar, command, os.path.abspath(archive)],
> -        stdout=subprocess.PIPE, check=True, cwd=temp
> -    )
> -    # Don't use "ar p", because its output is corrupted on Windows.
> -    run_ar("x")
> -    names = run_ar("t").stdout.decode().splitlines()
> -    paths = [os.path.join(temp, name) for name in names]
> +archive = os.path.abspath(archive)
> +names = subprocess.run([ar, "t", archive],
> +    stdout=subprocess.PIPE, check=True).stdout.decode().splitlines()
> +with open(archive, "rb") as f:
> +    is_thin = f.read(7) == b"!<thin>"

This part seems overly low-level, and a bit nasty to me, compared to the
rest of the script.

Since the thin archive files already exist, I wonder if we could work on a
file by file basis here, and ignore generally the type of the ".a" file.
For example, something like:

    o_files = []
    for n in names:
        if os.path.exists(n):
            o_files += n
        else
            <extract file>
            o_files += <extracted_path>

WDYT?