Thread: BUG #2531: missing header dependency in src/port/Makefile

BUG #2531: missing header dependency in src/port/Makefile

From
"Alexander Dupuy"
Date:
The following bug has been logged online:

Bug reference:      2531
Logged by:          Alexander Dupuy
Email address:      alex.dupuy@mac.com
PostgreSQL version: 8.1.4
Operating system:   Fedora Core 5
Description:        missing header dependency in src/port/Makefile
Details:

While there is a dependency for path.o on the generated header file
pg_config_paths.h, there is no such dependency for the "server" compiled
version path_srv.o in the Makefile.  With parallel make features enabled,
this can result in an attempt to compile path_srv.o before the
pg_config_paths.h file has been fully generated.

Reproducing this is difficult, since it requires a machine that runs the
compiles faster than the echo commands, but as the make.log fragment below
indicates, it can happen.  First, a diff to fix the problem:

Index: Makefile
===================================================================
RCS file: /src/cvs/postgres/src/port/Makefile,v
retrieving revision 1.1.1.6
diff -u -w -r1.1.1.6 Makefile
--- Makefile    12 Jun 2006 16:23:17 -0000    1.1.1.6
+++ Makefile    14 Jul 2006 05:52:01 -0000
@@ -45,6 +45,7 @@
     $(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<

 path.o: path.c pg_config_paths.h
+path_srv.o: path.c pg_config_paths.h

 #
 # Server versions of object files




make[4]: Entering directory `/src/postgres-8.1.4/postgres/src/port'
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o
copydir.o copydir.c
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o
dirmod.o dirmod.c
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o exec.o
exec.c
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o
noblock.o noblock.c
echo "#define PGBINDIR \"/usr/postgres/bin\"" >pg_config_paths.h
echo "#define PGSHAREDIR \"/usr/postgres/share\"" >>pg_config_paths.h
echo "#define SYSCONFDIR \"/usr/postgres/etc\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o pipe.o
pipe.c
echo "#define INCLUDEDIR \"/usr/postgres/include\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o
pgsleep.o pgsleep.c
echo "#define PKGINCLUDEDIR \"/usr/postgres/include\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o
pgstrcasecmp.o pgstrcasecmp.c
echo "#define INCLUDEDIRSERVER \"/usr/postgres/include/server\""
>>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c -o
sprompt.o sprompt.c
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE   -c thread.c
echo "#define LIBDIR \"/usr/postgres/lib\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c copydir.c -o
copydir_srv.o
echo "#define PKGLIBDIR \"/usr/postgres/lib\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c dirmod.c -o
dirmod_srv.o
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c exec.c -o
exec_srv.o
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c noblock.c -o
noblock_srv.o
echo "#define LOCALEDIR \"\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c path.c -o
path_srv.o
echo "#define DOCDIR \"/usr/postgres/doc\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c pipe.c -o
pipe_srv.o
path.c: In function ‘get_doc_path’:
path.c:599: error: ‘DOCDIR’ undeclared (first use in this function)
path.c:599: error: (Each undeclared identifier is reported only once
path.c:599: error: for each function it appears in.)
path.c: In function ‘get_man_path’:
path.c:608: error: ‘MANDIR’ undeclared (first use in this function)
echo "#define MANDIR \"/usr/postgres/man\"" >>pg_config_paths.h
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c pgsleep.c -o
pgsleep_srv.o
gcc -O3 -funroll-loops -falign-functions -march=i686 -pipe -g
--param large-function-insns=10000       -finline-limit=1200
-D_REENTRANT -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-I../../src/port  -I../../src/include -D_GNU_SOURCE  -c pgstrcasecmp.c -o
pgstrcasecmp_srv.o
make[4]: *** [path_srv.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory `/src/postgres-8.1.4/postgres/src/port'
make[3]: *** [all] Error 2

Re: BUG #2531: missing header dependency in src/port/Makefile

From
Tom Lane
Date:
"Alexander Dupuy" <alex.dupuy@mac.com> writes:
> While there is a dependency for path.o on the generated header file
> pg_config_paths.h, there is no such dependency for the "server" compiled
> version path_srv.o in the Makefile.  With parallel make features enabled,
> this can result in an attempt to compile path_srv.o before the
> pg_config_paths.h file has been fully generated.

Thanks for the report.  Patch applied back to 8.0.

            regards, tom lane