On Sun, Jan 12, 2025 at 04:16:58PM +0100, Arsen Arsenović wrote:
> Regstrapped on x86_64-pc-linux-gnu.  I've also checked the generated
> dependency files are correct by hand and "instrumented" the build to
> fail if two dependency files are the same, by doing the following:
> 
>   DPOSTCOMPILE = ! test -f $(DEPFILE).Po && mv ...
> 
> ... and confirmed no further conflicts of this sort happen.
> 
> OK for trunk?
> ---------- >8 ----------
> Currently, the dependency files for root-file.o and common-file.o were
> both d/.deps/file.Po, which would cause parallel builds to fail
> sometimes with:
> 
>   make[3]: Leaving directory 
> '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
>   make[3]: Entering directory 
> '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
>   mv: cannot stat 'd/.deps/file.TPo': No such file or directory
>   make[3]: *** 
> [/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/gcc-14-20240511/gcc/d/Make-lang.in:421:
>  d/root-file.o] Error 1 shuffle=131581365
> 
> Also, this means that dependencies of one of root-file or common-file
> are missing when developing.  After this patch, those two files get
> assigned dependency files d/.deps/d-root-file.o.Po and
> d/.deps/d-common-file.o.Po respectively.
> 
> There are other files with similar conflicts (mangle-package.o,
> visitor-package.o for instance).

Note, I ran into the same problem in
https://kojipkgs.fedoraproject.org//work/tasks/6545/127766545/build.log
> 
> gcc/d/ChangeLog:
> 
>       * Make-lang.in: Assign dependency-tracking files better
>       filenames.
> ---
>  gcc/d/Make-lang.in | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
> index f28761e4b370..25e2b0bbfe94 100644
> --- a/gcc/d/Make-lang.in
> +++ b/gcc/d/Make-lang.in
> @@ -65,8 +65,9 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC 
> $(CHECKING_DFLAGS) \
>       $(WARN_DFLAGS)
>  
>  DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
> -DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
> -DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
> +DEPFILE = $(subst /,-,$@)

Why do you need there the directory or suffix?
$(*F) is clearly bad, because there are rules like
d/%.o: d/dmd/%.d
        $(DCOMPILE) $(D_INCLUDES) $<
        $(DPOSTCOMPILE)
        
d/common-%.o: d/dmd/common/%.d
        $(DCOMPILE) $(D_INCLUDES) $<
        $(DPOSTCOMPILE)
etc. and while the stem in the first case is the basename of the filename
part, in the second case it is the basename of the filename part in the
common directory.
I think
DEPFILE = $(basename $(@F))
would be sufficient.
So the former d/.deps/file.Po which handled both d/dmd/common/file.d and
d/dmd/root/file.d in your case would be d/.deps/d-common-file.o.d and
d/.deps/d-root-file.o.d while with the above DEPFILE it would be
d/.deps/common-file.d and d/.deps/root-file.d
There are no d/dmd/*-*.d files and among d/*-*.cc the only are just d-
prefixed ones, and there are no clashes between the *.cc and *.d filenames:
for i in gcc/d/*.cc; do j=`basename $i .cc`; find gcc/d -name $j.d; done

So just (or if you want a helper variable, perhaps it should standa for the
whole $(@D)/$(DEPDIR)/$(basename $(@F)) part?

2025-01-13  Arsen Arsenović  <ar...@aarsen.me>
            Jakub Jelinek  <ja...@redhat.com>

        * Make-lang.in (DCOMPILE, DPOSTCOMPILE): Use $(basename $(@F))
        instead of $(*F).

--- gcc/d/Make-lang.in.jj       2025-01-13 09:12:07.408983471 +0100
+++ gcc/d/Make-lang.in  2025-01-13 10:57:16.398315375 +0100
@@ -65,8 +65,8 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -f
        $(WARN_DFLAGS)
 
 DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
-DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
-DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
+DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(basename 
$(@F)).TPo
+DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).TPo 
$(@D)/$(DEPDIR)/$(basename $(@F)).Po
 DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
 
 # Like LINKER, but use a mutex for serializing front end links.

        Jakub

Reply via email to