From patchwork Tue Apr 2 07:39:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1918667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SOpdfDKW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V80CP0sdKz1yYw for ; Tue, 2 Apr 2024 18:40:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BACB3858424 for ; Tue, 2 Apr 2024 07:39:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D46CE3858D28 for ; Tue, 2 Apr 2024 07:39:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D46CE3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D46CE3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712043576; cv=none; b=E6wtMQfyD7salM8Qg4kFkxp2k4X7GHIkr9KQqubmxFFjtyl5m1ZUtmU5wa8VlYF0Dg8CMEtmJ3qiYjE3M+s4xrox2F/ExFE59TUfrHUhflhdRMQ1Fidq/Fe+MVhTrBYY+lHufXvdv88c/fioV/x9hgDBbBralkJ9ori9yVyIfmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712043576; c=relaxed/simple; bh=puFWrpDTuRM2rLA0JPnFD9E23t2j5uoS8HsMfh0pw5Y=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=KNmB/jXNUK2hjakbX1rqlrtd5zAO+fqCJRhcM6uhO3f8Zc69crNzvZ5hzrxqmI0sTJdg0TtfTJL/cYCkyZKFy+FH5T5+NACju4Bl7Vq6Op6L5qC5a0rSXWRCV62LxxY18u/hxF98BbqduoWfG+6noog1jo2KbR3vZG0/IdS3y/4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712043573; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=jKJ4YX97dkCcdQc1BXIZI4128Zwn6iglpvvYUOjXST8=; b=SOpdfDKW/N9cTjXc/o7N/wRLvU2hwtVUS3Cm3RXwzcaYK5vXbn4N8nkWEthBNwMSUmpfel YwTXzdnWydZXrhL4nrtigo9Cwv0CDS9zOScu1MbUv041C10Up6or/HIpms/QkyPPftgCdC IlC1I+fWEvoXHlioUwXG/JnbmLwbQ1A= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-6TQ7s36fOcOt6Vh_nk_40A-1; Tue, 02 Apr 2024 03:39:32 -0400 X-MC-Unique: 6TQ7s36fOcOt6Vh_nk_40A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E2AB29AB3FC; Tue, 2 Apr 2024 07:39:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B4143C21; Tue, 2 Apr 2024 07:39:30 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 4327d96F3168698 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 2 Apr 2024 09:39:09 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4327d8qx3168697; Tue, 2 Apr 2024 09:39:08 +0200 Date: Tue, 2 Apr 2024 09:39:08 +0200 From: Jakub Jelinek To: Paolo Bonzini , Nathanael Nerode , Alexandre Oliva , Ralf Wildenhues , Ian Lance Taylor , Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org, =?utf-8?b?0JTQuNC70Y/QvSDQn9Cw0LvQsNGD0LfQvtCy?= Subject: [PATCH] Fix up postboot dependencies [PR106472] Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_MANYTO, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org On Wed, Mar 13, 2024 at 10:13:37AM +0100, Jakub Jelinek wrote: > While the first Makefile.tpl hunk looks obviously ok, the others look > completely wrong to me. > There is nothing special about libgo vs. libbacktrace/libatomic > compared to any other target library which is not bootstrapped vs. any > of its dependencies which are in the bootstrapped set. > So, Makefile.tpl shouldn't hardcode such dependencies. Here is my version of the fix. The dependencies in the toplevel Makefile simply didn't take into account that some target modules could be in a bootstrapped build built in some configurations as bootstrap modules (typically as dependencies of other target bootstrap modules), while in other configurations just as dependencies of non-bootstrap target modules and so not built during the bootstrap, but after it. Makefile.tpl arranges for those postboot target module -> target module dependencies to be emitted only inside of an @unless gcc-bootstrap block, while for @if gcc-bootstrap it just emits configure-target-whatever: stage_last dependencies which ensure those postbootstrap target modules are only built after everything that is bootstrapped has been. Now, the libbacktrace/libatomic target modules have bootstrap=true target_modules = { module= libbacktrace; bootstrap=true; }; target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; }; because those modules are dependencies of libphobos target module, so when d is included among bootstrapped languages, those are all bootstrapped and everything works correctly. While if d is not included, libphobos target module is disabled, libbacktrace/libatomic target modules aren't bootstrapped, nothing during bootstrap needs them, but post bootstrap libgo target module depends on the libatomic and libbacktrace target modules, libgfortran target module depends on the libbacktrace target module and libgm2 target module depends on the libatomic target module, but those dependencies were emitted only @unless gcc-bootstrap. There is a similar theoretical problem for zlib target module if GCJ would be ressurected, libphobos as bootstrap target module depends on the zlib target module, but if d is not configured, fastjar also depends on it. The following patch arranges for the @if gcc-bootstrap case to emit also target module -> target module dependencies, but conditionally on the on dependency not being bootstrapped. In the generated Makefile.in you can see what the Makefile.tpl change produces and that it just adds extra dependencies which weren't there before in the @if gcc-bootstrap case. I've bootstrapped without this patch with ../configure --enable-languages=c,c++,go; make on x86_64-linux (note, make -j2 or higher usually worked) which failed as described in the PR, then with this patch with the same command which built fine and the Makefile difference between the two builds being Jakub diff -up obj40{a,b}/Makefile --- obj40a/Makefile 2024-03-31 00:35:22.243791499 +0100 +++ obj40b/Makefile 2024-03-31 22:40:38.143299144 +0200 @@ -29376,6 +29376,14 @@ configure-bison: stage_last configure-flex: stage_last configure-m4: stage_last +configure-target-fastjar: maybe-configure-target-zlib +all-target-fastjar: maybe-all-target-zlib +all-target-libgo: maybe-all-target-libbacktrace +all-target-libgo: maybe-all-target-libatomic +all-target-libgm2: maybe-all-target-libatomic +configure-target-libgfortran: maybe-all-target-libbacktrace +configure-target-libgo: maybe-all-target-libbacktrace + # Dependencies for target modules on other target modules are # described by lang_env_dependencies; the defaults apply to anything which I believe are exactly the extra dependencies we want. Plus I've done normal x86_64-linux and i686-linux bootstraps/regtests which in my case include --enable-languages=default,ada,obj-c++,lto,go,d,rust,m2 for x86_64 and the same except ada for i686; those with my usual make -j32. The Makefile difference in those builds vs. unpatched case is just an extra empty line. Ok for trunk? 2024-04-02 Jakub Jelinek PR bootstrap/106472 * Makefile.tpl (make-postboot-target-dep): New lambda. Use it to add --enable-bootstrap dependencies of target modules on other target modules if the latter aren't bootstrapped. * Makefile.in: Regenerate. --- Makefile.tpl.jj 2024-01-09 22:40:16.812824317 +0100 +++ Makefile.tpl 2024-03-30 14:23:51.985398859 +0100 @@ -2013,6 +2013,25 @@ configure-target-[+module+]: maybe-all-g (unless (=* target "target-") (string-append "configure-" target ": " dep "\n")))))) + ;; Dependencies in between target modules if the dependencies + ;; are bootstrap target modules and the target modules which + ;; depend on them are emitted inside of @unless gcc-bootstrap. + ;; Unfortunately, some target modules like libatomic or libbacktrace + ;; have bootstrap flag set, but whether they are actually built + ;; during bootstrap or after bootstrap depends on e.g. enabled languages; + ;; if d is enabled, libphobos is built as target module and depends + ;; on libatomic and libbacktrace, which are therefore also built as + ;; bootstrap modules. If d is not enabled but go is, libatomic and + ;; libbacktrace are just dependencies of libgo which is not a bootstrap + ;; target module, but we need dependencies on libatomic and libbacktrace + ;; in that case even when gcc-bootstrap. This lambda emits those. + (define make-postboot-target-dep (lambda () + (let ((target (dep-module "module")) (on (dep-module "on"))) + (when (=* on "target-") + (when (=* target "target-") + (string-append "@unless " on "-bootstrap\n" (make-dep "" "") + "\n@endunless " on "-bootstrap\n")))))) + ;; We now build the hash table that is used by dep-kind. (define boot-modules (make-hash-table 113)) (define postboot-targets (make-hash-table 113)) @@ -2045,6 +2064,11 @@ configure-target-[+module+]: maybe-all-g [+ == "postbootstrap" +][+ (make-postboot-dep) +][+ ESAC +][+ ENDFOR dependencies +]@endif gcc-bootstrap +@if gcc-bootstrap +[+ FOR dependencies +][+ CASE (dep-kind) +] +[+ == "postbootstrap" +][+ (make-postboot-target-dep) +][+ ESAC +][+ +ENDFOR dependencies +]@endif gcc-bootstrap + @unless gcc-bootstrap [+ FOR dependencies +][+ CASE (dep-kind) +] [+ == "postbootstrap" +][+ (make-dep "" "") +] --- Makefile.in.jj 2024-01-16 22:51:10.233410651 +0100 +++ Makefile.in 2024-03-29 15:50:34.676632723 +0100 @@ -68677,6 +68677,39 @@ configure-flex: stage_last configure-m4: stage_last @endif gcc-bootstrap +@if gcc-bootstrap +@unless target-zlib-bootstrap +configure-target-fastjar: maybe-configure-target-zlib +@endunless target-zlib-bootstrap +@unless target-zlib-bootstrap +all-target-fastjar: maybe-all-target-zlib +@endunless target-zlib-bootstrap +@unless target-libstdc++-v3-bootstrap +configure-target-libgo: maybe-all-target-libstdc++-v3 +@endunless target-libstdc++-v3-bootstrap +@unless target-libbacktrace-bootstrap +all-target-libgo: maybe-all-target-libbacktrace +@endunless target-libbacktrace-bootstrap +@unless target-libatomic-bootstrap +all-target-libgo: maybe-all-target-libatomic +@endunless target-libatomic-bootstrap +@unless target-libstdc++-v3-bootstrap +configure-target-libgm2: maybe-all-target-libstdc++-v3 +@endunless target-libstdc++-v3-bootstrap +@unless target-libatomic-bootstrap +all-target-libgm2: maybe-all-target-libatomic +@endunless target-libatomic-bootstrap +@unless target-libstdc++-v3-bootstrap +configure-target-libgrust: maybe-all-target-libstdc++-v3 +@endunless target-libstdc++-v3-bootstrap +@unless target-libbacktrace-bootstrap +configure-target-libgfortran: maybe-all-target-libbacktrace +@endunless target-libbacktrace-bootstrap +@unless target-libbacktrace-bootstrap +configure-target-libgo: maybe-all-target-libbacktrace +@endunless target-libbacktrace-bootstrap +@endif gcc-bootstrap + @unless gcc-bootstrap all-gnattools: maybe-all-target-libstdc++-v3 configure-libcc1: maybe-configure-gcc