From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id C2DC73858D28 for ; Fri, 15 Mar 2024 14:13:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2DC73858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gwmail.gwu.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gwmail.gwu.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C2DC73858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710511996; cv=none; b=AyC6AQp3lUBKf3arhOCWaxWwE3W6TvF7I8bav9V2aChva84sciNF9CkGClgiwaepJa6tB78CgUEBdgvHw4wSVSteM9FA+Je2agVvA/qMPzCt8bafsTsRsqvaunuZ0rVlnG6YlACFeqnm64fWR6UN7ntkG251CwiYsuaRtfSaOb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710511996; c=relaxed/simple; bh=dQVV30Pk3l+r5WKQrKbNXFdBIPGIBuCn8eZxUBXEHSM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=XRpoFPV1K7Fmr4uqiqv4c6s3xlbkncsi/VISLRnBsp0B+YWCWF0eHCA7Lst4xQZHOfp/a9mqZ353foFrLIA/HfjaGtQf7Wo3HYiONACCHigm+LFcGMH8k+8GKjopSs9pH7kV3MnnF95O20hBvlHbpNCh8iUS57NgzVPg4MNfXXQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6e5d1e95481so876787a34.0 for ; Fri, 15 Mar 2024 07:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gwmail.gwu.edu; s=google; t=1710511994; x=1711116794; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LJwsp+ST9nGtoPziifW8xDopyfpRwpSOvhBXuPX5ac0=; b=DTpOjI0OAoCmaIrG28G2m1ytxksqKRqvirYWmwwmAwhxN8/eVBDqwwNS22MzQxqZy+ FO8YfDyBxbupl8kgCuHJ69rV9LhqqVqS9EjvReGaMpsTZFjmzOhWZ6nplx+YIhKkAk6U 5qYh9MVRwcbkHJi3PY5hO9nAehMg7tVgylQNSImM/eLC0MnAa5rVF7qMipXU4+jBaJSO YVqz25p+APUnvpAbaCHOrtRIPXg6XUsToxm/d7FCQJKAXYXJXmPSIo4Hl1yO61Mfd8AD VdDueOVrKNKU+t1s8oZWqmwJ7OcXPcz5+yF+JbeTzjJg4dvlrpGWsMxEkDgaI3lLVuqJ L8nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710511994; x=1711116794; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LJwsp+ST9nGtoPziifW8xDopyfpRwpSOvhBXuPX5ac0=; b=ajbRYiqyN80TYGOE5GjbWT9djZzMK0mRLsU9PK0QFVYVtAwV8t9s0kmv1nJ47Fh9JL cjqIfx3cZk5BOOZHH5Cz9dmvmL/QjJ+AH5AUZkSVecD7YqgDtaCslraN7BQ/LbsQ+tQO Hq1YP/S6q8hpsbgVxcqggFWUpOPxjGm7efUb8LaKFdA0wU+j7tMseFfwmQG7l+MyllXt 9ehYMGLgKMcEGMGek+vBS3rgb6am0QDhIcQx2ssRXw2co5ZYDMcDiss0OP6ik2GhgEOf yXGN9SQh1QKN0pBunvXKNlzxHR+IR97UO4oxIiip1V+ghkP12TyVbHRVoKifwJKOWpGF WGYg== X-Forwarded-Encrypted: i=1; AJvYcCUBgHqr5Mt7XCM6Dt/WtJEMIw7fwHy4kolJ/ZGwUEiMWGF0WoJJ/QjnIKI6YwGK6O7s3Vw0Z4d+IPjvS7RkSOx+KSw= X-Gm-Message-State: AOJu0YwTCrj6oyTbY63Lyy++hNdwOJXtT/D9lAITl1fcPBjTMD9Pa5qj EqG42L9DVyBzh9EJotROcKevA3K7GjX+zCBtIObK6unj3reV9+BybmFdQsoloaMn6BG469KNGAc w05hzQUWy+P3C34ga9+cV9NAhEm5JCbkNHlfi X-Google-Smtp-Source: AGHT+IGPf+JL7Ywwul7JNhGxGhHd2+0fagNKdaBUpMywleDoxgi27Phd2z5c+VDFPX1r2oonPdfwFTQaPCoCXONO2Vo= X-Received: by 2002:a05:6808:23c6:b0:3c2:5c1a:d721 with SMTP id bq6-20020a05680823c600b003c25c1ad721mr5986911oib.17.1710511993822; Fri, 15 Mar 2024 07:13:13 -0700 (PDT) MIME-Version: 1.0 References: <20240313080237.1143034-1-christophe.lyon@linaro.org> <1eb529f2-3842-4090-a8e2-f713a28f2394@simark.ca> In-Reply-To: From: Eric Gallager Date: Fri, 15 Mar 2024 10:13:02 -0400 Message-ID: Subject: Re: [RFC] add regenerate Makefile target To: Christophe Lyon Cc: Simon Marchi , binutils@sourceware.org, gdb@sourceware.org, gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Mar 15, 2024 at 4:53=E2=80=AFAM Christophe Lyon via Gcc wrote: > > On Thu, 14 Mar 2024 at 19:10, Simon Marchi wrote: > > > > > > > > On 2024-03-13 04:02, Christophe Lyon via Gdb wrote: > > > Hi! > > > > > > After recent discussions on IRC and on the lists about maintainer-mod= e > > > and various problems with auto-generated source files, I've written > > > this small prototype. > > > > > > Based on those discussions, I assumed that people generally want to > > > update autotools files using a script similar to autoregen.py, which > > > takes care of running aclocal, autoheader, automake and autoconf as > > > appropriate. > > > > > > What is currently missing is a "simple" way of regenerating other > > > files, which happens normally with --enable-maintainer-mode (which is > > > reportedly broken). This patch as a "regenerate" Makefile target > > > which can be called to update those files, provided > > > --enable-maintainer-mode is used. > > > > > > I tried this approach with the following workflow for binutils/gdb: > > > - run autoregen.py in srcdir > > > - cd builddir > > > - configure --enable-maintainer-mode > > > - make all-bfd all-libiberty regenerate -j1 > > > - for gdb: make all -C gdb/data-directory -j1 > > > - make all -jXXX > > > > > > Making 'all' in bfd and libiberty is needed by some XXX-gen host > > > programs in opcodes. > > > > > > The advantage (for instance for CI) is that we can regenerate files a= t > > > -j1, thus avoiding the existing race conditions, and build the rest > > > with -j XXX. > > > > > > Among drawbacks: > > > - most sub-components use Makefile.am, but gdb does not: this may mak= e > > > maintenance more complex (different rules for different projects) > > > - maintaining such ad-hoc "regenerate" rules would require special > > > attention from maintainers/reviewers > > > - dependency on -all-bfd and all-libiberty is probably not fully > > > intuitive, but should not be a problem if the "regenerate" rules > > > are used after a full build for instance > > > > > > Of course Makefile.def/Makefile.tpl would need further cleanup as I > > > didn't try to take gcc into account is this patch. > > > > > > Thoughts? > > > > My first thought it: why is it a Makefile target, instead of some scrip= t > > on the side (like autoregen.sh). It would be nice / useful to be > > able to it without configuring / building anything. For instance, the > > autoregen buildbot job could run it without configuring anything. > > Ideally, the buildbot wouldn't maintain its own autoregen.py file on th= e > > side, it would just use whatever is in the repo. > > Firstly because of what you mention later: some regeneration steps > require building host tools first, like the XXX-gen in opcodes. > > Since the existing Makefiles already contain the rules to autoregen > all these files, it seemed natural to me to reuse them, to avoid > reinventing the wheel with the risk of introducing new bugs. > > This involves changes in places where I've never looked at before, so > I'd rather reuse as much existing support as possible. > > For instance, there are the generators in opcodes/, but also things in > sim/, bfd/, updates to the docs and potfiles. In gcc, there's also > something "unusual" in fixincludes/ and libgfortran/ > > In fact, I considered also including 'configure', 'Makefile.in', > etc... in the 'regenerate' target, it does not seem natural to me to > invoke a script on the side, where you have to replicate the behaviour > of existing Makefiles, possibly getting out-of-sync when someone > forgets to update either Makefile or autoregen.py. What is currently > missing is a way to easily regenerate files without having to run a > full 'make all' (which currently takes care of calling autoconf & > friends to update configure/Makefile.in). > > But yeah, having to configure before being able to regenerate files is > a bit awkward too :-) > > > > > > Looking at the rule to re-generate copying.c in gdb for instance: > > > > # Make copying.c from COPYING > > $(srcdir)/copying.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/../COPYING3 $= (srcdir)/copying.awk > > awk -f $(srcdir)/copying.awk \ > > < $(srcdir)/../COPYING3 > $(srcdir)/copying.tmp > > mv $(srcdir)/copying.tmp $(srcdir)/copying.c > > > > There is nothing in this code that requires having configured the sourc= e > > tree. This code could for instance be moved to some > > generate-copying-c.sh script. generate-copying-c.sh could be called by > > an hypothetical autoregen.sh script, as well as the copying.c Makefile > > target, if we want to continue supporting the maintainer mode. > Wouldn't it be more obscure than now? Currently such build rules are > all in the relevant Makefile. You'd have to open several scripts to > discover what's involved with updating copying.c > Yeah I agree that it's good to keep all build rules in the Makefile; if there's a possibility of something changing, things that depend upon it need to know, and the best way to express those dependencies is in the Makefile. > > > > Much like your regenerate targets, an autoregen.sh script in a given > > directory would be responsible to re-generate all the files in this > > directory that are generated and checked in git. It would also be > > responsible to call any autoregen.sh file in subdirectories. > Makefiles already have all that in place :-) > Except if you consider that you'd want to ignore timestamps and always > regenerate things? > > > > There's just the issue of files that are generated using tools that are > > compiled. When experimenting with maintainer mode the other day, I > > stumbled on the opcodes/i386-gen, for instance. I don't have a good > > solution to that, except to rewrite these tools in a scripting language > > like Python. > > So for opcodes, it currently means rewriting such programs for i386, > aarch64, ia64 and luckily msp430/rl78/rx share the same opc2c > generator. Also there are the files generated by cgen, too, which no one seems to know how to regenerate, either. And then in bfd there's that chew program in the doc subdir. And then in the binutils subdirectory proper there's that sysinfo tool for generating sysroff.[ch]. > Not sure how to find volunteers? > > Christophe > > > > > Simon