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 CB231A04F5; Fri, 19 Jun 2020 01:13:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 65B65DE3; Fri, 19 Jun 2020 01:13:30 +0200 (CEST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id AF1ACDE0 for ; Fri, 19 Jun 2020 01:13:28 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id t74so4484278lff.2 for ; Thu, 18 Jun 2020 16:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B6eESN1/cnuzw0jKmxmlQHfoVp6WhIKU6xzzYRCw24U=; b=HkOqUl9pUvy+YhbGElnw94/K1rGx2Y/ZgXKzWxm0BtI5sObMjklnF5S9IJzoFWELrE 2vflMqMs7ybMFYhAC145GvI70vvNj3yNO88S2mlwhTj3UqLNh2Ra7otYlWVXUp3+DmIn CLzRtD66afT0XgQbEEaIl0ble7yG+MhZDo1seK2oi4e9EFERvQJrOeATRvCUTDdFEXk5 UTD1QEV1N0YE47EzLoUU43pvFZ2dG+4JHydgg1JpTmVdrrTBSwcqzmZo0Z8c+kgX0CjJ a1jkASHqKjXLQXX/Dd3+7h2oB96kJc90SYhazF7GyEkKBTp5Qg2fp7VCsDuaCcik+Uzz lkKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B6eESN1/cnuzw0jKmxmlQHfoVp6WhIKU6xzzYRCw24U=; b=AU4GLinRwRyv2BkUcdQ9vnEfhIrVoAdAfyXjE8BIbv2cu/JZCYwhYfYBL8FNEBsb08 cdcIozE1RoLyPV7qJyHx84leNwqv3enp9DcF3C4qNR+i8k3QeOwloapsmR2ZTi4xBl3c q6gF/4xu+zv2uq+JbPLS7IaBoXZSfsX6xE8YDTEBKA+3de28AXRNtSOSxGfTEBsbbPN5 uFK59sbiBJGW1onFybC+X5v4OOKFRinpXTnXPXGN0Ee2mED/kmYm7ABZTXnClRxyje7R LjMFAR0+l/RfChHvRwyhUlUb5893vQ0eTw5qmz5x0N0JdMOEGcAbBde4OcXxn4IFfAKB hMTA== X-Gm-Message-State: AOAM533aHgV2G/bI0kKkpo+oOB4/EuqxVhMbYbYQggjElip6/h7292aI fJYBQPmP9x42DRTJJ92f3YQ= X-Google-Smtp-Source: ABdhPJzv6jPy0SmXrq9dCS4rGdAqQ6zl5zGXaJ3k+ePHBgzT+W7mftibK3IMM24RzCJvDmAOl68TEw== X-Received: by 2002:a19:4915:: with SMTP id w21mr306505lfa.153.1592522008080; Thu, 18 Jun 2020 16:13:28 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id c3sm1037665lfi.91.2020.06.18.16.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 16:13:27 -0700 (PDT) Date: Fri, 19 Jun 2020 02:13:26 +0300 From: Dmitry Kozlyuk To: talshn@mellanox.com Cc: dev@dpdk.org, thomas@monjalon.net, pallavi.kadam@intel.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, harini.ramakrishnan@microsoft.com, ocardona@microsoft.com, anatoly.burakov@intel.com, fady@mellanox.com, bruce.richardson@intel.com Message-ID: <20200619021326.493469cb@sovereign> In-Reply-To: <20200618211546.24496-10-talshn@mellanox.com> References: <20200609103139.22168-2-talshn@mellanox.com> <20200618211546.24496-1-talshn@mellanox.com> <20200618211546.24496-10-talshn@mellanox.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6 9/9] build: generate version.map file for MingW on Windows 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" On Fri, 19 Jun 2020 00:15:46 +0300 talshn@mellanox.com wrote: > From: Tal Shnaiderman > > The MingW build for Windows has special cases where exported > function contain additional prefix: > > __emutls_v.per_lcore__* > > To avoid adding those prefixed functions to the version.map file > the map_to_def.py script was modified to create a map file for Mingw > with the needed changed. Thanks for working on this. Your solution is even simpler than we discussed, see some comments inline. > > The file name was changed to map_to_win.py > > Signed-off-by: Tal Shnaiderman > --- > buildtools/{map_to_def.py => map_to_win.py} | 21 ++++++++++++++++----- > buildtools/meson.build | 4 ++-- > drivers/meson.build | 12 +++++++++--- > lib/meson.build | 15 ++++++++++++--- > 4 files changed, 39 insertions(+), 13 deletions(-) > rename buildtools/{map_to_def.py => map_to_win.py} (51%) > > diff --git a/buildtools/map_to_def.py b/buildtools/map_to_win.py > similarity index 51% > rename from buildtools/map_to_def.py > rename to buildtools/map_to_win.py > index 6775b54a9d..dfb0748159 100644 > --- a/buildtools/map_to_def.py > +++ b/buildtools/map_to_win.py > @@ -13,23 +13,34 @@ def is_function_line(ln): > > def main(args): > if not args[1].endswith('version.map') or \ > - not args[2].endswith('exports.def'): > + not args[2].endswith('exports.def') and \ > + not args[2].endswith('mingw.map'): > return 1 > > # special case, allow override if an def file already exists alongside map file > +# for mingw also replace per_lcore__* to __emutls_v.per_lcore__* > override_file = join(dirname(args[1]), basename(args[2])) > if exists(override_file): > with open(override_file) as f_in: > - functions = f_in.readlines() > + lines = f_in.readlines() > + if args[2].endswith('mingw.map'): > + lines = [l.replace('per_lcore__', '__emutls_v.per_lcore__') for l in lines] > + functions = lines MinGW GCC linker doesn't fail on undefined symbols, so .map overrides will never be needed (and we're going to get rid of overrides soon anyway). > > # generate def file from map file. > -# This works taking indented lines only which end with a ";" and which don't > +# For clang this works taking indented lines only which end with a ";" and which don't > # have a colon in them, i.e. the lines defining functions only. > +# mingw keeps the original .map file but replaces per_lcore__* to __emutls_v.per_lcore__* > else: > with open(args[1]) as f_in: > - functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines()) > + lines = f_in.readlines() > + if args[2].endswith('mingw.map'): > + lines = [l.replace('per_lcore__', '__emutls_v.per_lcore__') for l in lines] > + functions = lines > + else: > + functions = [ln[:-2] + '\n' for ln in sorted(lines) > if is_function_line(ln)] > - functions = ["EXPORTS\n"] + functions > + functions = ["EXPORTS\n"] + functions Considering the comment above, entire logic for mingw.map is the following: if args[2].endswith('mingw.map'): with open(args[1]) as f_in, open(args[2], 'w') as f_out: f_out.writelines([...replace... for line in f_in.readlines()]) return 0 Wouldn't it be cleaner to move it to the beginning of function or even to a separate function dispatched by filename (or even script)? Motivation: soon .def logic will become more complicated and Windows-dependent (to analyze dumpbin.exe output), intertwining it with .map saves nothing and will impede. -- Dmitry Kozlyuk