Message ID | 87r0mapspt.fsf@redhat.com |
---|---|
Headers |
Return-Path: <libabigail-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E92F3858423 for <patchwork@sourceware.org>; Wed, 4 Oct 2023 10:50:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E92F3858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696416617; bh=QT13mrZRorGsfJaZI/7ITNn3r7unJ423m0DyRgEeEz4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=MgLYKoj9IlQKIa5tXvAXSJz7q8Lmk1IvUutqHFv632cY6ljAo9dLebJED3iGdfWAV q18EYfnAqkd6oJcLn7A93+4/xT7hEotkPmlYOWni2h++4Tlpk83PKSKyxhrSNGNU+g 1+fuEVhrznPEZCFk5qtugbGU2TGf6TyE/XZlsw40= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 156EA3858CDB for <libabigail@sourceware.org>; Wed, 4 Oct 2023 10:50:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 156EA3858CDB Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-171-xX4RMBnINImAzFSng9vTXQ-1; Wed, 04 Oct 2023 06:50:10 -0400 X-MC-Unique: xX4RMBnINImAzFSng9vTXQ-1 Received: by mail-vs1-f70.google.com with SMTP id ada2fe7eead31-45266ea607eso921837137.3 for <libabigail@sourceware.org>; Wed, 04 Oct 2023 03:50:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696416610; x=1697021410; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QT13mrZRorGsfJaZI/7ITNn3r7unJ423m0DyRgEeEz4=; b=B3PBg/cv3AlmB9TA+y4MIjSlPHXuMBgwDqCTe8RonM/oUAKoH8IBj6tmdRjMuW/XJC OB53gbsVrVRK954N/UywuYjh/WwzbVuRbRCMqY9LwM1GlORMh39DpFfotDFEo9x94/tP ErOcLSy3E/iXFmhnsj0SZ+MFvALJp7qFv7ugT9D02oM7k9ApNrhO8SJQO6RDSmhxAo/p WtmwJPf+M8dNX4N12uhwzDvEaszlL9Q1SgLmD9/c3cs6YYrLVfHHYstFjMe9cK4W5cVY VJ4bVNVByGvRFlLjEInHkAwm3vaPLzlqkR91Ep9Nn38rPKxrOEYrcLmTaZ0CsJ9O46Qz r3SQ== X-Gm-Message-State: AOJu0Yw6F4eKD0uGUwIELbmMxbqwVoboWfhZghZuGwdDblapJ1cexclV +u0+nrNWaBf7LGOFAYtW4xS3YueMhcH7sn+oFL61XcInLNlnmeHq7pqHZYUxm2pZ5ByASYWG0sU YXvO8DndMV6bVkbnNZcGq X-Received: by 2002:a67:ed06:0:b0:452:66b0:e3ad with SMTP id l6-20020a67ed06000000b0045266b0e3admr1720474vsp.20.1696416609792; Wed, 04 Oct 2023 03:50:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKfKySGvRIrmGXJdCHBsoShY9WCZyxH8u7pWXxvoYb6ZPL+FuwP/1dypufq/cfpDy7ROLs1g== X-Received: by 2002:a67:ed06:0:b0:452:66b0:e3ad with SMTP id l6-20020a67ed06000000b0045266b0e3admr1720464vsp.20.1696416609412; Wed, 04 Oct 2023 03:50:09 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id r2-20020a0ccc02000000b0064f77d37798sm1227288qvk.5.2023.10.04.03.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 03:50:08 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 0B30AB6EB1; Wed, 4 Oct 2023 12:50:07 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH 0/3, V2] For WIP branch check-uapi-support: Fix comparing non-reachable anonymous enums Organization: Red Hat / France X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Wed, 04 Oct 2023 12:50:06 +0200 Message-ID: <87r0mapspt.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project <libabigail.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libabigail>, <mailto:libabigail-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libabigail/> List-Help: <mailto:libabigail-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libabigail>, <mailto:libabigail-request@sourceware.org?subject=subscribe> From: Dodji Seketeli via Libabigail <libabigail@sourceware.org> Reply-To: Dodji Seketeli <dodji@redhat.com> Cc: Trilok Soni <quic_tsoni@quicinc.com>, dodji@redhat.com, Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com> Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" <libabigail-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
For WIP branch check-uapi-support: Fix comparing non-reachable anonymous enums
|
|
Message
Dodji Seketeli
Oct. 4, 2023, 10:50 a.m. UTC
Hello, The version 2 of this patch set is intended for the check-uapi-support branch dedicated to supporting the check-uapi.sh script [1]. Note that the difference with the first version is that the first patch of the previous version got merged into the master branch because it was independant from the task at hand. You can see it at https://inbox.sourceware.org/libabigail/87cyxur879.fsf@redhat.com. Please find below a thorough description of this patch set. The description of the task of supporting the comparison of non-reachable anonymous enums can be read on the email https://inbox.sourceware.org/libabigail/340b33bd-2b43-9f99-58e1-f1b77a51b48a@quicinc.com/: Another issue that comes up when comparing ABI across wide swaths of kernel commit history are changes to anonymous enums. From what I can tell, there's not a great way to handle this. If someone adds a new anonymous enum, the tag abidiff gives (e.g. enum __anonymous_enum__6) can change, so abidiff reports a new anonymous enum with all the same fields even though it was basically just a "rename". For reference, this file is full of anonymous enums: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/ethtool_netlink.h#L15. Basically any change in there is triggering a failure from the script. So, this patch set allows changes to anonymous enums that are not used by any function or global to be represented as we would expect them. For instance, suppose that a translation unit has the anonymous enums below: enum { E1_0, E1_1 }; enum { E2_0, E2_1 }; Suppose also that a subsequent version of that translation unit had some changes to that anonymous enum, making it become: enum { E1_0, E1_1, E1_2 }; enum { E2_0, E2_1, E2_2 }; Before this patch, compiling the files with the gcc option -fno-eliminate-unused-debug-types and using abidiff --non-reachable-types on the output would yield something like: Unreachable types summary: 0 removed, 1 changed, 1 added types 1 changed type unreachable from any public interface: [C] 'enum __anonymous_enum__1' changed: type name changed from '__anonymous_enum__1' to '__anonymous_enum__' type size hasn't changed 2 enumerator deletions: '__anonymous_enum__1::E2_0' value '0' '__anonymous_enum__1::E2_1' value '1' 3 enumerator insertions: '__anonymous_enum__::E1_O' value '0' '__anonymous_enum__::E1_1' value '1' '__anonymous_enum__::E1_2' value '2' 1 added type unreachable from any public interface: [A] 'enum __anonymous_enum__1' at test1-v1.c:9:1 What happens here is that: 1/ the internal name used to designate anonymous enums for the purpose of type canonicalization is used for user-facing reporting, which arguably makes very little sense from the point of view of the users. 2/ The generation of the internal names for anonymous enums is not meant to be "stable" across translation units. So the internal name of the first anonymous enum in the first version of the translation unit doesn't necessary match the one in the second version of the translation unit. And a number of downstream issues originates from 1/ and 2/. The second patch of the set designates anonymous enums by their "flat textual representation". Said otherwise, the name of the first enum is going to be: "enum {E1_0, E1_1,}". This should solve 1/ and 2/. In the reporting engine, the first patch uses that "flat representation" to name anonymous types in general (and enums in particular), instead of trying to use their qualified name (and thus their internal meaningless names). The third patch teaches the comparison engine that if an anonymous enum is deleted and added again (with the two version of the anonymous enum differing by a few enumerators), then we are probably looking at a change of anonymous enum. In any case, with this patch set applied, abidiff says the following about the example given earlier: Unreachable types summary: 0 removed, 2 changed, 0 added types 2 changed types unreachable from any public interface: [C] 'enum {E2_0=0, E2_1=1, }' changed: type size hasn't changed 1 enumerator insertion: 'E2_2' value '2' [C] 'enum {E1_1=1, E1_O=0, }' changed: type size hasn't changed 1 enumerator insertion: 'E1_2' value '2' This is much closer to what we'd intuitively expect. This patch set is to be merging into the branch "check-uapi-support" https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/check-uapi-support, so that it stays somewhat testable. For now, the patches are in the branch "better-anon-enums" which can be browsed at https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/better-anon-enums. [1]: The bug that tracks the work to support the check-uapi.sh script is https://sourceware.org/bugzilla/show_bug.cgi?id=30931. Dodji Seketeli (3): default-reporter,reporter-priv: Do not report names of anonymous enums ir,comparison,corpus: Better support anonymous enums comparison ir,comparison: Represent changed anonymous enums include/abg-fwd.h | 27 + include/abg-ir.h | 7 + src/abg-comparison.cc | 86 +- src/abg-corpus.cc | 4 +- src/abg-default-reporter.cc | 12 +- src/abg-ir.cc | 205 +- src/abg-reporter-priv.cc | 3 +- tests/data/Makefile.am | 6 + .../test-anonymous-enums-change-report-v0.txt | 16 + .../test-anonymous-enums-change-report-v1.txt | 21 + .../test-anonymous-enums-change-v0.c | 36 + .../test-anonymous-enums-change-v0.o | Bin 0 -> 3296 bytes .../test-anonymous-enums-change-v1.c | 41 + .../test-anonymous-enums-change-v1.o | Bin 0 -> 3336 bytes tests/data/test-annotate/libtest23.so.abi | 224 +- .../test-anonymous-members-0.o.abi | 22 +- .../data/test-annotate/test15-pr18892.so.abi | 8 +- ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 54 +- ...19-pr19023-libtcmalloc_and_profiler.so.abi | 10 +- ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 2 +- .../test43-PR22913-report-0.txt | 4 +- .../test-read-dwarf/PR22122-libftdc.so.abi | 12416 ++++++++-------- tests/data/test-read-dwarf/libtest23.so.abi | 216 +- .../test-read-dwarf/test-libandroid.so.abi | 44 +- .../test-read-dwarf/test16-pr18904.so.abi | 1816 +-- ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 40 +- .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 60 +- tests/test-abidiff-exit.cc | 32 + 28 files changed, 7881 insertions(+), 7531 deletions(-) create mode 100644 tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v0.txt create mode 100644 tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v1.txt create mode 100644 tests/data/test-abidiff-exit/test-anonymous-enums-change-v0.c create mode 100644 tests/data/test-abidiff-exit/test-anonymous-enums-change-v0.o create mode 100644 tests/data/test-abidiff-exit/test-anonymous-enums-change-v1.c create mode 100644 tests/data/test-abidiff-exit/test-anonymous-enums-change-v1.o