From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 EFC9D385E83A for ; Fri, 31 May 2024 08:18:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFC9D385E83A 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 EFC9D385E83A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717143552; cv=none; b=oXiWOU9vXXxJinBvv5dBelNyT2qLcJJQ5dGo+VxMUB/uABU0Jdfk085riFDEFcGQcwLDOz4xRkW2p6HJ/SOR1HN2zLzT1nClfH/7tMmbciCS4jaSsdAIQR66gteNMHAhQZ+t3aGrUeUCFYar+SBrbeyT4b/S5YYAqzygyDXEc8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717143552; c=relaxed/simple; bh=UE/drsvn5s8eJF3gV6M3ixhrVg6ymEwVa3h8nD5Mfq4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=eI4QVo70ke/Y/SvOXzFIK9mCFNFpO+AckIddwyrBUOdSXkYSashDfKPOHw6FkCvQDGL4sA8BVOedVIZDW8r29y+LlhJ/cO6mMoeIGxX7ndeKv5yau2e2CaKxI82YvEswSz7vft++22wfHlp3FBaiYMuCF7sns1zXPG5WFllCMk8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717143539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oPKTJzSNgnhA1sv6ovabdgPEb6gSAUUREo+dtgVQrs0=; b=Kt/NjW/oJvwBAyo1y2SiaVP/QyF+vjgp2yaaeTSd4ZCDy8Hks4gnoyOFMCksUMKs3JBz+Q 2IEz9MLK9tfAQLwK37hRnTQHR0U9nIU1MLWoPl6jUwf0OV7eF/XaWKXwL7Mk74MYg+sPWt nv7usJcAFFtJKcFnel/kdhzJm/mx3Ws= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-a-NJ1ZYHOuuOF-uL8tOM5g-1; Fri, 31 May 2024 04:18:57 -0400 X-MC-Unique: a-NJ1ZYHOuuOF-uL8tOM5g-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4212e3418b1so2877005e9.0 for ; Fri, 31 May 2024 01:18:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717143536; x=1717748336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oPKTJzSNgnhA1sv6ovabdgPEb6gSAUUREo+dtgVQrs0=; b=qB+p5ECn1p9Pp1uPXeeC9miWYbGSHO+9AYsK+A9D8NhkoNTRp+lv0rcG2LrJWExvVh 9yUVa/xYK584UHSSoIgsy+kOw/ySvMmkEPNfSmY969lGOparPqFDCf6jSdqmri1vwYbW 5NuIbVeaPbUnq7DPEqLruYYbQX732OGTfOCLU9KHV19S5nRjiY2csRxIhTB43V8wDUEo ClFLfqrbJjkD4tmTlWQD1p+oUX1HG8eHl80KhNZ+JFQGOtltsfdTYxrNqmDNXCEIqRra OJuo9PwgpgQAG2ympqtLHDEVr3EaR0GlCrkMId0ixDOSNrz+t5hk4cgspyo46K9M/Nw6 TqJQ== X-Gm-Message-State: AOJu0YxGCYwxIGA+SKOzY1iNUsNDHDn1Oym9q59VO/CQBPTe5y92scQT lFJA+H5q1OjV3Gbw9F2G6149AN5H2vWJFKqkz+/6cj1OtI0uhA97KlwaFDkLi8XaUNEaAB2ILr3 7f2Twuq3Umc2R0otLjWTPZKWCwOKkFf3/LplAFOZbRs3Tqk9MRsY8lKfsjJJmsNNZUGUw88Y66u Ie6qWD5GpPiILqXgzPVy78hD9wqj5BuGN/KCPXl5+Ccz0= X-Received: by 2002:a05:600c:1d27:b0:421:29b4:5337 with SMTP id 5b1f17b1804b1-4212dff7773mr11441135e9.0.1717143535930; Fri, 31 May 2024 01:18:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ4wmeRd5cDKputkJC0CsyN1h24FXPVQ0WTFpT+JTzDdkeXyoa6yHgYOYyde0ZHY0jIWc8LA== X-Received: by 2002:a05:600c:1d27:b0:421:29b4:5337 with SMTP id 5b1f17b1804b1-4212dff7773mr11440935e9.0.1717143535408; Fri, 31 May 2024 01:18:55 -0700 (PDT) Received: from localhost ([2a00:23c7:c696:e701:85a5:8a0c:1403:2dc]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b8a5598sm17277975e9.38.2024.05.31.01.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 01:18:54 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Tom Tromey Subject: [PATCHv2 5/5] gdb/doc: fix parallel build of pdf and dvi files Date: Fri, 31 May 2024 09:18:42 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.1 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_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When building with 'make -j20 -C gdb/doc all-doc' I often see problems caused from trying to build some dvi files in parallel with some pdf files. The problem files are: gdb.dvi and gdb.pdf; stabs.dvi and stabs.pdf; and annotate.dvi and annotate.pdf. The problem is that building these files create temporary files in the local directory. There's already a race here that two make threads might try to create these files at the same time. But it gets worse, to avoid issues where a failed build could leave these temporary files in a corrupted state, and so prevent the next build from succeeding, the recipe for each of these files delete all the temporary files first, this obviously causes problems if some other thread has already started the build and is relying on these temporary files. To work around this problem I propose we start using the --build flag for texi2dvi (which is the same tool used to create the pdf files). The --build flag allows for the temporary files to be placed into a sub-directory, e.g. creating gdb.pdf will create the temporary files in gdb.t2d/pdf/ and gdb.dvi uses gdb.t2d/dvi/, in this way the temporary files will never clash, and we can easily delete the specific sub-directory at the start of the recipe to ensure a successful build. Very old versions of texi2dvi don't support --build, so I've added a configure check for this option. If the option is not supported then we don't use it. This means we fall back to placing temporary files in the local directory, which means parallel builds will remain broken. The --build option is definitely present in texi2dvi version 6.1, from 2016, so any version after that should be fine. For me, with this fix in place, I can now run 'make -j20 -C gdb/doc all-doc' without seeing any build problems. Approved-By: Tom Tromey --- gdb/configure | 33 +++++++++++++++++++++++++++++++-- gdb/configure.ac | 21 +++++++++++++++++++++ gdb/doc/Makefile.in | 42 +++++++++++++++++++++++++++++------------- 3 files changed, 81 insertions(+), 15 deletions(-) diff --git a/gdb/configure b/gdb/configure index 66a7ad8d256..8d870d50de3 100755 --- a/gdb/configure +++ b/gdb/configure @@ -765,6 +765,7 @@ ENABLE_BFD_64_BIT_TRUE subdirs GDB_DATADIR DEBUGDIR +TEXI2DVI_EXTRA_FLAGS MAKEINFO_EXTRA_FLAGS MAKEINFOFLAGS MAKEINFO @@ -11499,7 +11500,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11502 "configure" +#line 11503 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11605,7 +11606,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11608 "configure" +#line 11609 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -24609,6 +24610,34 @@ if test x"$gdb_cv_have_makeinfo_click" = xyes; then fi +## Figure out if texi2dvi supports the --build option. Older versions +## didn't. If this option is not supported then parallel building in +## the docs/ directory is probably going to be broken. But single +## threaded build should be fine. +TEXI2DVI=texi2dvi +TEXI2DVI_EXTRA_FLAGS="" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $TEXI2DVI supports --build" >&5 +$as_echo_n "checking whether $TEXI2DVI supports --build... " >&6; } +if ${gdb_cv_have_texi2dvi_build_opt+:} false; then : + $as_echo_n "(cached) " >&6 +else + echo '\input texinfo' >conftest.texi + echo 'abc' >>conftest.texi + echo '@bye' >>conftest.texi + cp conftest.texi /home/andrew/tmp/ + if eval "$TEXI2DVI --build=tidy conftest.texi >&5 2>&5"; then + gdb_cv_have_texi2dvi_build_opt=yes + else + gdb_cv_have_texi2dvi_build_opt=no + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_texi2dvi_build_opt" >&5 +$as_echo "$gdb_cv_have_texi2dvi_build_opt" >&6; } +if test x"$gdb_cv_have_texi2dvi_build_opt" = xyes; then + TEXI2DVI_EXTRA_FLAGS="$TEXI2DVI_EXTRA_FLAGS --build=tidy" +fi + + # Check whether --with-separate-debug-dir was given. diff --git a/gdb/configure.ac b/gdb/configure.ac index 62ff09cea20..3b726e5f0aa 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -117,6 +117,27 @@ if test x"$gdb_cv_have_makeinfo_click" = xyes; then fi AC_SUBST(MAKEINFO_EXTRA_FLAGS) +## Figure out if texi2dvi supports the --build option. Older versions +## didn't. If this option is not supported then parallel building in +## the docs/ directory is probably going to be broken. But single +## threaded build should be fine. +TEXI2DVI=texi2dvi +TEXI2DVI_EXTRA_FLAGS="" +AC_CACHE_CHECK([whether $TEXI2DVI supports --build], gdb_cv_have_texi2dvi_build_opt, + [echo '\input texinfo' >conftest.texi + echo 'abc' >>conftest.texi + echo '@bye' >>conftest.texi + cp conftest.texi /home/andrew/tmp/ + if eval "$TEXI2DVI --build=tidy conftest.texi >&5 2>&5"; then + gdb_cv_have_texi2dvi_build_opt=yes + else + gdb_cv_have_texi2dvi_build_opt=no + fi]) +if test x"$gdb_cv_have_texi2dvi_build_opt" = xyes; then + TEXI2DVI_EXTRA_FLAGS="$TEXI2DVI_EXTRA_FLAGS --build=tidy" +fi +AC_SUBST(TEXI2DVI_EXTRA_FLAGS) + GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir, [look for global separate debug info in this path @<:@LIBDIR/debug@:>@], [${libdir}/debug]) diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in index 3d64526f542..cdb046bd90f 100644 --- a/gdb/doc/Makefile.in +++ b/gdb/doc/Makefile.in @@ -68,6 +68,8 @@ TEXI2ROFF=texi2roff # where to find texi2dvi, ditto TEXI2DVI=texi2dvi +TEXI2DVI_EXTRA_FLAGS=@TEXI2DVI_EXTRA_FLAGS@ +TEXI2DVI_CMD = $(TEXI2DVI) $(TEXI2DVI_EXTRA_FLAGS) # Package to install the docs under PACKAGE = @PACKAGE@ @@ -492,21 +494,26 @@ gdb-cfg.texi: ${srcdir}/${DOC_CONFIG}-cfg.texi # Clean these up before each run. Avoids a catch 22 with not being # able to re-generate these files (to fix a corruption) because these # files contain a corruption. +# +# If TEXI2DVI_CMD includes the --build option then these files should +# not be created in the current directory, but attempting to delete +# them is harmless. GDB_TEX_TMPS = gdb.aux gdb.cp* gdb.fn* gdb.ky* gdb.log gdb.pg* gdb.toc \ gdb.tp* gdb.vr* # GDB MANUAL: TeX dvi file gdb.dvi: ${GDB_DOC_FILES} - $(SILENCE) rm -f $(GDB_TEX_TMPS) - $(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) $(READLINE_TEXI_INCFLAG) \ - -I ${GDBMI_DIR} -I $(srcdir) $(srcdir)/gdb.texinfo + $(SILENCE) rm -fr $(GDB_TEX_TMPS) gdb.t2d/dvi/ + $(ECHO_TEXI2DVI) $(TEXI2DVI_CMD) $(SILENT_Q_FLAG) \ + $(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \ + $(srcdir)/gdb.texinfo gdb.ps: gdb.dvi $(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $? gdb.pdf: ${GDB_DOC_FILES} - $(SILENCE) rm -f $(GDB_TEX_TMPS) - $(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf \ + $(SILENCE) rm -fr $(GDB_TEX_TMPS) gdb.t2d/pdf/ + $(ECHO_TEXI2DVI) $(TEXI2DVI_CMD) $(SILENT_Q_FLAG) --pdf \ $(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \ $(srcdir)/gdb.texinfo @@ -607,41 +614,49 @@ stabs/index.html: $(STABS_DOC_FILES) # Clean these up before each run. Avoids a catch 22 with not being # able to re-generate these files (to fix a corruption) because these # files contain a corruption. +# +# If TEXI2DVI_CMD includes the --build option then these files should +# not be created in the current directory, but attempting to delete +# them is harmless. STABS_TEX_TMPS = stabs.aux stabs.cp* stabs.fn* stabs.ky* \ stabs.log stabs.pg* stabs.toc stabs.tp* stabs.vr* # STABS DOCUMENTATION: TeX dvi file stabs.dvi : $(STABS_DOC_FILES) - $(SILENCE) rm -f $(STABS_TEX_TMPS) - $(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) -I $(srcdir) \ + $(SILENCE) rm -fr $(STABS_TEX_TMPS) stabs.t2d/dvi/ + $(ECHO_TEXI2DVI) $(TEXI2DVI_CMD) $(SILENT_Q_FLAG) -I $(srcdir) \ $(srcdir)/stabs.texinfo stabs.ps: stabs.dvi $(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $? stabs.pdf: $(STABS_DOC_FILES) - $(SILENCE) rm -f $(STABS_TEX_TMPS) - $(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf -I $(srcdir) \ + $(SILENCE) rm -fr $(STABS_TEX_TMPS) stabs.t2d/pdf/ + $(ECHO_TEXI2DVI) $(TEXI2DVI_CMD) $(SILENT_Q_FLAG) --pdf -I $(srcdir) \ $(srcdir)/stabs.texinfo # Clean these up before each run. Avoids a catch 22 with not being # able to re-generate these files (to fix a corruption) because these # files contain a corruption. +# +# If TEXI2DVI_CMD includes the --build option then these files should +# not be created in the current directory, but attempting to delete +# them is harmless. ANNOTATE_TEX_TMPS = annotate.aux annotate.cp* annotate.fn* annotate.ky* \ annotate.log annotate.pg* annotate.toc annotate.tp* annotate.vr* # ANNOTATE DOCUMENTATION: TeX dvi file annotate.dvi : $(ANNOTATE_DOC_FILES) - $(SILENCE) rm -f $(ANNOTATE_TEX_TMPS) - $(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) -I $(srcdir) \ + $(SILENCE) rm -fr $(ANNOTATE_TEX_TMPS) annotate.t2d/dvi/ + $(ECHO_TEXI2DVI) $(TEXI2DVI_CMD) $(SILENT_Q_FLAG) -I $(srcdir) \ $(srcdir)/annotate.texinfo annotate.ps: annotate.dvi $(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $? annotate.pdf: $(ANNOTATE_DOC_FILES) - $(SILENCE) rm -f $(ANNOTATE_TEX_TMPS) - $(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf -I $(srcdir) \ + $(SILENCE) rm -fr $(ANNOTATE_TEX_TMPS) annotate.t2d/pdf/ + $(ECHO_TEXI2DVI) $(TEXI2DVI_CMD) $(SILENT_Q_FLAG) --pdf -I $(srcdir) \ $(srcdir)/annotate.texinfo annotate.info: $(ANNOTATE_DOC_FILES) @@ -689,6 +704,7 @@ Makefile: Makefile.in $(host_makefile_frag) ../config.status mostlyclean: rm -f gdb.mm gdb.ms gdb.me links2roff + rm -fr annotate.t2d/ stabs.t2d/ gdb.t2d/ rm -f $(GDB_TEX_TMPS) rm -f $(STABS_TEX_TMPS) rm -f $(ANNOTATE_TEX_TMPS) -- 2.25.4