From patchwork Thu Dec 3 13:26:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41284 Return-Path: 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 DC3CF3858023; Thu, 3 Dec 2020 13:26:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC3CF3858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607002000; bh=00nfZAmatxM1LEfgFAazsJ57eTWjt4dNcO+JBMYIVBg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=L9Y9qGyTCQPnNEH03wBqL6LEuEE1+yOt4AGzcYN0NQnYRaruGeVQPQG+nR8jpxeoa KsbxOWkCuQt4HU2MRgH38hiY5NpWpxcEV1jn/azDVGYAZgO5lexQSQkGKxNp6kywIG MfQ7xXbTFE6eDujjhNGdNWlqoYH2x12mRskLpVi8= 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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 11AE0385800D for ; Thu, 3 Dec 2020 13:26:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 11AE0385800D Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-vQ-rUzXmPQ-iQ4Ji3hNEvg-1; Thu, 03 Dec 2020 08:26:28 -0500 X-MC-Unique: vQ-rUzXmPQ-iQ4Ji3hNEvg-1 Received: by mail-wr1-f69.google.com with SMTP id z6so1195558wrl.7 for ; Thu, 03 Dec 2020 05:26:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=00nfZAmatxM1LEfgFAazsJ57eTWjt4dNcO+JBMYIVBg=; b=GCg34t9b0LWYjJmD1XNkLaKYFXvwrgsVu06UPu+FsghKpd21CphpIN+jQpphnfjo8X /iUxp3Y3EoFtMak7qeNzF+ZvVEOZGVk/ANFk9PkJsR8rhdWDd2Ipi4kUPgfEsTJWcAvs r2uo6dYX0PlP40NxxbrGhBfGP7YlFqanuZIy6Srb9pxhVXdp2ru4xyRw5iJkm7w2hPjz xTf2GvO0u1OYP8gtUIf9/PkzO5f5PBNuPRg9D4C6Bvjl+f8Lx3IWLpvFKpyONn5XGJxz 5tgYOAgRs88lY9N5hGyXiY3ee9eKtvaps+kRYR1js31E23BAP0qeStJZYuNi1CP4URoH Dw6A== X-Gm-Message-State: AOAM532VbC6dKTlYwoIlL289Slt+oyYaR3XYj5gW2LcAPSq+i2sAjnNo 7k/hrNDPeZlUeBQW3/0fMrJxikLcLyCm1CAe0Dfs040cdeSNlDLljPYcvPAR+BzFOt2/5NClHdn oQVkhEnHq8Cmu/aDnwXzuAr3fFepCbryTbdGRD6cE56kOQDyhuFcnNvSzbBLniQgaIGtu X-Received: by 2002:adf:f888:: with SMTP id u8mr1720624wrp.35.1607001986845; Thu, 03 Dec 2020 05:26:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2o9wrDNg8QjJwzwmyTaF8oTr9ZlupI4Rd7/aFZdAqwSzLZxDRVi0/eMT8CSE8XKM5QiLAKw== X-Received: by 2002:adf:f888:: with SMTP id u8mr1720589wrp.35.1607001986339; Thu, 03 Dec 2020 05:26:26 -0800 (PST) Received: from localhost (91-166-131-65.subs.proxad.net. [91.166.131.65]) by smtp.gmail.com with ESMTPSA id t184sm1636350wmt.13.2020.12.03.05.26.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2020 05:26:25 -0800 (PST) Received: by localhost (Postfix, from userid 1001) id 6FF611A2630; Thu, 3 Dec 2020 14:26:24 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH] Use C++11 for the code base Organization: Red Hat / France X-Operating-System: Red Hat Enterprise Linux Server 7.8 X-URL: http://www.redhat.com Date: Thu, 03 Dec 2020 14:26:24 +0100 Message-ID: <86ft4nowan.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Hello, As the Enterprise Linux 6 platform has now essentially reached its end of life for what it's worth (the Fedora EPEL6 distribution is not maintained anymore) nothing ties us to using C++03 only anymore. So, I think it makes sense to move the code base to the C++11 standard. Why C++11 and not, say, C++14 or more? Well, the more direct reason I see is that we need to support long life cycle platforms, the older one being Enterprise Linux 7 currently. This is the Fedora EPEL7 distribution, in concrete terms. And in that distribution, the compiler is GCC 4.8.x. And it supports C++11. In practise, nothing changes in the code that is already there. The new code however can use C++11 constructs just fine. I have updated the CONTRIBUTING file to write down some of the unwritten cultural biases of the current code base. Hopefully these few lines will help to shed some light on the choices made so far. The update to that file also enacts the use of C++11 and sets some limits to what we expects in terms of what the code base would look like. configure.ac is modified to unconditionally pass -std=c++11 to the compiler and express that in the configuration text displayed at the end of the configuration stage. Some Makefile.am files are updated accordingly. * CONTRIBUTING: Enact use of c++11. Also, we favor those who read/debug/maintain the code as opposed to those who write it ;-) * configure.ac: Switch to c++11 unconditionally. * src/Makefile.am: Adjust. * tests/Makefile.am: Adjust. Signed-off-by: Dodji Seketeli Applied to master. --- CONTRIBUTING | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 25 ++++++++++--------------- src/Makefile.am | 10 +++------- tests/Makefile.am | 15 ++++----------- 4 files changed, 72 insertions(+), 33 deletions(-) diff --git a/CONTRIBUTING b/CONTRIBUTING index b1f58df..7e3e856 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -96,6 +96,61 @@ So, to be complete the regression checking command to run against your patch should be: "make check-self-compare distcheck -j16", if you have a machine with a 16 threads processors, for instance. +Coding language and style +========================== + +The coding style is self evident when reading the source code. So +please, stick to and mimic what is already in there for the sake of +consistency at very least. Just for history, it's derived from the +style of the C++ standard library from the GNU project. + +As of libabigail 2.0, the language we use is C++ 11. The level +supported is the one supported by the GCC 4.8.x series of compilers. +This should be old and well tested enough to be supported by your +current favorite compiler. + +Initially, the code base of the project was written in C++03, with the +TR1 extensions. That heritage is well visible in the code base as it +is today. + +Please do not rush and send gazillions of patches that just re-write +tons of code into your favorite C++ 11 flavour du jour. We will +likely reject those patches. We want to keep the history of the code +base in such a way that tools like "git blame are still +useful. + +So we'll accept patches changing parts of the code base to more recent +C++ 11 constructs only if you happen to add functionality or fix +things in that area. If it makes "cultural common" sense to adopt +those constructs. What I mean by "cultural" is that must make sense +in relative to the culture of the project. And yes, that is +subjective. Sorry. + +As a generic rule, we tend to favor the lowest possible level of +abstraction that makes sense without requiring future maintainers of +the project to have a PhD in design patterns. We are not impressed by +design patterns. We use them where they make clear sense, but we +don't idolize them. Put it another way, we will always favor the one +who *READS* and debug the code over the one who writes it. To put +things in a hypothetical perspective, we'll rather accept a repetitive +code that stays simple to read and debug over a highly abstract one +using meta programming to save a few lines of repetitive code located +in a very small number of places. + +Really, in this project, we care about low level binary analysis +stuff. Issues in that area can be hard to reproduce and quite +challenging to debug. So having tons of abstraction layers in the +code base have proven to be a maintenance burden over the years, from +our experience in working on similar projects. So please help us +avoid those mistakes that we make just for the pleasure of writing +what can look as "pleasant code" at a first naive sight. + +That being said, we also love cleanly designed APIs that are fairly +re-usable and well documented. And we also praise abstraction and +modularisation that we recognize as being the most basic tools of any +engineer. So we like to think about ourselves as well rounded people +who care about maintaining things for a long time to come :-) + Launching regression tests in Valgrind -------------------------------------- diff --git a/configure.ac b/configure.ac index 2f15fd0..37b7882 100644 --- a/configure.ac +++ b/configure.ac @@ -85,12 +85,6 @@ AC_ARG_ENABLE(zip-archive, ENABLE_ZIP_ARCHIVE=no) -AC_ARG_ENABLE(cxx11, - AS_HELP_STRING([--enable-cxx11=yes|no], - [enable features that use the C++11 compiler]), - ENABLE_CXX11=$enableval, - ENABLE_CXX11=no) - AC_ARG_ENABLE(apidoc, AS_HELP_STRING([--enable-apidoc=yes|no|auto], [enable generation of the apidoc in html]), @@ -160,6 +154,11 @@ AC_LANG([C++]) AC_LANG_COMPILER_REQUIRE dnl +dnl We use C++11 +dnl +CXX_STANDARD=c++11 + +dnl dnl check if the c++ compiler has support __attribute__((visibility("hidden"))) dnl AC_MSG_NOTICE([checking for GCC visibility attribute support ...]) @@ -588,14 +587,6 @@ AM_CONDITIONAL(ENABLE_ZIP_ARCHIVE, test x$ENABLE_ZIP_ARCHIVE = xyes) DEPS_CPPFLAGS="$XML_CFLAGS $LIBZIP_CFLAGS" AC_SUBST(DEPS_CPPFLAGS) -dnl Handle conditional use of a C++11 compiler -if test x$ENABLE_CXX11 = xyes; then - CXXFLAGS="$CXXFLAGS -std=c++11" - AC_DEFINE([WITH_CXX11], 1, [Defined to 1 if a C++11 compiler is used]) -fi - -AM_CONDITIONAL(ENABLE_CXX11, test x$ENABLE_CXX11 = xyes) - dnl Check for the presence of doxygen program if test x$ENABLE_APIDOC != xno; then @@ -673,6 +664,9 @@ if test x$ENABLE_UBSAN = xyes; then CXXFLAGS="$CXXFLAGS -fsanitize=undefined" fi +dnl Set the level of C++ standard we use. +CXXFLAGS="$CXXFLAGS -std=$CXX_STANDARD" + dnl Check if several decls and constant are defined in dependant dnl libraries HAS_EM_AARCH64=no @@ -949,11 +943,12 @@ AC_MSG_NOTICE([ C Compiler : ${CC} C++ Compiler : ${CXX} GCC visibility attribute supported : ${SUPPORTS_GCC_VISIBILITY_ATTRIBUTE} + CXXFLAGS : ${CXXFLAGS} Python : ${PYTHON} OPTIONAL FEATURES: Enable zip archives : ${ENABLE_ZIP_ARCHIVE} - Use a C++-11 compiler : ${ENABLE_CXX11} + C++ standard level : ${CXX_STANDARD} libdw has the dwarf_getalt function : ${FOUND_DWARF_GETALT_IN_LIBDW} Enable rpm support in abipkgdiff : ${ENABLE_RPM} Enable rpm 4.15 support in abipkgdiff tests : ${ENABLE_RPM415} diff --git a/src/Makefile.am b/src/Makefile.am index d7990e3..26fc4d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,13 +4,9 @@ libabigaildir=$(libdir) AM_CXXFLAGS = $(VISIBILITY_FLAGS) -if ENABLE_CXX11 -CXX11_SOURCES = abg-viz-common.cc \ - abg-viz-dot.cc \ +VIZ_SOURCES = abg-viz-common.cc \ + abg-viz-dot.cc \ abg-viz-svg.cc -else -CXX11_SOURCES = -endif libabigail_la_SOURCES = \ abg-internal.h \ @@ -42,7 +38,7 @@ abg-tools-utils.cc \ abg-elf-helpers.h \ abg-elf-helpers.cc \ abg-regex.cc \ -$(CXX11_SOURCES) +$(VIZ_SOURCES) libabigail_la_LIBADD = $(DEPS_LIBS) libabigail_la_LDFLAGS = -lpthread -Wl,--as-needed -no-undefined diff --git a/tests/Makefile.am b/tests/Makefile.am index 6effbc2..655facb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,19 +3,11 @@ SUBDIRS = data ZIP_ARCHIVE_TESTS = if ENABLE_ZIP_ARCHIVE -ZIP_ARCHIVE_TESTS += runtestwritereadarchive -if ENABLE_CXX11 -ZIP_ARCHIVE_TESTS += runtestdot -endif +ZIP_ARCHIVE_TESTS += runtestwritereadarchive runtestdot endif AM_CXXFLAGS = $(VISIBILITY_FLAGS) -CXX11_TESTS = -if ENABLE_CXX11 -CXX11_TESTS += runtestsvg -endif - FEDABIPKGDIFF_TEST = if ENABLE_FEDABIPKGDIFF if ENABLE_RUNNING_TESTS_WITH_PY3 @@ -55,9 +47,10 @@ runtestlookupsyms \ runtestreadwrite \ runtestsymtab \ runtesttoolsutils \ +runtestsvg \ $(FEDABIPKGDIFF_TEST) \ -$(ZIP_ARCHIVE_TESTS) \ -$(CXX11_TESTS) +$(ZIP_ARCHIVE_TESTS) + if ENABLE_RUNNING_TESTS_WITH_PY3 TESTS += runtestdefaultsupprspy3.sh