From nobody Fri Dec 19 20:14:18 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599221009; cv=none; d=zohomail.com; s=zohoarc; b=WW6iQVQ9Mtwl9inl/9+bkTapxTz2SC0iSVPcBbFO0a2f5VvnW/wsjvscVEWYG2qUSzL1iaBxIaAJSmmV+hq5vE5xzfi8EzYl/Uy/ija64M0JgOshh6MQMV23dloMp9KH55NXBJUusm1O8qjni8sIUoNXQJ6a9LXKWV4Ui5yEXDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599221009; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D4PQW8qs7XPwLNu9A0HKFz2ckQOkfDbxP0qT21w2DvA=; b=YiAk7eUxplz3ZtWQLwUt3++nPgbQJe3OAxlHzylkqXT8lKSjyhivIO6AjuwhAnUzL1x4YSvc1SvJh2GF+Wp0syiHvhrpVQWHrT8irJwBitBsCROziVl4qtSofetj3Ru96kpe7ZwM264QjDEGAV0NTfu4N0dcFI6+JT0CZvQqPFs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599221009144404.2251494773244; Fri, 4 Sep 2020 05:03:29 -0700 (PDT) Received: from localhost ([::1]:46428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEARB-0008K8-P4 for importer@patchew.org; Fri, 04 Sep 2020 08:03:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEA6x-0001Au-Ju for qemu-devel@nongnu.org; Fri, 04 Sep 2020 07:42:31 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53365 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kEA6v-0005JD-GI for qemu-devel@nongnu.org; Fri, 04 Sep 2020 07:42:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-MlNJN3NfOCmFmBq3WcLg5A-1; Fri, 04 Sep 2020 07:42:27 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65CE896E572; Fri, 4 Sep 2020 11:41:48 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2535A10013C4; Fri, 4 Sep 2020 11:41:48 +0000 (UTC) X-MC-Unique: MlNJN3NfOCmFmBq3WcLg5A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 45/46] meson: Convert undefsym.sh to undefsym.py Date: Fri, 4 Sep 2020 07:41:21 -0400 Message-Id: <20200904114122.31307-46-pbonzini@redhat.com> In-Reply-To: <20200904114122.31307-1-pbonzini@redhat.com> References: <20200904114122.31307-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yonggang Luo Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Yonggang Luo Shell scripts are not easily invoked from the build process on MSYS, so convert undefsym.sh to a python script. Signed-off-by: Yonggang Luo Message-Id: <20200902170054.810-3-luoyonggang@gmail.com> Signed-off-by: Paolo Bonzini --- meson.build | 2 +- scripts/undefsym.py | 49 +++++++++++++++++++++++++++++++++++++++++++++ scripts/undefsym.sh | 20 ------------------ 3 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 scripts/undefsym.py delete mode 100755 scripts/undefsym.sh diff --git a/meson.build b/meson.build index 9473b42da3..6ed3c37f46 100644 --- a/meson.build +++ b/meson.build @@ -942,7 +942,7 @@ foreach d, list : modules endforeach =20 nm =3D find_program('nm') -undefsym =3D find_program('scripts/undefsym.sh') +undefsym =3D find_program('scripts/undefsym.py') block_syms =3D custom_target('block.syms', output: 'block.syms', input: [libqemuutil, block_mods], capture: true, diff --git a/scripts/undefsym.py b/scripts/undefsym.py new file mode 100644 index 0000000000..69a895cd26 --- /dev/null +++ b/scripts/undefsym.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +# Before a shared module's DSO is produced, a static library is built for = it +# and passed to this script. The script generates -Wl,-u options to force +# the inclusion of symbol from libqemuutil.a if the shared modules need th= em, +# This is necessary because the modules may use functions not needed by the +# executable itself, which would cause the function to not be linked in. +# Then the DSO loading would fail because of the missing symbol. + + +import sys +import subprocess + +def filter_lines_set(stdout, from_staticlib): + linesSet =3D set() + for line in stdout.splitlines(): + tokens =3D line.split(b' ') + if len(tokens) >=3D 1: + if len(tokens) > 1: + if from_staticlib and tokens[1] =3D=3D b'U': + continue + if not from_staticlib and tokens[1] !=3D b'U': + continue + new_line =3D b'-Wl,-u,' + tokens[0] + if not new_line in linesSet: + linesSet.add(new_line) + return linesSet + +def main(args): + if len(args) <=3D 3: + sys.exit(0) + + nm =3D args[1] + staticlib =3D args[2] + pc =3D subprocess.run([nm, "-P", "-g", staticlib], stdout=3Dsubprocess= .PIPE) + if pc.returncode !=3D 0: + sys.exit(1) + staticlib_syms =3D filter_lines_set(pc.stdout, True) + + shared_modules =3D args[3:] + pc =3D subprocess.run([nm, "-P", "-g"] + shared_modules, stdout=3Dsubp= rocess.PIPE) + if pc.returncode !=3D 0: + sys.exit(1) + modules_undef_syms =3D filter_lines_set(pc.stdout, False) + lines =3D sorted(staticlib_syms.intersection(modules_undef_syms)) + sys.stdout.buffer.write(b'\n'.join(lines)) + +if __name__ =3D=3D "__main__": + main(sys.argv) diff --git a/scripts/undefsym.sh b/scripts/undefsym.sh deleted file mode 100755 index b9ec332e95..0000000000 --- a/scripts/undefsym.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env bash - -# Before a shared module's DSO is produced, a static library is built for = it -# and passed to this script. The script generates -Wl,-u options to force -# the inclusion of symbol from libqemuutil.a if the shared modules need th= em, -# This is necessary because the modules may use functions not needed by the -# executable itself, which would cause the function to not be linked in. -# Then the DSO loading would fail because of the missing symbol. - -if test $# -le 2; then - exit 0 -fi - -NM=3D$1 -staticlib=3D$2 -shift 2 -# Find symbols defined in static libraries and undefined in shared modules -comm -12 \ - <( $NM -P -g $staticlib | awk '$2!=3D"U"{print "-Wl,-u," $1}' | sort -u)= \ - <( $NM -P -g "$@" | awk '$2=3D=3D"U"{print "-Wl,-u," $1}' | sort -u) --=20 2.26.2