bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make 3.81 May Incorrectly Regard Object Dependencies as Complete


From: Grant Erickson
Subject: Re: Make 3.81 May Incorrectly Regard Object Dependencies as Complete
Date: Tue, 19 Feb 2008 08:42:01 -0800
User-agent: Microsoft-Entourage/11.4.0.080122

On 2/18/08 10:12 PM, Grant Erickson wrote:
> I have been establishing a build environment and infrastructure for a project
> I am working on.
> 
> In the course of doing so, I have found some inexplicable behavior in make
> 3.81 when compiling and generating archive libraries in a pristine build tree.
> The issue manifests itself on both Mac OS X / Darwin on i686 and Ubuntu
> Desktop 7.10 on i686.
> 
> The behavior is that make creates the necessary object, depend and results
> directories based on order-only prerequisites in my implicit rules, correctly
> compiles the first source file into an object for the archive library, but
> then regards all other objects as complete and then tries to archive the
> library with non-existent and un-built objects:
>
> [ ... ]
>
> I think I've chased down every common make mistake I can think of, including
> empty rules, duplicate rules, environment variables, undefined variables, etc.
> 
> Sample archive/directory under test available on request.
> 
> Regards,
> 
> Grant Erickson

I have further simplified the test make file that demonstrates this behavior
and have removed the thunks which previously made it dependent upon 3.81,
allowing it to work with 3.80 or earlier.

It works successfully under 3.80 but fails under 3.81:

3.81
====

% /usr/gnu/bin/make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin8.11.1

% /usr/gnu/bin/make -r -R clobber
rm -f .depends/a.d .depends/b.d .depends/c.d .depends/d.d .depends/e.d
.depends/f.d .depends/g.d .depends/h.d
rm -f .objects/a.o .objects/b.o .objects/c.o .objects/d.o .objects/e.o
.objects/f.o .objects/g.o .objects/h.o
rm -f .results/libalphabet.a
rm -rf .objects/
rm -rf .depends/
rm -rf .results/

% /usr/gnu/bin/make -r -R
mkdir -p .depends
mkdir -p .objects
gcc -g -O1 -MD -MP -MF .depends/a.d -c -o .objects/a.o a.c
mkdir -p .results
ar -cr .results/libalphabet.a .objects/a.o .objects/b.o .objects/c.o
.objects/d.o .objects/e.o .objects/f.o .objects/g.o .objects/h.o
ar: .objects/b.o: No such file or directory
ar: .objects/c.o: No such file or directory
ar: .objects/d.o: No such file or directory
ar: .objects/e.o: No such file or directory
ar: .objects/f.o: No such file or directory
ar: .objects/g.o: No such file or directory
ar: .objects/h.o: No such file or directory
make: *** [.results/libalphabet.a] Error 1

3.80
====

% /usr/bin/make --version
GNU Make 3.80
Copyright (C) 2002  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

% /usr/bin/make -r -R clobber
rm -f .depends/a.d .depends/b.d .depends/c.d .depends/d.d .depends/e.d
.depends/f.d .depends/g.d .depends/h.d
rm -f .objects/a.o .objects/b.o .objects/c.o .objects/d.o .objects/e.o
.objects/f.o .objects/g.o .objects/h.o
rm -f .results/libalphabet.a
rm -rf .objects/
rm -rf .depends/
rm -rf .results/

% /usr/bin/make -r -R
mkdir -p .depends
mkdir -p .objects
gcc -g -O1 -MD -MP -MF .depends/a.d -c -o .objects/a.o a.c
gcc -g -O1 -MD -MP -MF .depends/b.d -c -o .objects/b.o b.c
gcc -g -O1 -MD -MP -MF .depends/c.d -c -o .objects/c.o c.c
gcc -g -O1 -MD -MP -MF .depends/d.d -c -o .objects/d.o d.c
gcc -g -O1 -MD -MP -MF .depends/e.d -c -o .objects/e.o e.c
gcc -g -O1 -MD -MP -MF .depends/f.d -c -o .objects/f.o f.c
gcc -g -O1 -MD -MP -MF .depends/g.d -c -o .objects/g.o g.c
gcc -g -O1 -MD -MP -MF .depends/h.d -c -o .objects/h.o h.c
mkdir -p .results
ar -cr .results/libalphabet.a .objects/a.o .objects/b.o .objects/c.o
.objects/d.o .objects/e.o .objects/f.o .objects/g.o .objects/h.o
ranlib .results/libalphabet.a

Test Makefile
=============

.SUFFIXES:
.SUFFIXES: .a .d .c .o

DependDirectory            = .depends/
ObjectDirectory            = .objects/
ResultDirectory            = .results/

ChangeFileExtension        = $(addsuffix $(1),$(basename $(2)))

GenerateDependName        = $(call ChangeFileExtension,.d,$(1))
GenerateDependPath        = $(addprefix $(DependDirectory),$(call
GenerateDependName,$(1)))

GenerateObjectName        = $(call ChangeFileExtension,.o,$(1))
GenerateObjectPath        = $(addprefix $(ObjectDirectory),$(call
GenerateObjectName,$(1)))

GenerateArchivePath        = $(addprefix $(ResultDirectory),lib$(1).a)

alphabet_SOURCES        = a.c b.c c.c d.c e.c f.c g.c h.c
alphabet_DEPENDS        = $(call GenerateDependPath,$(alphabet_SOURCES))
alphabet_OBJECTS        = $(call GenerateObjectPath,$(alphabet_SOURCES))
alphabet_RESULTS        = $(call GenerateArchivePath,alphabet)

DependPaths            = $(alphabet_DEPENDS)
ObjectPaths            = $(alphabet_OBJECTS)
ResultPaths            = $(alphabet_RESULTS)

$(ObjectDirectory)%.o: %.c | $(DependDirectory) $(ObjectDirectory)
    gcc -g -O1 -MD -MP -MF $(DependDirectory)$*.d -c -o $@ $<

.PHONY: alphabet
alphabet: $(alphabet_RESULTS)

$(alphabet_RESULTS): $(alphabet_OBJECTS)
    ar -cr $@ $?
    ranlib $@

$(DependDirectory) $(ObjectDirectory) $(ResultDirectory):
    mkdir -p $@

$(DependPaths): | $(DependDirectory)

$(ObjectPaths): | $(ObjectDirectory)

$(ResultPaths): | $(ResultDirectory)

.PHONY: clean
clean:
    rm -f $(DependPaths)
    rm -f $(ObjectPaths)
    rm -f $(ResultPaths)

.PHONY: clobber
clobber: clean
    rm -rf $(ObjectDirectory)
    rm -rf $(DependDirectory)
    rm -rf $(ResultDirectory)

ifdef DependPaths
VerifiedDependencies := $(foreach depend,$(DependPaths),$(wildcard
$(depend)))
ifdef VerifiedDependencies
ifeq ($(filter clean clobber,$(MAKECMDGOALS)),)
include $(VerifiedDependencies)
endif
endif # VerifiedDependencies
endif # DependPaths

Regards,

Grant






reply via email to

[Prev in Thread] Current Thread [Next in Thread]