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 3683E3858404 for ; Sat, 11 May 2024 09:42:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3683E3858404 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 3683E3858404 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=1715420558; cv=none; b=MenYrx1d6E5PWjm/jqxIvlF2OMG3R5Ohllty1vOQf8gvn+5uljNG4z38FST8R/rEDlh0ho/cGnYnkz9Q/c7t8zS4hCyZrlFW4JIB8KLtxw4OwvEYqE3WqcG9x/afG7DMQLDMS8uBVAuxqkMTkutb9TiA0mFkIp14QIPW6BDRm+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715420558; c=relaxed/simple; bh=BWNGvCF828XMl9MCp+fKL9PGeeznitJREGeN8KUOnSc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=M1xdgNTaNidCAtZI274J6Y7b/wIK+yLn/1SaIU89bpvJfrRlWx9bOmWZ7bIQGD1PIZM30KrS5tae2mdm9ZhxPFKhlVQL859cU8AXcShsWip9QKVfjKxqpsI+NR4K22a2SypQTuf8/znXtGEtNcJJNWH8R90LE4SQTGHjHNjGl4o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715420555; 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=UduXnMkYiG71sSPqvbB5FZphwwKtQ3EIseOtOX4EdEM=; b=UZIvuV24NFSK5NZTsRLLOwH4AaUnvT2t2HU6uqZJc6kt/sYt/7aDsMwQHdKR6nM7dtIePr H61f1rvj7TMqFHyFfvXCgrDzGqIYD+2iUo36trLkeqIYgi2en+iw1k/yXgUuTqd7bck2qK 3PBUPhAtwLJaByZ7hGQPth3ikc2MZPY= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-Zbwd1mbcNcqIRw_Pcl6F8w-1; Sat, 11 May 2024 05:37:34 -0400 X-MC-Unique: Zbwd1mbcNcqIRw_Pcl6F8w-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-51faceb0569so2134401e87.0 for ; Sat, 11 May 2024 02:37:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715420251; x=1716025051; 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=UduXnMkYiG71sSPqvbB5FZphwwKtQ3EIseOtOX4EdEM=; b=IsxaWs217KRM74MPYELQQ1HHGzZm3MS+9HIoRmEn/GYJ3wSmWz7ZCiEA6WhxZ8fXTf AOZX+XXCWm4mwkc6jqigFm+Sw/iWd51iub0EMzgMZX3KgOk+6BFiJVbko04Tznw6uD4+ +8Yz/n6t/aIuA2h7zYM27KKZyvh7AmjvH8hnOdxsWgkz5z/R6le7+LLqraOrJKrB5r+y x65okh5tU2K9ud7g71DvUvAkdAOrfSN6bWQTonHtTqbZou+NCW7NZRn/bkuONCXRcGFa p6jvQJ0iM0KfgP01bOAsTdrjV7p82fR3f0K0hIW9ehoFtqtCPe4y2+UIoDxkFMl8CUmC Xc6w== X-Gm-Message-State: AOJu0Yy6J9EfL72f+LmBprN05ANKgfJT4BadY2dEfzrT7pbmo9vse4HP sqSSLj99u0AFMv+AWFyyBH3AegduHem9073gVDbkWR4yL1DlE9a2FDSM2V42qVr+v6LfaZM2GbK iUa71CCsj3G43GNtkJHcxuxa6FJlecS4MFaK9x4dXiec9WMQB1CPFsFJ1XSiHIF9yxzTjC0DZB6 K8TNPVljvMQoIGtgjg9xtitD9fWFR5RRgbTOH1InOwGqU= X-Received: by 2002:a05:6512:1105:b0:51c:dc6:a1cf with SMTP id 2adb3069b0e04-5220fc734ecmr3352903e87.34.1715420251415; Sat, 11 May 2024 02:37:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYrcDUmDyVKRLRR02sw3ucE7fhvWHvzARIQvahPw1mTJ/+X3u1CWt+6xu/W921Plk9nwwWjQ== X-Received: by 2002:a05:6512:1105:b0:51c:dc6:a1cf with SMTP id 2adb3069b0e04-5220fc734ecmr3352873e87.34.1715420250796; Sat, 11 May 2024 02:37:30 -0700 (PDT) Received: from localhost (92.40.185.101.threembb.co.uk. [92.40.185.101]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41f9ffe26acsm80206865e9.1.2024.05.11.02.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 02:37:30 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/4] gdb/doc: fix parallel build of pdf and dvi files Date: Sat, 11 May 2024 10:37:12 +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=-8.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,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 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. --- 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 98cd488a737..f6e8a387172 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 @@ -24601,6 +24602,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 c05e561edeb..5836d6ce024 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@ @@ -481,21 +483,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 @@ -596,41 +603,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) @@ -665,6 +680,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