#1164

`make install` rebuilds with different flags when build-time flags are not repeated (multiconf)

Openvitlavopened 21d ago

Since v0.8.4, build/make/multiconf.make keys each build on the compiler and flags, and the install_* targets depend on libxxhash.a, libxxhash and xxhsum. As a result, make install does not install what make just built unless the exact same CC/CFLAGS/MOREFLAGS/... are passed again. Otherwise it silently builds a new configuration in a new cachedObjs/<hash>/ and installs that.

This is a common distribution pattern: flags are passed to the build step only, and the install step is expected to install the existing build.

Reproducer (v0.8.4)

make -j4 lib xxhsum_and_links MOREFLAGS=-O2
make install PREFIX=/usr LIBDIR=/usr/lib64 DESTDIR=/tmp/xxhash-stage

The second command compiles everything again into a different cachedObjs/<hash>/ directory, without -O2, and installs those binaries.

We build with CC=false CXX=false during install to make sure nothing is compiled at that stage, so for us it fails:

$ make install CC=false CXX=false PREFIX=/usr LIBDIR=/usr/lib64 DESTDIR=/tmp/xxhash-stage
CC cachedObjs/3aea5683d31feaaf9fa9c449730adf12/xxhash.o
make: *** [build/make/multiconf.make:170: cachedObjs/3aea5683d31feaaf9fa9c449730adf12/xxhash.o] Error 1

It already affects shipped packages

Fedora's xxhash-0.8.4-1.fc46 passes MOREFLAGS="... -DXXH_X86DISPATCH_ALLOW_AVX" to make and does not repeat it for make install. The build log shows that %install rebuilds libxxhash.a, libxxhash.so.0.8.4 and xxhsum in new cache directories, so the packaged binaries are not the ones built (and tested) in %build, and lack the MOREFLAGS:

https://kojipkgs.fedoraproject.org/packages/xxhash/0.8.4/1.fc46/data/logs/x86_64/build.log

Executing(%install)
+ /usr/bin/make install DESTDIR=... PREFIX=/usr LIBDIR=/usr/lib64 DISPATCH=1 LIBXXH_DISPATCH=1
CC cachedObjs/f1ede99bcfd3ddf0323a6390657d41aa/xxhash.o
CC cachedObjs/f1ede99bcfd3ddf0323a6390657d41aa/xxh_x86dispatch.o
AR cachedObjs/f1ede99bcfd3ddf0323a6390657d41aa/libxxhash.a
...
LD cachedObjs/c8b0ddff1f4d15001a89d5161327acbc/libxxhash.so.0.8.4
...
LD cachedObjs/d4bd2d014b55b5bb0c80e8d07fcadf24/xxhsum

Expected behavior

I think the multiconf design is right for development builds, but make install should install the configuration that was built, not pick a new one from install-time variables:

  • after make <flags>, a plain make install installs those binaries without compiling anything;
  • if they are missing or out of date, they are rebuilt (with a working compiler) or the install fails (e.g. with CC=false), but a different configuration is never selected silently;
  • a clean make install still builds with the current flags, and a normal make with new flags still selects a new configuration.

Possible approaches

  1. Remember the selected configuration at build time (e.g. the cache path behind the libxxhash.a / xxhsum symlinks, plus the dependency list of that binary), and let install-only goals reuse it when it is up to date, falling back to the current flags otherwise.
  2. Make install targets check only that the binaries exist, as zstd does ([ -e zstd ] || $(MAKE) zstd-release). This is simpler but does not detect stale binaries. #1163 is along these lines.

Activity

0

No activity yet.