neon icon indicating copy to clipboard operation
neon copied to clipboard

`make` always recompiles the Neon extension

Open yeputons opened this issue 1 year ago • 2 comments

Steps to reproduce

  1. Build neon
  2. Run make neon-pg-ext

Expected result

There are no gcc commands in the input as no files has been changed.

Actual result

Compiling neon
make PG_CONFIG=/home/yeputons/neon/neon//tmp_install/bin/pg_config \
	-C /home/yeputons/neon/neon//pgxn/neon install
make[1]: Entering directory '/home/yeputons/neon/neon/pgxn/neon'
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o inmem_smgr.o inmem_smgr.c -MMD -MP -MF .deps/inmem_smgr.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o libpagestore.o libpagestore.c -MMD -MP -MF .deps/libpagestore.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o libpqwalproposer.o libpqwalproposer.c -MMD -MP -MF .deps/libpqwalproposer.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o pagestore_smgr.o pagestore_smgr.c -MMD -MP -MF .deps/pagestore_smgr.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o relsize_cache.o relsize_cache.c -MMD -MP -MF .deps/relsize_cache.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o neon.o neon.c -MMD -MP -MF .deps/neon.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o walproposer.o walproposer.c -MMD -MP -MF .deps/walproposer.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I/home/yeputons/neon/neon/tmp_install/include -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o walproposer_utils.o walproposer_utils.c -MMD -MP -MF .deps/walproposer_utils.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -shared -o neon.so  inmem_smgr.o libpagestore.o libpqwalproposer.o pagestore_smgr.o relsize_cache.o neon.o walproposer.o walproposer_utils.o -L/home/yeputons/neon/neon/tmp_install/lib -L/home/yeputons/neon/neon/tmp_install/lib -lpq   -Wl,--as-needed -Wl,-rpath,'/home/yeputons/neon/neon/tmp_install/lib',--enable-new-dtags  
/usr/bin/mkdir -p '/home/yeputons/neon/neon/tmp_install/lib/postgresql'
/usr/bin/mkdir -p '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension'
/usr/bin/mkdir -p '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension'
/usr/bin/install -c -m 755  neon.so '/home/yeputons/neon/neon/tmp_install/lib/postgresql/neon.so'
/usr/bin/install -c -m 644 .//neon.control '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension/'
/usr/bin/install -c -m 644 .//neon--1.0.sql  '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension/'
make[1]: Leaving directory '/home/yeputons/neon/neon/pgxn/neon'
Compiling neon_test_utils
make PG_CONFIG=/home/yeputons/neon/neon//tmp_install/bin/pg_config \
	-C /home/yeputons/neon/neon//pgxn/neon_test_utils install
make[1]: Entering directory '/home/yeputons/neon/neon/pgxn/neon_test_utils'
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -I. -I./ -I/home/yeputons/neon/neon/tmp_install/include/postgresql/server -I/home/yeputons/neon/neon/tmp_install/include/postgresql/internal  -D_GNU_SOURCE   -c -o neontest.o neontest.c -MMD -MP -MF .deps/neontest.Po
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O0 -g3  -fPIC -shared -o neon_test_utils.so  neontest.o -L/home/yeputons/neon/neon/tmp_install/lib    -Wl,--as-needed -Wl,-rpath,'/home/yeputons/neon/neon/tmp_install/lib',--enable-new-dtags  
/usr/bin/mkdir -p '/home/yeputons/neon/neon/tmp_install/lib/postgresql'
/usr/bin/mkdir -p '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension'
/usr/bin/mkdir -p '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension'
/usr/bin/install -c -m 755  neon_test_utils.so '/home/yeputons/neon/neon/tmp_install/lib/postgresql/neon_test_utils.so'
/usr/bin/install -c -m 644 .//neon_test_utils.control '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension/'
/usr/bin/install -c -m 644 .//neon_test_utils--1.0.sql  '/home/yeputons/neon/neon/tmp_install/share/postgresql/extension/'
make[1]: Leaving directory '/home/yeputons/neon/neon/pgxn/neon_test_utils'

Thoughts

Running make -d provides a reason: the neon-pg-ext depends on postgres which depends on postgres-headers which always does make install in the postgres repository. And that always overwrites header files in tmp_install/include/postgres, hence the extension's makefile has to recompile the extension.

Can we somehow alter make install's behavior to overwrite only if something has been changed? Perhaps add a --compare flag to /usr/bin/install's calls, if it does what I think it does?

That problem is new: we previously had all C code in separate repository, see #2307 . Not a big issue at the moment as our extension is small.

yeputons avatar Sep 01 '22 13:09 yeputons

See my investigation here on how to make make install not touch things it shouldn't https://github.com/neondatabase/neon/issues/1873

bojanserafimov avatar Sep 01 '22 14:09 bojanserafimov

Note that this issue seems to shadow our underlying build system issues: e.g. make neon-pg-ext-v15 does always recompile the whole extension, but make --dry-run --assume-new=pgxn/neon/neon.c neon-pg-ext-v15 does not. As if make does not know that binaries depend on source files.

yeputons avatar Sep 09 '22 02:09 yeputons