From patchwork Sat Sep 28 16:46:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1168859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509774-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hT1GRa77"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="X3R4u5ii"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46gZLl5xTxz9sNF for ; Sun, 29 Sep 2019 02:46:37 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=VGM+EssQsK4H8FgZ lG5czeM3Pu/GrzyoELblIknH8rjkgSnmYmppTWuUBbwOnxgrQobMp2fpTkcJwWek xhQthuHU5Y4gUuEWOkKVMhebagBnwdLYrOFtwJUHA2QXnaEWd77F2dz5uVkT8fn8 3ac7+ejohCZzxfNX2PFfE5GuVY8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=o56bHdSGDSo3c1CpeSZs2h 9rDmw=; b=hT1GRa77pDTlhExtzCtdmw/OA09DubJGhApX1soGKQ0YgwD56C4AmP Zzh4vkjuVwmsoWxXgCcCUyjNqY8JbD4iwRAsqcVtYLgf1jbbIkhTZlmC6AKd6Y6D LVoSr4shB/JmPKwmfKLA75Y6FiLn/cuH1ll/2zpr1vMW+wVUl3xJs= Received: (qmail 4291 invoked by alias); 28 Sep 2019 16:46:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4247 invoked by uid 89); 28 Sep 2019 16:46:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=recipe, arrangement, consequently, simultaneous X-HELO: esa6.hgst.iphmx.com Received: from esa6.hgst.iphmx.com (HELO esa6.hgst.iphmx.com) (216.71.154.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Sep 2019 16:46:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1569689176; x=1601225176; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=bSxWD3Kn0OqhIIIbZwtwSfFNd/qlBzCDqDqplEnQeiY=; b=X3R4u5iiwJ5otOY8rQ+jGVHdcMc6sNqyUmIfrcjZAapg4SBp2+pNRUTz +0dHzS+X7EnoKvi5oUzjxaCWSY8bUupca7E0IcIO6DkhGkkRaCeW5ay3U ESTkSeTnDA4xQDTikX+9IDoF6hi0Y0h5TrdxHC8vE3IEcpUEHnrLe7Eyr rkfzR43j61sASMOmpCRDInqaj+26eAl2/2tsu5ixm4CLJ7TC+V0AZ6boy 4NsypjUF86FMHYEuD2gh3kAO0toT2nd5xQ0pahhPq2RgdOOphkoRvazai tnDJ4jOfJ2dN5rxOhjjQ5n2mjvt48GO2myfP6UR9HDfHbW0W6rcuZV9a7 w==; IronPort-SDR: ERwznjCD4fyahMe8QzsFPQ3bf/fK+D1XkCCOGXBFLydyZjbd0qiGxjtGElti9Vf2WPgogMGlPQ OckcojWfJ+7xdrX31NhOtmWPUCeMudQfgYwRWakOVeXJMITEuqKaj8v5oBAjawDl8z36timKxi WTZlzl1ygNp6JPETxAPwGg3ch3JPPzNsxzWfKNH4B8pRZg0gbRqcfAWnt5QlYIwGVsPT/djOPf jEEJGTJn/Wzg665FJA69YNrKjYacCVtvf3rCP7GfXk3Ndi2vvpwfKdERQuaU4IGpyzlP2Q8J+k VCk= Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 29 Sep 2019 00:46:14 +0800 IronPort-SDR: eCGXHdbcdSjpKWytxqyV5h/yqqnxI16fIXNtU4lw5X3h7yZ6xLUpvuPyIHAplOH2PgNj8iwRWm Wch+Zm9jUU0re31B56R4i+y25QHTolh696D122mpZsUdQdaNcPlKyeBKQe/OXjetV3WrJRUEuB GdP7CrX90gyD/qRWK58TwKG/OIZXf3mu6mmJQj4xP4gddXQlVA97j1L/1C7+URZ1w2cbIXA2lJ kzBdwQ8258zEK61pDKaVTEuoOUDo8J4Yc03wiiPjrHfVgXVDiu1hH9R7BIZyS3wOb2VTGwSwE/ +aFfBP0kW0hLdttSRC2Cn31e Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2019 09:42:26 -0700 IronPort-SDR: fYnY26J9pPTnwbcqh+vfQPnPPhA5fhHLU/QRzl49m0DOyJX96hl5M0RkdLYsO3UkhL6dBDFDZF sWihCFJ6O1tB4o3UM8BGcLSJzQmVqwywFk4zgzyokkK2uuLDDbIwYXo5CeHC3bV5UztW3DQcap RA+k/k3Rw2efzY+jNp+fxIfkcpXeZPD9rb4NIOxXvwru9j1iksAh73/yZGpwECvKnSKDvzKbZK 6l0ttDz/8lShrRfH4qWoZcsyZ+ldJkuneQ01q23a3PDjZZ8NW8HqiJsQVkGy86xrEgteRfGwjf 8Mg= WDCIronportException: Internal Received: from unknown (HELO redsun52) ([10.149.66.28]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2019 09:46:13 -0700 Date: Sat, 28 Sep 2019 17:46:08 +0100 (BST) From: "Maciej W. Rozycki" To: Arnaud Charlet cc: gcc-patches@gcc.gnu.org Subject: [PATCH v2 1/2] libada: Remove racy duplicate gnatlib installation In-Reply-To: <20190927071552.GA5648@adacore.com> Message-ID: References: <20190926074255.GA12138@adacore.com> <20190927071552.GA5648@adacore.com> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 For some reason, presumably historical, the `install-gnatlib' target for the default multilib is invoked twice, once via the `ada.install-common' target in `gcc/ada/gcc-interface/Make-lang.in' invoked from gcc/ and again via the `install-libada' target in libada/. Apart from doing the same twice this is actually harmful in sufficiently parallelized `make' invocation, as the removal of old files performed within the `install-gnatlib' recipe in the former case actually races with the installation of new files done in the latter case, causing the recipe to fail and abort, however non-fatally, having not completed the installation of all the built files needed for the newly-built compiler to work correctly. This can be observed with a native `x86_64-linux-gnu' bootstrap: make[4]: Entering directory '.../gcc/ada' rm -rf .../lib/gcc/x86_64-linux-gnu/10.0.0/adalib rm: cannot remove '.../lib/gcc/x86_64-linux-gnu/10.0.0/adalib': Directory not empty make[4]: *** [gcc-interface/Makefile:512: install-gnatlib] Error 1 make[4]: Leaving directory '.../gcc/ada' make[3]: *** [.../gcc/ada/gcc-interface/Make-lang.in:853: install-gnatlib] Error 2 make[2]: [.../gcc/ada/gcc-interface/Make-lang.in:829: ada.install-common] Error 2 (ignored) which then causes missing files to be reported when an attempt is made to use the newly-installed non-functional compiler to build a `riscv64-linux-gnu' cross-compiler: (cd ada/bldtools/sinfo; gnatmake -q xsinfo ; ./xsinfo sinfo.h ) error: "ada.ali" not found, "ada.ads" must be compiled error: "s-memory.ali" not found, "s-memory.adb" must be compiled gnatmake: *** bind failed. /bin/sh: ./xsinfo: No such file or directory make[2]: *** [.../gcc/ada/Make-generated.in:45: ada/sinfo.h] Error 127 make[2]: Leaving directory '.../gcc' make[1]: *** [Makefile:4369: all-gcc] Error 2 make[1]: Leaving directory '...' make: *** [Makefile:965: all] Error 2 Depending on timing `.../lib/gcc/x86_64-linux-gnu/10.0.0/adainclude' may cause an installation failure instead and the resulting compiler may be non-functional in a different way. Only invoke `install-gnatlib' from within gcc/ then if a legacy build process is being used with libada disabled and gnatlib built manually with `make -C gcc gnatlib'. gcc/ * Makefile.in (gnat_install_lib): New variable. * configure.ac: Substitute it. * configure: Regenerate. gcc/ada/ * gcc-interface/Make-lang.in (ada.install-common): Split into... (gnat-install-tools, gnat-install-lib): ... these. --- On Fri, 27 Sep 2019, Arnaud Charlet wrote: > > Hmm, I've experimented a bit and AFAICT if `--disable-libada' is given > > without my proposed change applied, then the gnatlib stuff doesn't get > > built in the first place let alone installed anyway. > > With --disable-libada you need to build gnatlib and gnattools explicitly via > e.g. > > make -C gcc gnatlib gnattools > > (after having done a "make" or "make bootstrap") > > and then you can use "make install" Ack. This seems to be of a very limited use, e.g. it does not support building shared libraries or multilibs, and it breaks in my build of a `riscv64-linux-gnu' cross-compiler because the `make -C gcc' invocation does not pass the `--sysroot=' option set in SYSROOT_CFLAGS_FOR_TARGET and consequently the newly-built compiler cannot find system headers needed to build gnatlib (also there is a missing ordering dependency beetween the `gnatlib' and `gnattools' targets, making the simultaneous invocation as given break in parallel `make', with a `You must first build the GNAT library: make gnatlib' message). I see no particular reason to break what has been working however, so here's my proposed rewritten change. With so many limitations and its mismatch with the current GCC build arrangement and practices I'd consider your manual build recipe a legacy one though and would rather not invest too much effort into supporting it. Insted I'd recommend everyone to switch to building via gnattools/ and libada/ top-level directories. NB one can alternatively use `make -C gcc install-gnatlib' to complement the manual build process. I have verified this change by running my combined build process where a native `x86_64-linux-gnu' configuration is built first and then used to build a `riscv64-linux-gnu' cross-compiler, both with `--disable-libada' specified, without and with this patch applied. I have added `make -C gcc gnatlib && make -C gcc gnattools' as an extra build step before `make install'. This has run up to failing to find `riscv64-linux-gnu' system headers in `make -C gcc gnatlib' as noted above, at which point the installation trees had both the same contents, including `x86_64-linux-gnu' gnatlib development files and static libraries as well as gnattools in particular. I have also verified, with the same build process and the extra `make -C gcc' invocations removed, that the usual configuration with libada enabled produces the same result as with v1 of this change. Maciej Changes from v1: - gnatlib installation now retained in gcc/ada/gcc-interface/Make-lang.in and instead invoked iff `--disable-libada' has been requested at the top level. --- gcc/Makefile.in | 4 ++++ gcc/ada/gcc-interface/Make-lang.in | 5 ++++- gcc/configure | 15 +++++++++++++-- gcc/configure.ac | 10 ++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) gcc-lang-no-install-gnatlib.diff Index: gcc/gcc/Makefile.in =================================================================== --- gcc.orig/gcc/Makefile.in +++ gcc/gcc/Makefile.in @@ -1705,6 +1705,10 @@ $(FULL_DRIVER_NAME): ./xgcc # language hooks, generated by configure @language_hooks@ +# Wire in install-gnatlib invocation with `make install' for a configuration +# with top-level libada disabled. +gnat_install_lib = @gnat_install_lib@ + # per-language makefile fragments ifneq ($(LANG_MAKEFRAGS),) include $(LANG_MAKEFRAGS) Index: gcc/gcc/ada/gcc-interface/Make-lang.in =================================================================== --- gcc.orig/gcc/ada/gcc-interface/Make-lang.in +++ gcc/gcc/ada/gcc-interface/Make-lang.in @@ -822,7 +822,9 @@ doc/gnat-style.pdf: ada/gnat-style.texi # gnatlink, gnatls, gnatmake, gnatname, gnatprep, gnatxref, gnatfind, # gnatclean). # gnatdll is only used on Windows. -ada.install-common: +ada.install-common: $(gnat_install_lib) gnat-install-tools + +gnat-install-tools: $(MKDIR) $(DESTDIR)$(bindir) -if [ -f gnat1$(exeext) ] ; \ then \ @@ -843,6 +845,7 @@ doc/gnat-style.pdf: ada/gnat-style.texi # # Finally, install the library # +gnat-install-lib: gnat-install-tools -if [ -f gnat1$(exeext) ] ; \ then \ $(MAKE) $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib; \ Index: gcc/gcc/configure =================================================================== --- gcc.orig/gcc/configure +++ gcc/gcc/configure @@ -814,6 +814,7 @@ SET_MAKE accel_dir_suffix real_target_noncanonical enable_as_accelerator +gnat_install_lib REPORT_BUGS_TEXI REPORT_BUGS_TO PKGVERSION @@ -7826,6 +7827,16 @@ else fi +# If top-level libada has been disabled, then wire in install-gnatlib +# invocation with `make install', so that one can build and install +# the library manually with `make -C gcc all gnatlib gnattools install'. +if test x"$enable_libada" = xno; then + gnat_install_lib=gnat-install-lib +else + gnat_install_lib= +fi + + if test x"$enable_as_accelerator_for" != x; then $as_echo "#define ACCEL_COMPILER 1" >>confdefs.h @@ -18819,7 +18830,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18822 "configure" +#line 18833 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18925,7 +18936,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18928 "configure" +#line 18939 "configure" #include "confdefs.h" #if HAVE_DLFCN_H Index: gcc/gcc/configure.ac =================================================================== --- gcc.orig/gcc/configure.ac +++ gcc/gcc/configure.ac @@ -982,6 +982,16 @@ AC_ARG_ENABLE(languages, esac], [enable_languages=c]) +# If top-level libada has been disabled, then wire in install-gnatlib +# invocation with `make install', so that one can build and install +# the library manually with `make -C gcc all gnatlib gnattools install'. +if test x"$enable_libada" = xno; then + gnat_install_lib=gnat-install-lib +else + gnat_install_lib= +fi +AC_SUBST(gnat_install_lib) + if test x"$enable_as_accelerator_for" != x; then AC_DEFINE(ACCEL_COMPILER, 1, [Define if this compiler should be built as the offload target compiler.])