From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 0775E385DC1D for ; Fri, 15 Mar 2024 08:50:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0775E385DC1D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0775E385DC1D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710492625; cv=none; b=ArGsT6oLQAqmHSk9CnBBXb9qPcPiLCoSXt2ZnYvcgvRpXxONs8wq+Ftj3NdPbc9Cw77/M9or7eMjYxtedvCA76wta6jjL2cTlxfmisSq+9EqpACHIUytoK8rHifYJOCVXtEJv4gOHqwXmNxVhAcFmviRMIQLdjpYQTm2/DtM1nE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710492625; c=relaxed/simple; bh=q4f9XQ/+0qR2h/+BjwHlrYJ9ihdGoC0KpBFwd9TxwTE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=tMI1oAh3V8mo4M6AEFhn8ISCdl6HqTZl/oucDXrttLAFmxAY2dFBPPka65ypkzKYueDV5DZ14d7lyDqvB47oj7KhnOf7o+l22R58RKq2mupyRYpUYilQgfpfFFIA1+JEgf3NltbZwULybXJV/VIS31nlx/SqPczVgEifnQo9GO4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5654f700705so2746793a12.1 for ; Fri, 15 Mar 2024 01:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710492618; x=1711097418; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BYuVeqjcpkTUkcT5nrgwNREUHYE2eKXadPT4YLXCc9Q=; b=WVcGFucuvFYkeiDFaQLIB97CUPOWDOr0zu78s3I8I7C/qu5CuEP/4+iKoZuPrGPlww x0mOaozhphzq5MnJr79dTbpH3dlHjf7goI9hpccWIU2JfIrGnvqWyeNT/AmDlDf21QMf or6uGEMkxh/dIB7t5PblEteb0Bll8RjqOM50xIPyCWJm8IyNFBYjjhGQB+1uy/drrU6p 8p73jSfg7cyXue8q/LpJX3rnLLoKX3kGiT/RxTVQY0cBuV14Vd82qS/qCrS4dYz93WRK +mpb1MXPUTfEcWgVaR8igTKQR5dkvWFNRljdxMzqpldO7WqjXURnnPwsu6Ris+EeG1sD tLbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710492618; x=1711097418; h=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=BYuVeqjcpkTUkcT5nrgwNREUHYE2eKXadPT4YLXCc9Q=; b=bjvommG+JfDOAiPMymMvHrPyJGfRQYJ9E0nH9QdCkSQdmBIGu0W+7poKEkP8aiKFRD jhotQxmv7ojvXJJwWggi3sd0QY2GZxQr3BCsC326JzrJn45/DxAAw9xDWKAcni3QS7lO isASCBB70otUlxs5iqbV1tpImh3yn//sFTnTOLUvBc/k0hEZlN4+K5DY2BJ6MgZMIJrq YTYkbk5MLYYeIfX7MAxtBo0xLztLJwFoYm8LbAHVbxeD2ulWJQyU40rUpaCs9Ydm6Hgv UMgbg5bmIclcLtr6rMS6XOneXJI+g0eBhincPzPlB9ZjMt4DCH8m6PNpRs8UIHTWEEQH PgTg== X-Forwarded-Encrypted: i=1; AJvYcCWPNTlzM0Tw9b46W9WssbFKeBwMcoFnskwfbDLfh/amd0Qtdewuvj0hT5yMK/RlfYTSb5iNYsb+i214H3XgVx8= X-Gm-Message-State: AOJu0YwqI9HKlV4E8XBlDqHIEOb7q7t2NPL0w8HUUYbdp7S/baR4amb1 HjxASbvXFfX/OtAiiHLNRdGVdBxJXcW3il3WQt2eX6cqw+smQwTFTh5ZnjhkAIzxJrqxrdxHxeB ZN3r3sSZTgkSl+ntB0iR1BFiLWe0K0UXAX6Y+HQ== X-Google-Smtp-Source: AGHT+IElfCe77CRVHJtPwVKPTQuoG8xyAv5zxcKTZ8Mk3Z704Ld38PG1BdA8uBTzqMhH0o7WANJPWPy/9riP7rd0l0I= X-Received: by 2002:a05:6402:5285:b0:568:32b8:b2ae with SMTP id en5-20020a056402528500b0056832b8b2aemr2903425edb.1.1710492618452; Fri, 15 Mar 2024 01:50:18 -0700 (PDT) MIME-Version: 1.0 References: <20240313080237.1143034-1-christophe.lyon@linaro.org> <1eb529f2-3842-4090-a8e2-f713a28f2394@simark.ca> In-Reply-To: <1eb529f2-3842-4090-a8e2-f713a28f2394@simark.ca> From: Christophe Lyon Date: Fri, 15 Mar 2024 09:50:07 +0100 Message-ID: Subject: Re: [RFC] add regenerate Makefile target To: Simon Marchi Cc: binutils@sourceware.org, gdb@sourceware.org, gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: 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-mode > > 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 at > > -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 make > > 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 script > 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 the > 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 source > 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 > > 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. Not sure how to find volunteers? Christophe > > Simon